Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Cancel drag (Read 2248 times)
cthompso
YaBB Newbies
*
Offline



Posts: 6
Joined: May 27th, 2009
Cancel drag
May 27th, 2009 at 11:18pm
Print Post  
When I drag a node from a NodeListView onto a Diagram, is the DraggedNode.Node a clone or the node that is in the list view?  In the drop event handler, I am creating a node and adding it to the diagram.  How do I prevent the DraggedNode from being dropped onto the diagram for me?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cancel drag
Reply #1 - May 28th, 2009 at 7:33am
Print Post  
Yes, the OnDrop handler calls the Clone method of the dragged node and adds the copy to the diagram.

You can prevent the operation from a handler of the Diagram.DragOver event:

Code
Select All
private void OnDragOver(object sender, DragEventArgs e)
{
	if (e.GetPosition(diagram.DocumentPlane).X < 100)
		e.Effects = DragDropEffects.None;
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
cthompso
YaBB Newbies
*
Offline



Posts: 6
Joined: May 27th, 2009
Re: Cancel drag
Reply #2 - May 29th, 2009 at 1:07am
Print Post  
Stoyan,
The code below didn't achieve the result I was looking for.  It cancels the drop event.  What I want to do is after a node is dragged and dropped from a NodeListView, I want to automatically draw some links, make the node larger, add some text, etc.  In the drop event handler I get a reference to the dragged node like so: ((DraggedNode)e.Data.GetData("MindFusion.Diagramming.Wpf.DraggedNode")).Node.  I assumed I was working with a clone.  I added links but they did not appear on the diagram.  So I made a clone of the dragged node, added it to the diagram, and then added links.  In this case the links appeared on the diagram.  But then I get two nodes added to the diagram (the one I added and the one that is automatically added).  What would you recommend I do to be able to drop a node and then draw links to it as part of the drop?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Cancel drag
Reply #3 - May 29th, 2009 at 4:21am
Print Post  
The control raises NodeCreated when the drop operation creates the node, and it gives you a reference to the automatically added node. You can handle that event to create some links and change the node properties.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint