Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic NullReferenceException (Read 3877 times)
JasonB
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Jun 5th, 2008
NullReferenceException
Jul 1st, 2008 at 6:23pm
Print Post  
   at MindFusion.Diagramming.Wpf.InteractionState.IsAllowed(Point point)
   at MindFusion.Diagramming.Wpf.Diagram.xc588ce77f0df4705(MouseButtonEventArgs xfbf34718e704c6bc)
   at MindFusion.Diagramming.Wpf.Diagram.OnPreviewMouseUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnPreviewMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.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(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, Int32 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, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.NativeWindow.WndProc(Message& m)
   at System.Windows.Forms.Integration.WindowsFormsHost.ActivateWindowListener.WndProc
(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at Crestron.Software.Shell.Library.SmartClientApplication`3.Start() in C:\Dev\Fusion\trunk\Shell\Source\Infrastructure\Library\SmartClientApplication.c
s:line 61
   at Microsoft.Practices.CompositeUI.CabApplication`1.Run() in C:\Dev\Fusion\trunk\Shell\Source\Core\CompositeUI\CabApplication.cs:line 81
   at Crestron.Software.Shell.Program.RunInDebugMode() in C:\Dev\Fusion\trunk\Shell\Source\Shell\Program.cs:line 32
   at Crestron.Software.Shell.Program.Main() in C:\Dev\Fusion\trunk\Shell\Source\Shell\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
  
Back to top
 
IP Logged
 
JasonB
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Jun 5th, 2008
Re: NullReferenceException
Reply #1 - Jul 1st, 2008 at 6:23pm
Print Post  
This may or may not be relevant:

This occurs during a drag and drop operation of two items on the diagram.

I have a custom behavior that in this situation returns null for the override of StartDraw.

After the drag occurs successfully, the next mouse click (mouse up) causes the exception.

I think this involves the drag code since it was immediately after I refactored a bit of it that the exception started occuring. I used to be canceling the interaction (diagram.Interaction.Cancel(diagram)) in PreviewMouseLeftButtonDown but moved this to PreviewMouseMove.

This is my drag code:

   private void block_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
       {
           behavior.StartPoint = e.GetPosition(null);
       }

       private void block_PreviewMouseMove(object sender, MouseEventArgs e)
       {
           if (e.LeftButton == MouseButtonState.Pressed && !behavior.IsDraggingBlockItem)
           {
               Point mousePosition = e.GetPosition(null);
               if ((Math.Abs(mousePosition.X - behavior.StartPoint.X) > SystemParameters.MinimumHorizontalDragDistance) || (Math.Abs(mousePosition.Y - behavior.StartPoint.Y) > SystemParameters.MinimumVerticalDragDistance))
               {
                  draggedBlockItem = ((Block)sender).SelectedItem;
                  StartDrag(draggedBlockItem);
               }
           }
       }

       private void StartDrag(BlockItem draggedBlockItem)
       {
           if (!object.ReferenceEquals(draggedBlockItem, null))
           {
               Block block = draggedBlockItem.BlockParent;
               if (!block.IsMouseOverAnchor())
               {
                   behavior.IsDraggingBlockItem = true;
                   if (!object.ReferenceEquals(diagram.Interaction, null))
                   {
                       diagram.Interaction.Cancel(diagram);
                   }

                   object dummyData = new object();
                   DragDrop.DoDragDrop(draggedBlockItem, dummyData, DragDropEffects.Link);
               }
           }
       }
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullReferenceException
Reply #2 - Jul 2nd, 2008 at 7:29am
Print Post  
To what kind of object have you attached the block_PreviewMouseLeftButtonDown and private void block_PreviewMouseMove handlers?

Stoyan
  
Back to top
 
IP Logged
 
JasonB
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Jun 5th, 2008
Re: NullReferenceException
Reply #3 - Jul 11th, 2008 at 9:20pm
Print Post  
To a class that eventually inherits from UserControl.

The events are raised by a "Block" object - this inherits from ContentControl.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NullReferenceException
Reply #4 - Jul 14th, 2008 at 12:10pm
Print Post  
We haven't had much luck reproducing this. Drag-and-drop is done by dragging an item from the Diagram to another control, right? Could you copy your Behavior.StartDraw code here, or send it to support@mindfusion.eu?

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
JasonB
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 24
Joined: Jun 5th, 2008
Re: NullReferenceException
Reply #5 - Jul 14th, 2008 at 2:36pm
Print Post  
No, this involves drag and drop from one diagram node to another. My custom behavior class is below. Not a big deal if you can't figure this one out, I just thought I'd report it - I'm just using the old drag and drop code which works fine.

public class DeviceDiagramBehavior : DrawLinksBehavior
    {
       private bool isDraggingBlockItem = false;

       public DeviceDiagramBehavior(DeviceDiagram diagram)
           : base(diagram)
       {
   
       }
      
       public override InteractionState StartDraw(Point point)
       {
           if (isDraggingBlockItem)
           {
               return null;
           }
           else
           {
               return base.StartDraw(point);
           }
       }

       public bool IsDraggingBlockItem
       {
           get { return isDraggingBlockItem; }
           set { isDraggingBlockItem = value; }
       }
    }
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint