Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic floating node (Read 1959 times)
chris g
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Jul 17th, 2013
floating node
Jul 17th, 2013 at 11:00am
Print Post  
Hi,

I'm using flowchart.net for windows forms and am trying to keep a node centered in the view (only horizontally.) The view never has horizontal scroll-bars when I'm trying to do this.

The diagram measure units are in pixels, the diagram autoresize property is set to none. The problem is that when I set the bounds, it moves too far to the right. I'm almost certainly doing something silly, I'd be grateful if anyone could give me any pointers.

_node is the node I would like to center in the view and this code is called from the resize event handler on the diagram view.

Code
Select All
RectangleF NodeBounds = _node.Bounds;
RectangleF DocDiagramBounds = View.ClientToDoc(new Rectangle(0, 0, View.Width, 0));
DocDiagramBounds.Height = Diagram.Bounds.Height;
Diagram.Bounds = DocDiagramBounds;
NodeBounds.X = (((float)Diagram.Bounds.Width) / 2.0f) - (_node.Bounds.Width / 2.0f);
 _node.SetBounds(NodeBounds, true, true);
 




Thanks.
Chris.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: floating node
Reply #1 - Jul 17th, 2013 at 11:20am
Print Post  
Hi,

Your code works correctly in my test project. However you might get unexpected results if the view's ZoomFactor is different from 100 or the scroll position is different from 0 at the time when you call ClientToDoc. Add a breakpoint at that line and verify these properties' values when the debugger hits it.

Also check other references to _node; there might be another event handler moving it to the right later on (e.g. note that view_Resize is raised once before Form_Load).

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


I Love MindFusion!

Posts: 3
Joined: Jul 17th, 2013
Re: floating node
Reply #2 - Jul 17th, 2013 at 11:28am
Print Post  
Thankyou for an extremely quick response. I will check out your suggestions.
  
Back to top
 
IP Logged
 
chris g
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Jul 17th, 2013
Re: floating node
Reply #3 - Jul 17th, 2013 at 11:59am
Print Post  
Thanks, with your help I was able to isolate the problem. It now looks great Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint