Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) How to use Container node? (Read 10501 times)
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
How to use Container node?
Oct 14th, 2008 at 8:32pm
Print Post  
???
Do you have samples for container node?

Thanks a lot.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #1 - Oct 15th, 2008 at 11:57am
Print Post  
ContainerNodes should be pretty straightforward to use. What exactly do you need a sample for?
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #2 - Oct 15th, 2008 at 11:04pm
Print Post  
Is there a way to resize the ContainerNode by mouse? But I don't want to resize other ShapeNodes in the same diagram.

Can I drag and drop a ShapeNode from the NodeListView directly to a ContainerNode? In the project FlowCharter, I can only drag a ShapeNode to the diagram, then drag it to the ContainerNode.

Would you please give some code snippet?

Thanks a lot.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #3 - Oct 16th, 2008 at 7:08am
Print Post  
It seems that lets you resize containers:

// in NodeCreated handler
ContainerNode container = e.Node as ContainerNode;
if (container != null)
{
     container.Caption = "container 123";
     container.EnabledHandles = AdjustmentHandles.All & ~AdjustmentHandles.Rotate;
     container.HandlesStyle = HandlesStyle.DashFrame;
}

though our developers tell me they haven't planned for that, and the containers might still resize automatically in some situations.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #4 - Oct 16th, 2008 at 7:49am
Print Post  
As for dragging from the listview to a ContainerNode, first set

containerNode.AllowDrop = true;

Next download this version - it adds raising NodeCreated for nodes dropped from the NodeListView:

https://mindfusion.eu/_temp/listviewevt.zip

and handle NodeCreated like this

DiagramNodeCollection nodes = diagram.GetNodesAt(e.Node.Bounds.Location);
foreach (DiagramNode node in nodes)
{
     ContainerNode containerNode = node as ContainerNode;
     if (containerNode != null)
     {
           containerNode.Add(e.Node);
           break;
     }
}

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #5 - Oct 16th, 2008 at 2:13pm
Print Post  
Thank you very much, Stoyo.

There is one issue left.
I collapse a ContainerNode and create some ShapeNodes below the collapsed ContainerNode.
Then I expand the ContainerNode. The ContainerNode overlaps the ShapeNodes.
This is not what I thought.

The purpose to use ContainerNode is to Collapse/Expnd the sub-diagram drawn in the ContainerNode and save some space in the main diagram.

I want the diagram rearrange the layout when the ContainerNode collapses/expands.

Can I implement this feature?

Thanks again.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #6 - Oct 16th, 2008 at 3:50pm
Print Post  
You want the new nodes to move further down the diagram when you expand the container? or they should simply appear above the container on the Z order?
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #7 - Oct 16th, 2008 at 5:26pm
Print Post  
I want the new nodes to move further down the diagram when I expand the container.

Thanks a lot!
« Last Edit: Oct 16th, 2008 at 7:22pm by chris »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #8 - Oct 17th, 2008 at 9:02am
Print Post  
If each node in your diagram is in a container, that should be simple. You could handle the ContainerFolded and Unfolded events and run any of the layout algorithms from there. Set the layout's MultipleGraphsPlacement property to Vertical to order the containers in column, and pass a DiagramItemCollection containing all ContainerNodes as an argument to the Arrange method.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #9 - Oct 17th, 2008 at 3:31pm
Print Post  
We can not put all the nodes inside ContainerNodes. If the new nodes are not in a ContainerNode, is there a way to rearrange the layout?

When a ContainerNode is collapsed, the space used by the ContainerNode may be occupied by other stuff. When the ContainerNode is expanded again, it should not overlap with other stuff which occupies the original space used by the ContainerNode.


Thanks.
« Last Edit: Oct 17th, 2008 at 10:28pm by chris »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #10 - Oct 20th, 2008 at 12:29pm
Print Post  
You could add all top-level nodes to an array or list, and offset all nodes whose Bounds.Y value is greater than the (un)folded container 's Y when the Folded/Unfolded event is raised. By top-level nodes I mean ones that are not in a container. The amount to offset the nodes below the container should be equal to the difference between the container's Bounds before folding it and its CaptionHeight.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #11 - Oct 21st, 2008 at 2:22pm
Print Post  
I'm wandering if this feature is a general expectation for ContainerNodes and can be added to the next release?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Container node?
Reply #12 - Oct 21st, 2008 at 2:44pm
Print Post  
It seems what you need is something like a vertical stackpanel -like layout, which we haven't considered using ContainreNodes for until now. I suppose we could implement it as a simple layout class, say StackLayout, rather than as a feature of the ContainerNode class.

Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #13 - Oct 21st, 2008 at 3:46pm
Print Post  
Thank you very much, Stoyo.

It's a good idea. If you can implement a new StackLayout class which can rearrange the ContainerNode ( stretch/collapse both in vertical and horizental ), that's great.

Our user will create very large and complex diagram. This can reduce the complexity and space. What I need is like a kind of SubDiagram concept.
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: How to use Container node?
Reply #14 - Oct 23rd, 2008 at 8:04pm
Print Post  
Stoyo wrote on Oct 20th, 2008 at 12:29pm:
You could add all top-level nodes to an array or list, and offset all nodes whose Bounds.Y value is greater than the (un)folded container 's Y when the Folded/Unfolded event is raised. By top-level nodes I mean ones that are not in a container. The amount to offset the nodes below the container should be equal to the difference between the container's Bounds before folding it and its CaptionHeight.



In the ContainerFolded event handler, the height in the ContainerBound equals to the CaptionHeight.
How can I get the expanded height of the ContainerNode? I think it should be save somewhere inside the ContainerNode.

Also, how can I get the horizontal offset between the folded ContainerNode and the expanded ContainerNode?

Thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint