Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Links: One Source, more Destinations? (Read 1283 times)
KillaChris
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 18
Joined: Apr 25th, 2012
Links: One Source, more Destinations?
Aug 29th, 2012 at 6:59am
Print Post  
Hello i have a question.
At the moment I'm working on a overview.
In the middle there is one Node.
On the right side of this Node there are some other Nodes, all these other nodes point to the Node in the middle.
On the left side there are as well some other Nodes, the Node in the middle points to all these other Nodes.
At the moment I'm creating a link for each Node. But especially for the Nodes on the left side, it would be great if i can create a Link from the main Node, that goes left and then splits to all the other Nodes.
It would look much more better if this Link splits, because now i have about 20 Links. And all these Links go left, but not in the same way, some of them are on the top then there are some between the Nodes and so on.
So it would be great if i could create one Link and then set all its Destinations, so that the Link splits on its way.

Is there some possibility for that?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links: One Source, more Destinations?
Reply #1 - Aug 29th, 2012 at 10:02am
Print Post  
The DiagramLink class does not support multiple destinations. You could align first or last segments of links by running these methods for the middle node:

Code
Select All
private void AlignOutLinks(DiagramNode node)
{
	RectangleF r = node.Bounds;
	foreach (DiagramLink link in node.OutgoingLinks)
	{
		link.AutoRoute = false;
		link.SegmentCount = 2;
		if (link.Destination.GetCenter().X > r.Right)
		{
			PointF p1 = new PointF(r.Right, r.Y + r.Height / 2);
			PointF p2 = new PointF(p1.X + 10, p1.Y);
			link.ControlPoints[0] = p1;
			link.ControlPoints[1] = p2;
			link.UpdateFromPoints();
		}
		if (link.Destination.GetCenter().X < r.Left)
		{
			PointF p1 = new PointF(r.Left, r.Y + r.Height / 2);
			PointF p2 = new PointF(p1.X - 10, p1.Y);
			link.ControlPoints[0] = p1;
			link.ControlPoints[1] = p2;
			link.UpdateFromPoints();
		}
		// add cases for destination nodes above and below if necessary
	}
}

private void AlignInLinks(DiagramNode node)
{
	RectangleF r = node.Bounds;
	foreach (DiagramLink link in node.IncomingLinks)
	{
		link.AutoRoute = false;
		link.SegmentCount = 2;
		if (link.Origin.GetCenter().X > r.Right)
		{
			PointF p1 = new PointF(r.Right, r.Y + r.Height / 2);
			PointF p2 = new PointF(p1.X + 10, p1.Y);
			link.ControlPoints[2] = p1;
			link.ControlPoints[1] = p2;
			link.UpdateFromPoints();
		}
		if (link.Origin.GetCenter().X < r.Left)
		{
			PointF p1 = new PointF(r.Left, r.Y + r.Height / 2);
			PointF p2 = new PointF(p1.X - 10, p1.Y);
			link.ControlPoints[2] = p1;
			link.ControlPoints[1] = p2;
			link.UpdateFromPoints();
		}
		// add cases for origin nodes above and below if necessary
	}
} 



Alternatively, you could insert small (and possibly invisible) nodes at the split point as shown in the TernaryConnections sample project.

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