Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Dragging outside of the bounds of the Diagram View (Read 4337 times)
Neverforget115
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Feb 11th, 2013
Dragging outside of the bounds of the Diagram View
Apr 16th, 2013 at 1:00pm
Print Post  
Hello,

I am attempting to provide functionality to users of my application to drag a node out of my diagram view and drop it onto an Infragistics Ultragrid, so it can trigger an event that will open up another form using the node's tagged data object, and the ultragrid row's data object. The actual drag/drop functionality won't be a problem, as that has already been solved in these forums previously:

http://mindfusion.eu/Forum/YaBB.pl?num=1360593365/0#2

However, my issue is that I cannot drag a node outside of the diagram view. It just scrolls around the diagram.

I want that to still be the case, because it is important to be able to drag and drop nodes around that diagram. Whenever I hit a certain part of the diagram (beyond which, I know there is nothing else to the diagram), I want to turn off the scrolling, and be able to carry the node outside of the diagramview. Getting the bounds that I want to use to shut off the scrolling should be relatively simple. The only thing I need to know is how to turn off the scrolling when I hit those bounds.

Any thoughts on how to solve this?

Thank you!
-Seth
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging outside of the bounds of the Diagram View
Reply #1 - Apr 16th, 2013 at 4:37pm
Print Post  
Hi,

You could start the external drag operation from NodeModifying event handler when you detect the dragged node is no longer inside the content bounds:

Code
Select All
RectangleF contentRect = new RectangleF(0, 0, 300, 300);

private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	var testRect = contentRect;
	testRect.Inflate(50, 50); // add buffer area where nodes can still be dragged internally
	if (!testRect.Contains(e.Node.Bounds))
	{
		DoDragDrop("test", DragDropEffects.Copy);
		e.CancelDrag(); // stop internal drag operation
	}
}

private void diagram_NodeModified(object sender, NodeEventArgs e)
{
	contentRect = RectangleF.Union(contentRect, e.Node.Bounds);
}

private void diagram_NodeCreated(object sender, NodeEventArgs e)
{
	contentRect = RectangleF.Union(contentRect, e.Node.Bounds);
} 



You can do the same from SelectionMoving handler if you need to support external drag for multiple selected nodes.

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


I Love MindFusion!

Posts: 4
Joined: Feb 11th, 2013
Re: Dragging outside of the bounds of the Diagram View
Reply #2 - Apr 17th, 2013 at 12:49pm
Print Post  
Excellent!  Thank you!

-Seth
  
Back to top
 
IP Logged
 
Andy B
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: May 1st, 2013
Re: Dragging outside of the bounds of the Diagram View
Reply #3 - May 1st, 2013 at 7:29pm
Print Post  
Is there a way to change the cursor back and get back the original dragdrop event if the mouse goes outside the content rectangle temporarily but comes back "in bounds"?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging outside of the bounds of the Diagram View
Reply #4 - May 2nd, 2013 at 8:46am
Print Post  
You can cancel the OLE drag operation via the QueryContinueDrag event. Then the DoDragDrop method returns and the internal drag operation will continue as usual:

Code
Select All
bool cancelInternalDrag;

private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	var testRect = contentRect;
	testRect.Inflate(50, 50); // add buffer area when nodes can still be dragged internally
	if (!testRect.Contains(e.Node.Bounds))
	{
		cancelInternalDrag = true;
		DoDragDrop("test", DragDropEffects.Copy);

		if (cancelInternalDrag)
			e.CancelDrag(); // stop internal drag operation
	}
}

private void Form1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
	var diagramPoint = diagramView.ClientToDoc(
		diagramView.PointToClient(MousePosition));
	var testRect = contentRect;
	testRect.Inflate(50, 50); // add buffer area when nodes can still be dragged internally
	if (testRect.Contains(diagramPoint))
	{
		e.Action = DragAction.Cancel;
		cancelInternalDrag = false;
	}
} 



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