Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Dragging nodes inside the diagram (Read 3705 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Dragging nodes inside the diagram
Jan 11th, 2010 at 12:22pm
Print Post  
I implemented 2 event handlers:
Code
Select All
	  private void OnDiagram_NodeModifying(object sender, NodeValidationEventArgs e)
	  {
		if (e.Node.Bounds.Top < 1 || e.Node.Bounds.Left < 1)
		    e.Cancel = true;
		foreach(DiagramLink link in e.Node.GetAllLinks())
		{
		    if (link.ControlPoints.Count == 3)//Linear link
			  link.Route();
		}
	  }
	  private void OnDiagram_SelectionMoving(object sender, ValidationEventArgs e)
	  {
		Selection selection = m_Diagram.Selection;
		if (selection.Bounds.Top < 1 || selection.Bounds.Left < 1)
		    e.Cancel = true;
	  }
 


Is there any way to stop dragging selection or node instead e.Cancel = true;
CancelDrag() is bad for me because it returns the old position and I want to stop dragging at current position (Top or Left == 1)?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging nodes inside the diagram
Reply #1 - Jan 11th, 2010 at 1:28pm
Print Post  
Diagram.Interaction.Complete() should do that. However I'm not sure if a validation event would be a nice place for calling it; if it doesn't work from these handlers, try calling it from the behavior class' OnMouseMove override.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Dragging nodes inside the diagram
Reply #2 - Jan 14th, 2010 at 7:52am
Print Post  
Hello, Stoyan! Say me please how can I override the event Ctrl+MouseDrag? I want to implement the following behavior: when user presses the Ctrl key and drag the node by mouse this node will be copied at the drop mouse position
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging nodes inside the diagram
Reply #3 - Jan 14th, 2010 at 8:44am
Print Post  
Hi,

Set diagram.ModifierKeyActions.Control = None to stop drawing a selection rectangle when Ctrl is pressed. In the StartDraw override check if Keyboard.Modifiers & Control is set, and if so clone the underlying node and return InteractionState(clone, Modify).

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Dragging nodes inside the diagram
Reply #4 - Jan 14th, 2010 at 9:33am
Print Post  
Thanks! All works ok!
  
Back to top
 
IP Logged
 
Amx
YaBB Newbies
*
Offline


digito ergo sum

Posts: 21
Joined: Jan 19th, 2010
Re: Dragging nodes inside the diagram
Reply #5 - Jan 19th, 2010 at 3:47pm
Print Post  
Hi, I'm testing Diagramming for WPF to replace our current diagramming lib.

I need to drag a node with the same simplicity used to add a link (by clicking only one time a node, without select it before) but I don't find the way... Cry

Best regards,
Amx.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging nodes inside the diagram
Reply #6 - Jan 19th, 2010 at 3:52pm
Print Post  
Hi,

Set Diagram.ModificationStart = Auto.

Best regards,
Stoyan
  
Back to top
 
IP Logged
 
Amx
YaBB Newbies
*
Offline


digito ergo sum

Posts: 21
Joined: Jan 19th, 2010
Re: Dragging nodes inside the diagram
Reply #7 - Jan 19th, 2010 at 4:03pm
Print Post  
Great.. Tnx Wink
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint