Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic TreeLayout of children in ContainerNode (Read 2922 times)
MarkLive64
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Nov 24th, 2009
TreeLayout of children in ContainerNode
Nov 24th, 2009 at 10:17pm
Print Post  
I have created a simple diagram with a start node, container node, and end node. When I add children to the container node and apply a TreeLayout, the children are not arranged. I have also tried adding the children to a DiagramItemsCollection and applying the layout to those. This results in the children being pulled out of the container completely. How do I perform the layout of the children in the container? Here is the code I have tried:

ShapeNode n1 = dgmWorkflow.Factory.CreateShapeNode(0, 0, 30, 30, MindFusion.Diagramming.Silverlight.Shapes.Start);
ContainerNode n2 = dgmWorkflow.Factory.CreateContainerNode(0, 0, 150, 150);
ShapeNode n2_1 = dgmWorkflow.Factory.CreateShapeNode(0, 0, 30, 30, MindFusion.Diagramming.Silverlight.Shapes.Arrow1);
ShapeNode n2_2 = dgmWorkflow.Factory.CreateShapeNode(0, 0, 30, 30, MindFusion.Diagramming.Silverlight.Shapes.Arrow2);
ShapeNode n3 = dgmWorkflow.Factory.CreateShapeNode(0, 0, 30, 30, MindFusion.Diagramming.Silverlight.Shapes.Terminator);

n2.Children.Add(n2_1);
n2.Children.Add(n2_2);

dgmWorkflow.Factory.CreateDiagramLink(n1, n2);
dgmWorkflow.Factory.CreateDiagramLink(n2, n3);
dgmWorkflow.Factory.CreateDiagramLink(n2_1, n2_2);

var layout = new MindFusion.Diagramming.Silverlight.Layout.TreeLayout();
layout.Direction = MindFusion.Diagramming.Silverlight.Layout.TreeLayoutDirection.TopToBottom;
layout.LinkStyle = MindFusion.Diagramming.Silverlight.Layout.TreeLayoutLinkType.Cascading3;
layout.Arrange(dgmWorkflow);

DiagramItemCollection items = new DiagramItemCollection();
items.Add(n2_1);
items.Add(n2_2);
layout.Arrange(dgmWorkflow, items);

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout of children in ContainerNode
Reply #1 - Nov 25th, 2009 at 12:31pm
Print Post  
Check this example:
https://mindfusion.eu/_samples/RecursiveTreeLayout.zip

It applies TreeLayout recursively, so it should work also for nested containers.

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


I love YaBB 1G - SP1!

Posts: 2
Joined: Nov 24th, 2009
Re: TreeLayout of children in ContainerNode
Reply #2 - Nov 25th, 2009 at 6:51pm
Print Post  
Thanks for the example.  This definitely works to layout all of the nested containers and nodes.  However, when I switch the tree layout link type from straight to cascading3, then the links into the containers become all messed up after arranging.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: TreeLayout of children in ContainerNode
Reply #3 - Nov 26th, 2009 at 9:38am
Print Post  
The layout method did not offset the intermediate points of contained links correctly. This version should fix that:
https://mindfusion.eu/_beta/diaglite_ctrlayout.zip

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint