Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Only allow ShapeNodes in ContainerNodes (Read 2822 times)
Chris M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 17
Joined: Oct 7th, 2014
Only allow ShapeNodes in ContainerNodes
Jul 26th, 2016 at 6:47pm
Print Post  
I have a couple of ContainerNodes with some ShapeNodes in them.  I want to be able to drag the ShapeNodes but only allow them to be dropped into ContainerNodes.

I'm trying to use the NodeModifying event along with a LINQ query on my Diagram.Nodes collection but in the debugger the Bounds of a Node are not the actual bounds of the Node.

Is there a better way to do this?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Only allow ShapeNodes in ContainerNodes
Reply #1 - Jul 26th, 2016 at 6:56pm
Print Post  
try this -

Code
Select All
private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	if (e.Node is ShapeNode)
		e.Cancel = !(diagram.GetNodeAt(e.MousePosition, true, true) is ContainerNode);
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Chris M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 17
Joined: Oct 7th, 2014
Re: Only allow ShapeNodes in ContainerNodes
Reply #2 - Jul 26th, 2016 at 7:10pm
Print Post  
You are the man! Works great! Thanks!
  
Back to top
 
IP Logged
 
Chris M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 17
Joined: Oct 7th, 2014
Re: Only allow ShapeNodes in ContainerNodes
Reply #3 - Jul 26th, 2016 at 7:57pm
Print Post  
One more thing.  If I select one or more ShapeNodes, then I am able to drop them outside the ContainerNode..
  
Back to top
 
IP Logged
 
Chris M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 17
Joined: Oct 7th, 2014
Re: Only allow ShapeNodes in ContainerNodes
Reply #4 - Jul 26th, 2016 at 8:23pm
Print Post  
I did this for the SelectionModifying event which seems to work (it's in VB).  If any of the nodes in the selection are moved outside the ContainerNode, the Cancel is set.

Private Sub Diagram_SelectionModifying(sender As Object, e As SelectionValidationEventArgs) Handles Diagram.SelectionModifying

For Each diagramnode As DiagramNode In Diagram.Selection.Nodes
If (TypeOf diagramnode Is ShapeNode) Then
e.Cancel = Not (TypeOf Diagram.GetNodeAt(e.MousePosition, True, True) Is ContainerNode)
End If
Next

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