Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Center diagram nodes (Read 2180 times)
Christian Sack
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Jan 16th, 2014
Center diagram nodes
Jan 16th, 2014 at 10:40am
Print Post  
Hello,
I am using the Diagram and DiagramView classes to display a workflow. I am also using the FlowchartLayout class to automatically layout the nodes. But I didn't find a way to center the nodes within the view (and within the visible area respectively). Is there a way to center the nodes with the help of this layout?

Best regards,
Christian Sack
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Center diagram nodes
Reply #1 - Jan 16th, 2014 at 11:38am
Print Post  
Hi,

At this time the layout classes always start arranging from top-left of diagram.Bounds, unless you use TreeLayout with KeepRootPosition. You can center on a node by setting the scroll position after applying a layout. For scrolling to work, you might also have to ensure the diagram is larger than current view:

Code
Select All
void CenterHorizontally(DiagramNode node)
{
	var viewport = diagramView.ClientToDoc(diagramView.ClientRectangle);
	if (viewport.Width > diagram.Bounds.Width)
	{
		var r = diagram.Bounds;
		r.X -= viewport.Width / 2;
		r.Width = viewport.Width;
		diagram.Bounds = r;
	}

	diagramView.ScrollX = node.GetCenter().X - viewport.Width / 2;
} 



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