Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic resizeToFitItems not updating node location? (Read 2906 times)
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
resizeToFitItems not updating node location?
Jan 5th, 2009 at 7:04pm
Print Post  
I have just started using Diagram.ResizeToFitItems but it doesn't seem like the diagram.nodes shapenode bounds/center are being updated when I do so. Am I missing something?

Dean
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: resizeToFitItems not updating node location?
Reply #1 - Jan 6th, 2009 at 6:18am
Print Post  
This resizes the diagram object so it gets just big enough to contain all items. If you need to resize items to fit their contents, call ResizeToFitText or ResizeToFitImage from a loop.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
Re: resizeToFitItems not updating node location?
Reply #2 - Jan 7th, 2009 at 4:48pm
Print Post  
Thanks, Stoyo but what is happening to me is that the diagram resizes, the nodes move but the node locations don't change/update.
  
Back to top
 
IP Logged
 
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
Re: resizeToFitItems not updating node location?
Reply #3 - Jan 7th, 2009 at 5:52pm
Print Post  
Stoyo,

I don't think I understand the relationship between the DiagramView.Size and the Diagram.Bounds. I see that the diagramView.Size is unchanged by the resizetoFit, the diagram is reduced as necessary and the diagram's x and y value are translated.

The real problem I have is I am recording the location of the nodes on the diagramview so that when I redraw the diagram from scratch I can place them. I'm not sure how to integrate the resizeToFit behavior into this system. Should I record the diagram bounds, the on restore i would set the canvas size, place the diagram, and then plot the nodes relative to the diagram bounds?

Thanks,

Dean
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: resizeToFitItems not updating node location?
Reply #4 - Jan 7th, 2009 at 8:12pm
Print Post  
The nodes do not move, but the origin of the coordinate system shifts - that is the top-left corner of the diagram - so the nodes appear at a different position. If you want to update just the size of the diagram, you could save the Bounds value, call ResizeToFitItems(), and set Bounds to RectangleF.FromLTRB(oldBounds.Left, oldBounds.Top, newBounds.Right, newBounds.Bottom).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
Re: resizeToFitItems not updating node location?
Reply #5 - Jan 8th, 2009 at 8:26pm
Print Post  
how can one control the origin of the coordinate system programmatically?

Thanks!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: resizeToFitItems not updating node location?
Reply #6 - Jan 9th, 2009 at 9:59am
Print Post  
You specify where the origin point is located inside the diagram by setting Bounds. Calling ResizeToFitItems changes Bounds too, so to restore the CS origin, you set the Bounds' Left and Top properties back to their old values. That should take care of all items being displaced on screen after calling ResizeToFit.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint