Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Layout of containers inside container (Read 3198 times)
sledenev
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Dec 16th, 2009
Layout of containers inside container
Apr 13th, 2010 at 12:28pm
Print Post  
Hi,

For my task I need to create parent ContainerNode and put inside two (N in general) child ContainerNodes and layout child containers inside parent container.

But before closed/open container action main group looks weird: first child is inside of parent, second child attached outside.

Please, see my code below. Thanks in advance.


ContainerNode mainContainer = new ContainerNode();
ContainerNode childContainer1 = new ContainerNode();
ContainerNode childContainer2 = new ContainerNode();
diagram1.Nodes.Add( mainContainer );
diagram1.Nodes.Add( childContainer1 );
diagram1.Nodes.Add( childContainer2 );

mainContainer.Add( childContainer1 );
mainContainer.Add( childContainer2 );

DiagramItemCollection arranger = new DiagramItemCollection
{
childContainer1, childContainer2
};

GridLayout fl1 = new GridLayout();
fl1.Arrange( diagram1, arranger );
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Layout of containers inside container
Reply #1 - Apr 13th, 2010 at 1:08pm
Print Post  
You'll need to call the parent container's UpdateBounds method.
  
Back to top
 
IP Logged
 
sledenev
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Dec 16th, 2009
Re: Layout of containers inside container
Reply #2 - Apr 15th, 2010 at 8:55am
Print Post  
Stoyo wrote on Apr 13th, 2010 at 1:08pm:
You'll need to call the parent container's UpdateBounds method.


Thank you, it works.

But I have another question. I have arranged tree of shapenodes and need to put this tree inside the container and keep their layout. I've tried several ways and cant succeed: nodes just overlapped with each other. What am I doing wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Layout of containers inside container
Reply #3 - Apr 15th, 2010 at 10:50am
Print Post  
Do you need to move the tree to a container programmatically? It should look like this:

foreach (DiagramNode node in treeNodes)
     container.Add(node);

Stoyan
  
Back to top
 
IP Logged
 
sledenev
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Dec 16th, 2009
Re: Layout of containers inside container
Reply #4 - Apr 15th, 2010 at 11:47am
Print Post  
Stoyo wrote on Apr 15th, 2010 at 10:50am:
Do you need to move the tree to a container programmatically? It should look like this:

foreach (DiagramNode node in treeNodes)

container.Add(node);

Stoyan


I do exactly like you said, but the result is not one that I expect. That's my code:

ContainerNode container = new ContainerNode( diagram1 );
ShapeNode s1 = new ShapeNode( diagram1 );
ShapeNode s2 = new ShapeNode( diagram1 );
DiagramLink link = new DiagramLink( diagram1, s1, s2 );

diagram1.Nodes.Add( s1 );
diagram1.Nodes.Add( s2 );
diagram1.Links.Add( link );
diagram1.Nodes.Add( container );

DiagramItemCollection arrange = new DiagramItemCollection { s1, s2 };
TreeLayout treeLayout = new TreeLayout( s1, TreeLayoutType.Centered );
treeLayout.Arrange( diagram1, arrange );

container.Add( s1 );
container.Add( s2 );
container.UpdateBounds( true );

GridLayout gridLayout = new GridLayout();
gridLayout.Arrange( diagram1 );
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Layout of containers inside container
Reply #5 - Apr 15th, 2010 at 1:09pm
Print Post  
Set arrange = new DiagramItemCollection { s1, s2, link } and it will work.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint