The MindFusion Forums
Flow Diagramming Components >> Windows Forms >> override DrawLinksBehavior to cohabitate with Pan
https://mindfusion.eu/Forum/YaBB.pl?num=1525361898

Message started by Thomas Falcone on May 3rd, 2018 at 3:38pm

Title: override DrawLinksBehavior to cohabitate with Pan
Post by Thomas Falcone on May 3rd, 2018 at 3:38pm
Hi, I'm currently searching a way to make the DrawLinksBehavior cohabitate with the PanBehaviour. (so the user can pan while creating a link without reseting the link being created nor the visual feedback).
I found another post of this issue but it was for android. Is there a fancy way to do it in c# ?

Title: Re: override DrawLinksBehavior to cohabitate with Pan
Post by Slavcho on May 3rd, 2018 at 4:58pm
Hi,

Panning while drawing a link sounds like automatic scrolling -

[code]
diagramView.Behavior = Behavior.DrawLinks;
diagramView.AutoScroll = true;[/code]

Or do you mean pressing additional mouse button to enable pan mode while also holding the left one for drawing?

Regards,
Slavcho
Mindfusion

Title: Re: override DrawLinksBehavior to cohabitate with Pan
Post by Thomas Falcone on May 4th, 2018 at 7:44am
Sorry if it wasnt clear, it's actually the second behaviour i'm trying to implement.

=> Or do you mean pressing additional mouse button to enable pan mode while also holding the left one for drawing?

But actually, the Drawlink interraction is cancelled by the pan.
So I would like to restart a new drawlink after a pan if a previous drawlink was active at the begining of the pan.

It looks like it is possible but I cant find a way to achieve it.

Title: Re: override DrawLinksBehavior to cohabitate with Pan
Post by Slavcho on May 7th, 2018 at 11:24am
The Behavior classes can track only a single mouse button (pressing a second button cancels the current interaction), so it's not possible to handle two buttons out of the box. You can still implement simultaneous panning by overriding mouse event handlers in a custom DiagramView class -

[code]
class MyDiagramView : DiagramView
{
     protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
     {
           base.OnMouseDown(e);

           if (e.Button == MouseButtons.Right)
           {
                 prevPanPoint = ClientToDoc(e.Location);
                 panning = true;
           }
     }

     protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
     {
           base.OnMouseMove(e);

           if (panning)
           {
                 var currentPoint = ClientToDoc(e.Location);
                 ScrollX += prevPanPoint.X - currentPoint.X;
                 ScrollY += prevPanPoint.Y - currentPoint.Y;
                 RecreateCacheImage();

                 prevPanPoint = ClientToDoc(e.Location);
           }
     }

     protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
     {
           if (e.Button == MouseButtons.Right)
                 panning = false;
           else
                 base.OnMouseUp(e);
     }

     PointF prevPanPoint;
     bool panning;
}[/code]

Regards,
Slavcho

Title: Re: override DrawLinksBehavior to cohabitate with Pan
Post by Thomas Falcone on May 9th, 2018 at 9:42am
Looks like a good way to implement the required behaviour. Thanks a lot, I'll keep updated if i make it work out.

Title: Re: override DrawLinksBehavior to cohabitate with Pan
Post by Thomas Falcone on May 31st, 2018 at 3:41pm
Tried it, it was slopy and didnt fit the requirements, but I found a way to implement it (bypassing interactions) and users were happy.

Thanks anyway :)

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.