Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ArgumentOutOfRange in custom drawlinks behavior (Read 3525 times)
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
ArgumentOutOfRange in custom drawlinks behavior
Jun 3rd, 2013 at 9:16pm
Print Post  
If the DiagramView.Behavior is set to Custom..

..and you are using a custom DrawLinksBehavior class..

If you rapidly click on a diagram link, an ArgumentOutOfRange exception gets thrown from the OnMouseMove.

Once the exception is thrown it also stops drawing the link correctly.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ArgumentOutOfRange in custom drawlinks behavior
Reply #1 - Jun 4th, 2013 at 7:27am
Print Post  
Please post the exception stack trace and behavior class code.
  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ArgumentOutOfRange in custom drawlinks behavior
Reply #2 - Jun 4th, 2013 at 2:43pm
Print Post  
Here is an example class that replicates the problem:

Code
Select All
public class TestDrawLinksBehavior : DrawLinksBehavior
    {
        protected internal TestDrawLinksBehavior(DiagramView diagramView) : base(diagramView)
        {
        }

        public override InteractionState StartDraw(PointF point)
        {
            DiagramItem ac = Diagram.ActiveItem;

            int handle = 0;

            var hitTest = false;

            if (ac != null)
            {
                hitTest = ac.HitTestHandle(point, ref handle);
                if (!hitTest && handle == 0 && ac.ContainsPoint(point))
                {
                    //Force the move handle
                    handle = 8;
                    hitTest = true;
                }
            }

            // Any interactive item (move, handles, containers, etc.)
            if (ac != null && Diagram.IsItemInteractive(ac) && hitTest)
            {
                return new InteractionState(ac, handle, MindFusion.Diagramming.Action.Modify);
            }
            else // Selecting tools
            {
                return new InteractionState(Diagram.Selection, -1, MindFusion.Diagramming.Action.Create);
            }
        }
    } 

  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ArgumentOutOfRange in custom drawlinks behavior
Reply #3 - Jun 4th, 2013 at 2:44pm
Print Post  
Here is the stack trace:
Code
Select All
   at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
   at MindFusion.Diagramming.PointCollection.get_Item(Int32 index)
   at MindFusion.Diagramming.DiagramLink.UpdateModify(PointF current, InteractionState ist)
   at MindFusion.Diagramming.InteractionState.Update(PointF point, Diagram diagram)
   at MindFusion.Diagramming.WinForms.Behaviors.BehaviorBase.OnMouseMove(Point mousePosition)
   at MindFusion.Diagramming.WinForms.DiagramView.OnMouseMove(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseMove(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at AlteryxGuiToolkit.Main.StartApp(String[] args) in s:\Alteryx\AlteryxGuiToolkit\Main.cs:line 187
   at AlteryxGui.CMain.Main(String[] args) in s:\Alteryx\AlteryxGui\Main.cs:line 68
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart() 

  
Back to top
 
IP Logged
 
j poz
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ArgumentOutOfRange in custom drawlinks behavior
Reply #4 - Jun 4th, 2013 at 2:51pm
Print Post  
It seems like commenting out this line stops the exception from happening:
Code
Select All
return new InteractionState(ac, handle, MindFusion.Diagramming.Action.Modify); 



However, the exception doesn't get thrown from inside of InteractionState so you can't simply put a try/catch around this line..
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ArgumentOutOfRange in custom drawlinks behavior
Reply #5 - Jun 4th, 2013 at 4:06pm
Print Post  
The handle index you pass to InteractionState constructor is later directly used as index within the link's ControlPoints collection, so the handle = 8 assignment will cause an exception if the active item is link with fewer than 9 points. Try adding an additional check for ac type to the if statement around that assignment:

Code
Select All
if (ac is DiagramNode && !hitTest && handle == 0 && ac.ContainsPoint(point)) 



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


I Love MindFusion!

Posts: 78
Joined: Nov 21st, 2012
Re: ArgumentOutOfRange in custom drawlinks behavior
Reply #6 - Jun 4th, 2013 at 4:49pm
Print Post  
That worked. Thank you.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint