Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic override DrawLinksBehavior to cohabitate with Pan (Read 2787 times)
Thomas Falcone
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: May 3rd, 2018
override DrawLinksBehavior to cohabitate with Pan
May 3rd, 2018 at 3:38pm
Print Post  
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# ?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #1 - May 3rd, 2018 at 4:58pm
Print Post  
Hi,

Panning while drawing a link sounds like automatic scrolling -

Code
Select All
diagramView.Behavior = Behavior.DrawLinks;
diagramView.AutoScroll = true; 



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

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Thomas Falcone
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: May 3rd, 2018
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #2 - May 4th, 2018 at 7:44am
Print Post  
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.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #3 - May 7th, 2018 at 11:24am
Print Post  
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
Select All
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;
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Thomas Falcone
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: May 3rd, 2018
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #4 - May 9th, 2018 at 9:42am
Print Post  
Looks like a good way to implement the required behaviour. Thanks a lot, I'll keep updated if i make it work out.
  
Back to top
 
IP Logged
 
Thomas Falcone
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: May 3rd, 2018
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #5 - May 31st, 2018 at 3:41pm
Print Post  
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 Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint