- Welcome, Guest. Please Login or Register
MindFusion  
  We have released initial version of MindFusion.Scheduling library for HTML5 & JavaScript.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
override DrawLinksBehavior to cohabitate with Pan
Read 414 times

Thomas Falcone   Offline
YaBB Newbies
*
Posts: 4
I Love MindFusion!


   
     
 
override DrawLinksBehavior to cohabitate with Pan
May 3rd, 2018 at 4: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# ?
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1529
Gender: male
tech.support


   
     
 
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #1 - May 3rd, 2018 at 5:58pm
 
Hi,

Panning while drawing a link sounds like automatic scrolling -

Code:
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
 
 
 
IP Logged    
 
     

Thomas Falcone   Offline
YaBB Newbies
*
Posts: 4
I Love MindFusion!


   
     
 
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #2 - May 4th, 2018 at 8: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.
 
 
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1529
Gender: male
tech.support


   
     
 
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #3 - May 7th, 2018 at 12:24pm
 
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;
} 



Regards,
Slavcho
 
 
 
IP Logged    
 
     

Thomas Falcone   Offline
YaBB Newbies
*
Posts: 4
I Love MindFusion!


   
     
 
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #4 - May 9th, 2018 at 10:42am
 
Looks like a good way to implement the required behaviour. Thanks a lot, I'll keep updated if i make it work out.
 
 
 
IP Logged    
 
     

Thomas Falcone   Offline
YaBB Newbies
*
Posts: 4
I Love MindFusion!


   
     
 
Re: override DrawLinksBehavior to cohabitate with Pan
Reply #5 - May 31st, 2018 at 4: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 Smiley
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print