Pulling a chain

All new links in my diagram are dashed and usually when I draw a link from an output port, one end of the link is firmly attached to the port.
Accidentally I turned ON possibility of drawing links backwards (from input to output) and noticed an interesting result - a new link was attached to the cursor and drawing a new link looked like pulling a chain from the input port. I liked it very much!
Is there any way I can apply this behavior to all ports?

P.S. If anyone wants to know how to disable drawing a link from input to output, here’s the code:
(diagram.FindMouseTool(typeof(GoToolLinkingNew), true) as GoToolLinkingNew).ForwardsOnly = true;

Although this isn’t precisely what you are asking about, you might be interested in how the Processor sample animates dashed links to give the impression of the flow of stuff from one node to another. Run the Processor sample app, drag some nodes into the canvas, draw some links between the nodes, and then click the “Animate” button.

Basically what you want is having the temporary link (actually GoStroke) created by the link-drawing tool to paint its stroke backwards.
So here's a link class that paints itself backwards:
[Serializable]
public class TestTempLink : GoLink {
public TestTempLink() {
Pen p = new Pen(Color.Blue, 2);
p.DashStyle = DashStyle.Dash;
this.Pen = p;
}
// !!! doesn't handle lots of stuff, including arrowheads, shadow, jumpovers
public override void Paint(Graphics g, GoView view) {
Pen pen = this.Pen;
if (pen == null) return;
int npoints = this.PointsCount;
GraphicsPath path = MakePath();
path.Reverse();
DrawPath(g, view, pen, null, path);
}
}
And here's how you get your view's new-linking tool to use this class:
[Serializable]
public class TestLinkingNewTool : GoToolLinkingNew {
public TestLinkingNewTool(GoView view) : base(view) {}
protected override IGoLink CreateTemporaryLink(IGoPort fromPort, IGoPort toPort) {
IGoLink result = new TestTempLink();
result.FromPort = fromPort;
result.ToPort = toPort;
this.View.Layers.Default.Add(result.GoObject);
return result;
}
}
Install this tool by replacing the standard one:
goView1.ReplaceMouseTool(typeof(GoToolLinkingNew), new TestLinkingNewTool(goView1));

Thanks Walter, the code does exactly what I wanted.
What about adding a “Draw backwards” property in future releases? Smile

I suppose we should consider it.
But I think you're the first person to ask for that feature in the 5+ years that GoDiagram has been on the market.