Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ContainerNode (Read 2588 times)
Novice
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Apr 19th, 2011
ContainerNode
Apr 20th, 2011 at 10:41am
Print Post  
How can I programatically get a containerNode to resize to fit all the DiagramItems that are either in the containerNode.SubOrdinateGroup or are AttachedTo an item in the ContainerNode.SubOrdinateGroup with FollowMasterContainment set to true.

I have tried to use containerNode.UpdateBounds() but for some reason this is not working for me.

At the moment I can programatically add a tree of ShapeNodes and TableNodes to a ContainerNode such that when I move any node in the tree its SubOrdinateGroup moves correctly in sync.  Also when I fold the containerNode all the DiagramItems in the tree that I expect to be hidden are correctly hidden.

However I cannot get the containerNode to resize so that all the DiagramItems in the tree are contained within the bounds of the containerNode.  In fact as far as I can tell when it comes to setting the size of the containerNode the containerNode does not recognise these DiagramItems which are hidden when the containerNode is folded.

Hope that makes sense.  If you can point me in the right direction it would be great.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ContainerNode
Reply #1 - Apr 20th, 2011 at 12:44pm
Print Post  
UpdateBounds should do that. Are you sure container.UpdateBounds() is the last method you call, and not moving or attaching additional nodes afterwards?
  
Back to top
 
IP Logged
 
Novice
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Apr 19th, 2011
Re: ContainerNode
Reply #2 - Apr 20th, 2011 at 2:16pm
Print Post  
UpdateBounds is definitely the last method I'm calling (have also debugged to confirm UpdateBounds has no affect).

The following is extreme simplification of what I'm doing but demonstrates the affect I'm getting.  I guess I must be doing something not quite right.  Please have a look and advise.

       private void AddTestNodes(Diagram diagram, PointF docPt)
       {
           // add the containerNode
           SizeF sizeF = new SizeF(100, 100);
           ContainerNode containerNode = diagram1.Factory.CreateContainerNode(docPt, sizeF, true);
           containerNode.Brush = (MindFusion.Drawing.Brush)diagram1.BackBrush.Clone();
           containerNode.Caption = "My First Container";

           // add a TableNode
           PointF location = new PointF(containerNode.Bounds.X + (containerNode.Bounds.Width / 2), containerNode.Bounds.Bottom - 5);
           SizeF size = new SizeF(20,20);
           TableNode tableNode = diagram.Factory.CreateTableNode(location, size);

           // add a ShapeNode and ...
           ShapeNode shapeNode = diagram.Factory.CreateShapeNode(location.X, location.Y + 30, 15, 15);
           // ... attach to tableNode so moves with tableNode
           shapeNode.AttachTo(tableNode, AttachToNode.BottomCenter);

           // ensure that the tableNode is hidden when the master ContainerNode is folded
           tableNode.AttachTo(containerNode, AttachToNode.BottomCenter);

           // ensure that the items in the SubordinateGroup (ie the shapeNode) of tableNode are also hidden when the master containerNode is folded
           tableNode.SubordinateGroup.FollowMasterContainment = true;

           // this is the call to resize that does not seem to make any difference
           containerNode.UpdateBounds();
}

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ContainerNode
Reply #3 - Apr 20th, 2011 at 4:52pm
Print Post  
It should work if you replace

tableNode.AttachTo(containerNode, AttachToNode.BottomCenter);

with

containerNode.Add(tableNode);
  
Back to top
 
IP Logged
 
Novice
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 14
Joined: Apr 19th, 2011
Re: ContainerNode
Reply #4 - Apr 20th, 2011 at 6:31pm
Print Post  
Made the suggested change and this is now working.  Many thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint