Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Node and Anchor point selection (Read 4494 times)
Naganathan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Jun 14th, 2010
Node and Anchor point selection
Aug 25th, 2010 at 12:02pm
Print Post  
Hi Stoyo,
You have any idea on how to implement the following functionality?

I want to move the node when the node is clicked and dragged instead of start creating link and link should be created only when i click on any of the anchor points.
Currently what happens is the node is moved only when clicked at center and dragged..if i click any place other than the node center,the diagram starts creating a link from the nearest anchor point..though i set AutoSnapLinks to "false" and AutoSnapDistance to 0 still it takes the nearest anchor point when dragged and creates a link instead of moving the node..

And this makes moving the node very difficult (specially when the node size is small)..

Appreciate your help..

Thanks,
Naganathan NS.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Node and Anchor point selection
Reply #1 - Aug 25th, 2010 at 1:52pm
Print Post  
Hi,

Assign an instance of this class to diagram.CustomBehavior:

Code
Select All
public class MyBehavior : DrawShapesBehavior
{
	public MyBehavior(Diagram diagram) : base(diagram) { }

	public override InteractionState StartDraw(Point point)
	{
		var node = Diagram.GetNodeAt(point, true);
		if (node != null)
		{
			if (GetAnchorAt(node, point) != null)
			{
				var link = CreateLink(node, point);
				Diagram.Links.Add(link);
				return new InteractionState(link, Action.Create, link.ControlPoints.Count - 1, point);
			}

			return new InteractionState(node, Action.Modify, 8, point);
		}

		return base.StartDraw(point);
	}

	static AnchorPoint GetAnchorAt(DiagramNode node, Point point)
	{
		foreach (AnchorPoint ap in node.AnchorPattern.Points)
		{
			Rect r = node.Bounds;
			Point p = new Point(
				r.Width * ap.X / 100 + r.X,
				r.Height * ap.Y / 100 + r.Y);

			if (p.Distance(point) < 10)
				return ap;
		}

		return null;
	}
} 



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


I love YaBB 1G - SP1!

Posts: 22
Joined: Jun 14th, 2010
Re: Node and Anchor point selection
Reply #2 - Aug 26th, 2010 at 12:35pm
Print Post  
Thanks Stoyo...it works as expected...

Thanks,
Naganathan NS.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint