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

Zoom the rectangle to the Diagram Control Dimensions without loosing the Aspect Ratio

Hi,

I have a rectangle with some predefine width and height.

I need to draw the rectangle in such a way that it occupies the entire viewable are of the diagram control. In other words it shoulb be zoomed in maintaining the aspect ratio.

For e.g., if the rectangle width is 100 and height is 100.
Let the diagram control width is 500 and height is also 500.

Now my rectangle should occupy the entire width and height of the diagram control.

I cant directly set the height and width of the rectangle to diagram dimensions as there are numerous calculations are based on the rectangle dimensions.

In a simplified way my requirement is to zoom the rectangle to the diagram control dimensions without loosing the aspect ratio.

Please let me know the solution for this ASAP.

Thanks In advance,
Murali

3 Replies

GM Gowri Manohari D Syncfusion Team May 20, 2009 12:51 PM UTC

Hi Murali,

Thanks for choosing Syncfusion Products.

The below is the code snippet for your requirement.Let me know it will meet your requirement.

Syncfusion.Windows.Forms.Diagram.Rectangle rect = new Syncfusion.Windows.Forms.Diagram.Rectangle(50, 50,100, 100);
rect.NodeScale.Width = diagram1.Width;
diagram1.Model.AppendChild(rect);

Thanks & Regards,
Gowri


MK Murali Krishna May 20, 2009 12:57 PM UTC

Hi,

The NodeScale.Width is not accessable due to its Protection level.
Do I need to include something?
My version of SyncFusion is 6.3.0.32.

Thanks
Murali


AD Administrator Syncfusion Team May 21, 2009 06:54 AM UTC

Hi Murali,

The below is the code snippet for your version.


Syncfusion.Windows.Forms.Diagram.Rectangle rect = new Syncfusion.Windows.Forms.Diagram.Rectangle(50, 50, 100, 100);
rect.NodeScale.ModelScale = diagram1.Width;
diagram1.Model.AppendChild(rect);


Let me know any future reference in this regard.



Thanks & Regards,
Gowri

Loader.
Live Chat Icon For mobile
Up arrow icon