If you have two nodes with multiple links between them the default “Force layout” shows two nodes with one line (link) between them. If I apply the Layered layout to the view it then shows all of the links between the nodes.
You can specify a different value of GoLink.Curviness for each link. For example, look at the StateCharter sample, or http://www.nwoods.com/forum/forum_posts.asp?TID=2966.
That seems to work but only after I have moved the node? When the page first comes up, it shows my two nodes and one line. IF I move one of the nodes, the links show up with the curved lines. Can I force the curved lines to show up on the load? is the objectmoved event doing something to the view to update?
The result of MakePath is too late in the process.
The main “line” of a link is implemented by a GoLink, which inherits from GoStroke. So the points of the link are accessible and modifiable with GoStroke methods. (Note that if you are using a GoLabeledLink, the link is available via the GoLabeledLink.RealLink property.)
But the computation of the stroke’s points is determined by GoLink.CalculateStroke. That’s what uses the Curviness property to decide what points to use as the route when the stroke has a Bezier style.
Regarding having to move a node to get the routing you want – I’m guessing that your initialization of the link is happening too late. In other words, after GoLink.CalculateStroke has been already been called. You might find that the easiest thing to do is to just call GoLink.CalculateRoute() on each link.
Thank you for the response. I have tried clearing the link pathpoints and using CalculateRoute() , which does give me a different path when using the Beizer style with the curviness property.
[code] [Serializable]
public class BentLink : GoLink {
public override void CalculateStroke() {
GoPort from = this.FromPort as GoPort;
GoPort to = this.ToPort as GoPort;
if (from != null && to != null && from.FromSpot == NoSpot && to.ToSpot == NoSpot
&& !this.Orthogonal && !this.IsSelfLoop) {
CalculateLineNoSpot(from, to);
} else {
base.CalculateStroke();
}
}
private void CalculateLineNoSpot(GoPort from, GoPort to) {
ClearPoints(); // clear this before calling Get[From/To]LinkPoint
PointF pA = from.GetFromLinkPoint(this.AbstractLink);
PointF pB = to.GetToLinkPoint(this.AbstractLink);
AddPoint(pA);
float rad = this.Curviness;
float off = Math.Abs(rad);
if (off > 0.5f) {
float Dx = pB.X-pA.X;
float Dy = pB.Y-pA.Y;
if (rad < 0) off = -off;
float Mx = pA.X + Dx/2;
float My = pA.Y + Dy/2;
float C1x = Mx;
float C1y = My;
if (Math.Abs(Dy) < 0.5f) {
if (Dx > 0)
C1y -= off;
else
C1y += off;
} else {
float slope = -Dx/Dy;
float E = (float)Math.Sqrt(off*off / (slope*slope + 1));
if (rad < 0) E = -E;
C1x = (Dy < 0 ? -1 : 1) * E + Mx;
C1y = slope*(C1x-Mx) + My;
}
AddPoint(new PointF(C1x, C1y));
}
AddPoint(pB);
}
}[/code]
Of course, you still need to set the GoLink.Curviness values appropriately for each link.
Note that you won’t need this code if GoLink.Orthogonal is true.