Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Container Node (Read 2082 times)
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Container Node
Apr 14th, 2011 at 9:33am
Print Post  
Hi Stoyo

How can i make sure that the Node inside a container node, should not be deleted or moved out from the container node by user action. But If user deletes the container node then it should be deleted along with the node inside the container node.

And the node inside the container node should not allowed to resize but if user resize the container node then the node inside the container node also should reflect.


If you paste me the sample code would be Great Thankful.

N.B. : Each Container node will have only one node inside.



Thanks and Best Regards
Hamid
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container Node
Reply #1 - Apr 14th, 2011 at 10:19am
Print Post  
Hi Hamid,

You can handle NodeDeleting and NodeModifying like this to prevent deleting and resizing container's children:

Code
Select All
private void diagram_NodeDeleting(object sender, NodeValidationEventArgs e)
{
	ContainerNode container = ContainerNode.GetContainer(e.Node);
	if (container != null)
		e.Cancel = true;
} 



This will delete child nodes automatically when a c container is deleted, or you could also delete them from code in response to the container's NodeDeleted:

Code
Select All
private void diagram_ContainerChildAdded(object sender, MindFusion.Diagramming.ContainerChildEventArgs e)
{
	e.Container.SubordinateGroup.AutoDeleteItems = true;
} 



This will resize the first child node of a container:
Code
Select All
private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	ContainerNode container = e.Node as ContainerNode;
	if (container != null && container.SubordinateGroup != null)
	{
		DiagramNode child = container.SubordinateGroup.AttachedNodes[0];
		RectangleF r = container.Bounds;
		r.Inflate(-10, -10);
		child.Bounds = r;
	}
} 



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


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Container Node
Reply #2 - Apr 14th, 2011 at 11:08am
Print Post  
Hi Stoyo

Thanks a lot for your quick response and that works fine.

I have another question that I Create the link connecting to the Container node in the diagram and when i apply the FlowChart Layout (or any layout), the node inside the container node is moved out.

How can i fix this?

Thanks and Regards
Hamid
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Container Node
Reply #3 - Apr 14th, 2011 at 1:09pm
Print Post  
Hi Hamid,

I think recent versions don't do that. If you are with an older version, try running the layouts with KeepGroupLayout enabled.

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