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

ZoomToFit Programaticly

Hello,

I have a diagram with Model.SizeToContent set to false.
I need to zoom my view to fit my model.

How can I do that without putting my Model.SizeToContent to true and calling diagram.FitDocument().

Regards.
Lotfi

3 Replies

AD Administrator Syncfusion Team May 12, 2009 09:07 AM UTC

Hi Lotfi,

I have created the sample for your requirement.Here i have mentioned link for the sample.Please check it.


http://files.syncfusion.com/support/Diagram.Windows/Forums/F81066/main.htm

Thanks & Regards,
Gowri


LB Lotfi Belattar May 12, 2009 03:19 PM UTC

HiGowri,

I have modified your sample in order to be able to move items outside the view:
this.model1.BoundaryConstraintsEnabled = false;

And I also added the FitToDocument() in your function:

private void btnZoom_Click(object sender, EventArgs e)
{
RectangleF rectF = new RectangleF();
foreach (Node nd in this.diagram1.Model.Nodes)
{
rectF = RectangleF.Union(rectF, nd.BoundingRectangle);
}
this.diagram1.Model.LogicalSize = new SizeF(rectF.Right, rectF.Bottom);
this.diagram1.FitDocument();
this.diagram1.UpdateView();
}

Now, If I move an Item on the left or up outside the view, the FitDocument does not work.
Is there a parameter that I have to set in order to fix that ?

Regards,
Lotfi


AD Administrator Syncfusion Team May 14, 2009 01:58 PM UTC

Hi Lotif,


Thanks for your update.

We have updated the response for your incident(55811) the same issue which you have mentioned in this forum.Let me know your problem getting solved.


Regards,
Gowri

Loader.
Live Chat Icon For mobile
Up arrow icon