Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Customization of link behaviour (Read 2248 times)
yangxh
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Mar 12th, 2012
Customization of link behaviour
Mar 12th, 2012 at 1:06pm
Print Post  
Hi,
I want to implement a special link behaviuor. The user click on one node's anchorpoint then scroll the view with mouse as usual and hit another node's anchorpoint to finish the connection action. Is it possible? And how?
Thank you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Customization of link behaviour
Reply #1 - Mar 12th, 2012 at 6:03pm
Print Post  
Hi,

Try this:

Code
Select All
private DiagramLink currentLink = null;

private void diagram_NodeClicked(object sender, NodeEventArgs e)
{
	if (currentLink == null)
	{
		currentLink = diagram.Factory.CreateDiagramLink(e.Node, e.MousePosition);
	}
	else
	{
		currentLink.Destination = e.Node;
		currentLink = null;
	}
}

private void diagramView_MouseMove(object sender, MouseEventArgs e)
{
	if (currentLink != null)
	{
		PointF mousePos = diagramView.ClientToDoc(e.Location);
		currentLink.ControlPoints[currentLink.ControlPoints.Count - 1] = mousePos;
		currentLink.UpdateFromPoints();
	}
} 



You can use the GetAnchorAt method from this post to find out if the mouse is exactly above an anchor point:
http://mindfusion.eu/Forum/YaBB.pl?board=wpfdg_disc;action=display;num=125049956...

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


I Love MindFusion!

Posts: 5
Joined: Mar 12th, 2012
Re: Customization of link behaviour
Reply #2 - Mar 13th, 2012 at 9:34am
Print Post  
It worked. Thank you very much! Grin
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint