Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ContainerNode layout/positioning (Read 3266 times)
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
ContainerNode layout/positioning
Feb 24th, 2012 at 12:08pm
Print Post  
Hi,

I would like to create a ContainerNode and have a number of nodes inside it that are laid out side by side.

If I run the following code;

Code
Select All
// create the container
_container = new ContainerNode();
_container.Bounds = new Rect(new Point(50, 50), new Size(250, 75));
diagram.Nodes.Add(_container);

// add the first node
var node1 = new ShapeNode();
node1.Bounds = new Rect(new Point(0, 0), new Size(50, 50));
diagram.Nodes.Add(node1);
_container.Add(node1);

// add the second node - this is side-by-side with the first node which is good
var node2 = new ShapeNode();
node2.Bounds = new Rect(new Point(50, 0), new Size(50, 50));
diagram.Nodes.Add(node2);
_container.Add(node2);
 



... this creates a ContainerNode with two nodes side by side.

If I then move the ContainerNode to a new position in my diagram and run this code;

Code
Select All
// add a third node - this should be alongside the other two nodes, but it isn't
var node3 = new ShapeNode();
node3.Bounds = new Rect(new Point(100, 0), new Size(50, 50));
diagram.Nodes.Add(node3);
_container.Add(node3);
 



.. what I am finding is that the third node is not side by side with the others - it is in a different place entirely. This only happens if I move the ContainerNode inbetween adding the first two nodes and the third.

Why are the nodes not being placed in the positions that I have specified?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ContainerNode layout/positioning
Reply #1 - Feb 24th, 2012 at 1:57pm
Print Post  
Hi,

Bounds should be specified in diagram coordinates, even for nodes that will be added to container. Add the container's Bounds.Location value to the relative origin you need for the child node and it should appear where expected.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
matt.s
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 56
Joined: Apr 3rd, 2008
Re: ContainerNode layout/positioning
Reply #2 - Feb 24th, 2012 at 3:16pm
Print Post  
Yes - that works fine - thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint