Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ZoomToFit for diagram not working. (Read 1133 times)
Anant_Shukla
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 36
Joined: Mar 16th, 2009
ZoomToFit for diagram not working.
Mar 24th, 2009 at 8:52am
Print Post  
Hi,

I need the diagram to resize such a way to fit all the items on the diagram. For the purpose I have written the following code :

private void InitDiagram(Diagram diagram)
{
diagram.Behavior = Behavior.Modify;
diagram.BackBrush = Brushes.LightBlue;diagram.AllowSelfLoops = false;
diagram.AllowUnconnectedLinks = false;
diagram.AllowLinksRepeat = false;
diagram.LinkCrossings = LinkCrossings.Arcs;
diagram.ContainerMargin = 0;
diagram.RouteLinks = true;
}

Nodes are added in the window constructor. The code used by me is as follows :

ShapeNode node1 = new ShapeNode(diagram);
InitNodes(node1);
node1 = diagram.Factory.CreateShapeNode(new Point(150, -40), new Size(45, 45));
Uri uri1 = new Uri(@"..\..\stickyImage.BMP", UriKind.RelativeOrAbsolute);
node1.Image = new BitmapImage(uri1);
node1.ImageAlign = ImageAlign.Center;
node1.Text = "Node1";
diagram.Nodes.Add(node1);

Also to include the nodes with negative value of coordinates following logic is also added in the window constructor to show them properly which is as follows :

Rect diagBounds = diagram.Bounds;
Rect rect = diagram.GetContentBounds(false, false);

diagBounds.Union(rect);
diagram.Bounds = diagBounds;

diagram.ScrollTo(rect.TopLeft);

Now after all this logic in the window constructor I have called the diagram.ZoomToFit() method which doesnot seem to work.

diagram.ZoomToFit();

Ant suggestions what I am missing.

Thanks and Regards,
Anant Shukla.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint