Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic inaccessible anchor points (Read 4177 times)
tutimsade
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Mar 5th, 2013
inaccessible anchor points
Mar 6th, 2013 at 5:53pm
Print Post  
Hi,
I have a data flow diagram (of type Diagram) which is built by the user by dragging and dropping custom nodes (adapted by DiagramNodeAdapter) into it. The user can also draw links between those nodes.
These custom nodes are usually of the same size, but in some cases, if the user adds more "output ports" (of type AnchorPoint) in order to add more outgoing links, these ports become inaccessible for drawing links from them, as they exceed the range of the node.
I tried various methods of DiagramNodeAdapter to increase its range in this case, such as SetBounds or Resize. But they had no effect.
I also tried to dynamically update the Height property of the custom node. That made the ports accessible (at least visually – a hand cursor appeared when hovering), but messed all the other ports arrangement, making them appear detached.
I attached 2 screenshots. In the first one the desired look but the exceeding ports are not accessible. In the second one the ports are seemingly accessible (couldn't include cursor in the screenshot, but it appears), but anchor points are messed.
Any ideas how I should use SetBounds, or any other method to solve this issue?
(using MindFusion.Diagramming.Wpf version 2.4.0.21968)
Thanks.
  

Capture1_001.PNG (Attachment deleted)
Capture2_002.PNG (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: inaccessible anchor points
Reply #1 - Mar 7th, 2013 at 7:17am
Print Post  
Hi,

The diagram lets you draw new links starting only from within node's Bounds by default. You can use a custom behavior to let users draw links even from outside a node. Check this post for a sample custom behavior class:
http://mindfusion.eu/Forum/YaBB.pl?num=1210257325/1#1

From StartDraw, call the diagram.GetNodeAt(point, threshold) overloaded method to find a nearby node even if it's at some distance from the mouse pointer.

If not using a custom behavior, you will have to make your nodes larger so that anchor points are entirely within their Bounds. That would also require modifying the hosted controls so they are drawn with some transparency around the frames and centered relatively to their node's rectangle.

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


I Love MindFusion!

Posts: 3
Joined: Mar 5th, 2013
Re: inaccessible anchor points
Reply #2 - Mar 10th, 2013 at 2:42pm
Print Post  
thanks, I tried implemeting your suggestion for custom behavior. I did something like this:

public override InteractionState StartDraw(Point point)
        {
            int attempts = 0;
            do
            {
                DiagramNode node = Diagram.GetNodeAt(point, 13 * attempts);
                if (node != null)
                {                   
                    if (node.AnchorPattern != null )
                    {
                        try
                        {
                            return base.StartDraw(point);
                        }
                        catch (Exception)
                        {
                     // failed to draw
                            attempts++;
                        }                                              
                    }
                }
                else // didn't find the node in range
                {
                    attempts++;
                }
            } while (attempts<20); // assumes no more than 21 possible ports          
            return base.StartDraw(point);
        }

But again it fails to draw a link from the "exceeding" anchor points - I get an error:
"System.NullReferenceException: Object reference not set to an instance of an object.
   at MindFusion.Diagramming.Wpf.InteractionState.Start(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.MouseDevice.Synchronize()
   at System.Windows.Input.MouseDevice.ChangeMouseCapture(IInputElement mouseCapture, IMouseInputProvider providerCapture, CaptureMode captureMode, Int32 timestamp)
   at System.Windows.Input.MouseDevice.PreNotifyInput(Object sender, NotifyInputEventArgs e)
   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)"

(For the rest of the anchor points, those "in range", it works ok as before).
What else am I missing?
Thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: inaccessible anchor points
Reply #3 - Mar 11th, 2013 at 7:51am
Print Post  
Your code always returns base.StartDraw, so it does not override anything. You will have to return something like this when you find a node nearby:

Code
Select All
DiagramLink link = CreateLink();
link.Origin = node;
return new InteractionState(link, -1, Action.Create); 



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


I Love MindFusion!

Posts: 3
Joined: Mar 5th, 2013
Re: inaccessible anchor points
Reply #4 - Mar 11th, 2013 at 5:03pm
Print Post  
Thanks, works.
The only thing missing now is displaying a hand cursor.
I can do it by implementing the port's (UserControl) MouseEnter handler. But is there a way setting it by one of your methods?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: inaccessible anchor points
Reply #5 - Mar 11th, 2013 at 8:07pm
Print Post  
In your custom behavior class, override the SetMouseCursor method and return CursorHint.AllowLink when StartDraw would start drawing a link.

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