Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Dragging a ShapeNode from Diagram to Diagram.. (Read 3232 times)
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Dragging a ShapeNode from Diagram to Diagram..
Jan 30th, 2014 at 3:50pm
Print Post  
Hello,

when i drag e.g. a file from windows explorer into a diagram, both PreviewMouseMove and DragOver events fire, and i can catch and process this events.

But when i drag a ShapeNode from another Diagram onto this one, these do not fire at all?

cheers
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging a ShapeNode from Diagram to Diagram..
Reply #1 - Jan 30th, 2014 at 5:01pm
Print Post  
Hi,

You will get DragOver raised in the second diagram only if you call DragDrop.DoDragDrop from the first diagram to start OLE drag and drop operation. The example here might help, though it's for our Windows Forms library:
http://mindfusion.eu/Forum/YaBB.pl?num=1366117235/1#1

You will have to replace Control.DoDragDrop with DragDrop.DoDragDrop and RectangleF with Rect.

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


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: Dragging a ShapeNode from Diagram to Diagram..
Reply #2 - Mar 4th, 2014 at 4:13pm
Print Post  
erm.. when i drag out a node to another view, then i redraw all the contents of the Diagram (to take out the dragged-out node) all looks fine.

But, when i try drag again another node, (just starting the drag within diagram) - i think the Diagram.Interaction never settled to null - i get a bad crash like:

bject reference not set to an instance of an object. | System.NullReferenceException: Object reference not set to an instance of an object.
   at MindFusion.Diagramming.Wpf.DiagramNode.DP(Rect A, Point B, InteractionState C)
   at MindFusion.Diagramming.Wpf.DiagramNode.YO(Rect A, Rect B, Point C, AdjustmentHandles D, InteractionState E)
   at MindFusion.Diagramming.Wpf.DiagramNode.AllowModify(Point current, InteractionState ist)
   at MindFusion.Diagramming.Wpf.InteractionState.ValidateAndSetCursor(Point point, Diagram diagram)
   at MindFusion.Diagramming.Wpf.Behaviors.BehaviorBase.OnMouseMove(Point mousePosition)
   at MindFusion.Diagramming.Wpf.Diagram.OnPreviewMouseMove(MouseEventArgs e)
   at System.Windows.UIElement.OnPreviewMouseMoveThunk(Object sender, MouseEventArgs e)
   at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)    at MindFusion.Diagramming.Wpf.DiagramNode.DP(Rect A, Point B, InteractionState C)
   at MindFusion.Diagramming.Wpf.DiagramNode.YO(Rect A, Rect B, Point C, AdjustmentHandles D, InteractionState E)
   at MindFusion.Diagramming.Wpf.DiagramNode.AllowModify(Point current, InteractionState ist)
   at MindFusion.Diagramming.Wpf.InteractionState.ValidateAndSetCursor(Point point, Diagram diagram)
   at MindFusion.Diagramming.Wpf.Behaviors.BehaviorBase.OnMouseMove(Point mousePosition)
   at MindFusion.Diagramming.Wpf.Diagram.OnPreviewMouseMove(MouseEventArgs e)
   at System.Windows.UIElement.OnPreviewMouseMoveThunk(Object sender, MouseEventArgs e)
   at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

... any ideas how to settle the interaction down after a changed no of nodes in diagram?

thx

(PS noone else posts here anymore?)
  
Back to top
 
IP Logged
 
ulthien
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 91
Location: Munich
Joined: Nov 29th, 2011
Re: Dragging a ShapeNode from Diagram to Diagram..
Reply #3 - Mar 4th, 2014 at 5:31pm
Print Post  
or i am missing the wpf equivalent ot the lines in your example:

           cancelInternalDrag = true;
           DoDragDrop("test", DragDropEffects.Copy);

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

?

cheers
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Dragging a ShapeNode from Diagram to Diagram..
Reply #4 - Mar 5th, 2014 at 9:42am
Print Post  
Yes, you must call e.CancelDrag(); It seems WPF keeps sending mouse events while DoDragDrop works unlike Windows Forms, and that makes the NodeModifying handler reentrant, so you must also guard against that. E.g. one way to implement it is blocking the mouse events from window's PrevewMouseDown override:

Code
Select All
bool dragDrop = false;

private void OnNodeModifying(object sender, NodeValidationEventArgs e)
{
	var testRect = diagram.Viewport;
	testRect.Inflate(-50, -50);
	if (!testRect.Contains(e.Node.Bounds))
	{
		dragDrop = true;
		DragDrop.DoDragDrop(this, "test", DragDropEffects.Copy);
		dragDrop = false;
		e.CancelDrag();
	}
}

protected override void OnPreviewMouseMove(MouseEventArgs e)
{
	base.OnPreviewMouseMove(e);
	e.Handled = dragDrop;
} 



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