Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic A special situation can not link (Read 1783 times)
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
A special situation can not link
Oct 25th, 2017 at 8:45am
Print Post  
When I created an arc, and assigned an anchorpoint, but this point is not on the arc. Is a floating anchor, at this time can not link. Only drag the diagramlink to the arc, will automatically docked to the specified anchor. I would like to directly drag the diagramlink to the anchor, directly to the connection. Is there any way to achieve it?
For example, the arc in the picture and the anchor of 'X'.
  

anchor_Point.png ( 14 KB | 79 Downloads )
anchor_Point.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: A special situation can not link
Reply #1 - Oct 25th, 2017 at 9:25am
Print Post  
Check if AutoSnapLinks and AutoSnapDistance properties will work for you. Otherwise we'd need to extend hit-testing methods of nodes to check for points outside of their Bounds, or if you are already using a custom class you might try overriding ContainsPoint method yourself.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
Re: A special situation can not link
Reply #2 - Oct 27th, 2017 at 6:00am
Print Post  
I have rewritten the ContainsPoint method, but in the small red rectangle, it is not triggering the ContainsPoint method when it moves very small.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: A special situation can not link
Reply #3 - Oct 30th, 2017 at 7:43pm
Print Post  
This works for me, for drawing links both to and from external anchor point -
Code
Select All
public class MyNode : ShapeNode
{
	public override bool ContainsPoint(Point diagramPoint)
	{
		if (AnchorPattern != null)
		{
			const double hitTestDist = 10;
			foreach (var point in AnchorPattern.Points)
			{
				var r = Bounds;
				var x = r.X + r.Width * point.X / 100;
				var y = r.Y + r.Height * point.Y / 100;
				if (Math.Abs(x - diagramPoint.X) < hitTestDist &&
					Math.Abs(y - diagramPoint.Y) < hitTestDist)
					return true;
			}
		}
		return base.ContainsPoint(diagramPoint);
	}
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint