Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic drop wire to delete it (Read 1714 times)
ChangMH
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Jul 5th, 2014
drop wire to delete it
Jul 5th, 2014 at 12:35pm
Print Post  
My requirement is to delete wire by moving its end away from node and dropping it. If I do that now the wire returns to where it was. Thanks for any advice.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: drop wire to delete it
Reply #1 - Jul 7th, 2014 at 5:31am
Print Post  
You could set AllowUnconnectedLinks = true to let users drag the link end to an empty location of the diagram, and then delete the link from LinkModified handler when it isn't connected to a node:

Code
Select All
private void OnLinkModified(object sender, LinkEventArgs e)
{
	if (!e.Link.IsConnected)
		diagram.Links.Remove(e.Link);
} 



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


I Love MindFusion!

Posts: 2
Joined: Jul 5th, 2014
Re: drop wire to delete it
Reply #2 - Jul 9th, 2014 at 6:41am
Print Post  
It works. Is it possible to remove e.Link only if its end is 20 pixels or more away from node, and it stays connected if it is close than 20 pixels?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: drop wire to delete it
Reply #3 - Jul 9th, 2014 at 1:48pm
Print Post  
Add a LinkModifying handler and set e.Cancel = true if you detect the mouse pointer is still close to the node:

Code
Select All
private void OnLinkModifying(object sender, LinkValidationEventArgs e)
{
	if (e.AdjustmentHandle == 0)
	{
		var dist = Utilities.Distance(
			e.MousePosition,
			e.Link.Origin.GetNearestBorderPoint(e.MousePosition));
		if (dist < 20)
			e.Cancel = true;
	}
	if (e.AdjustmentHandle == e.Link.ControlPoints.Count - 1)
	{
		var dist = Utilities.Distance(
			e.MousePosition,
			e.Link.Destination.GetNearestBorderPoint(e.MousePosition));
		if (dist < 20)
			e.Cancel = true;
	}
} 



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