Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Adjust link to a straight line (Read 2869 times)
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Adjust link to a straight line
Jun 25th, 2009 at 3:02pm
Print Post  
Hi Stoyan,

We try to change node postion to change the link to a straight line. But it's not easy to dot. What property of the Diagram should be set to make it easier?

By the way, how to paste a image.

Thanks a lot.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Adjust link to a straight line
Reply #1 - Jun 26th, 2009 at 5:45am
Print Post  
Hi,

You could just set link.Style = Polyline and SegmentCount = 1 if you need the link to be a straight line. Why are you changing the node position too?

Stoyan
  
Back to top
 
IP Logged
 
chris
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 57
Joined: Feb 1st, 2008
Re: Adjust link to a straight line
Reply #2 - Jun 26th, 2009 at 2:14pm
Print Post  
Hi Stoyan,

Because I have to use cascading link style, I can't do this way. I tried some propertes like AllignToGrid. But the cascading line is not easy to change from a "Z" lilke line to a straight line.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Adjust link to a straight line
Reply #3 - Jun 28th, 2009 at 11:25am
Print Post  
Hi Chris,

This should do it for the case where there is a single link connected to the node:

Code
Select All
private void OnLinkCreated(object sender, LinkEventArgs e)
{
	DiagramLink l = e.Link;
	DiagramNode o = l.Origin;
	DiagramNode d = l.Destination;

	if (d.IncomingLinks.Count == 1 &&
		Math.Abs(o.Bounds.Y - d.Bounds.Y) < 30)
	 {
		double vcenter = o.Bounds.Y + o.Bounds.Height / 2;
		Rect r = d.Bounds;
		r.Y = vcenter - r.Height / 2;
		d.Bounds = r;

		for (int i = 0; i < l.ControlPoints.Count - 1; ++i)
		{
			Point p = l.ControlPoints[i];
			p.Y = vcenter;
			l.ControlPoints[i] = p;
		}
		l.UpdateFromPoints();
	}
}
 



You might need to handle more complex situations, such as detecting if there is a chain of nodes connected horizontally, and aligning the whole chain.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Adjust link to a straight line
Reply #4 - Jun 28th, 2009 at 11:32am
Print Post  
Regarding the image you sent us with the last segment being vertical, you can handle this by moving the last and next-to-last control points to the left when you detect this in LinkCreated. In a few days we are releasing v2.2 with a new routing algorithm that should never set the segment like that anyway.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint