We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get Diagram actual size

Hi,
how can I get the actual size of my diagram?

For example:
rect = new Rectantle(0,0,20,20);

I want to get the size of the diagram, so, width = 20, height = 20.
If I have:
rect1 = new Rectantle(0,0,20,20);
rect 2= new Rectantle(20,0,20,20);
I'll have width = 40, height = 20.

This is a very simple sample; I should know the size of a DirectedTreeLayout with lots of nodes and levels.

Thank you,
Ivan

1 Reply

SK Swarnesh Krishna Kumar Syncfusion Team May 25, 2015 09:12 AM UTC

Hi Ivan,
Thanks for using Syncfusion products.
We are glad to inform that we have created a simple sample to achieve your requirement.


how can I get the actual size of my diagram?

For example:

rect = new Rectantle(0,0,20,20);


I want to get the size of the diagram, so, width = 20, height = 20.

If I have:

rect1 = new Rectantle(0,0,20,20);

rect 2= new Rectantle(20,0,20,20);

I'll have width = 40, height = 20.


This is a very simple sample;


We suggest you to get the size of the diagram by

Diagram.Model.LogicalSize.Width and Diagram.Model.LogicalSize.Height.


Here is the code snippet:


[C#]

//Finding the size of the diagram

SizeF DiagramSize = new SizeF(diagram1.Model.LogicalSize.Width, diagram1.Model.LogicalSize.Height);

I should know the size of a DirectedTreeLayout with lots of nodes and levels.

We suggest you to get the size of the layout by passing the Layoutmanager.Model.Nodes and the MeasureUnit in Diagram.Controller.GetBoundingRect property.

Here is the code snippet:


[C#]

DirectedTreeLayoutManager dtlm = new DirectedTreeLayoutManager(this.diagram1.Model, 0, 50, 60);

RectangleF Rect = new RectangleF();

//Finding the size of the layout Rect=this.diagram1.Controller.GetBoundingRect(dtlm.Model.Nodes, MeasureUnits.Pixel);

SizeF LayoutSize = new SizeF(Rect.Width, Rect.Height);


Here is the Sample:

Sample




Please let us know if any concerns.
Regards,
Swarnesh K

Loader.
Live Chat Icon For mobile
Up arrow icon