Hi,
I have links with both the Orthogonal and AvoidsNodes set to true.
When trying to connect two blocks with an “obstacle” in between, the link “preview” shows the link crossing directly through the obstacle. However, letting go of the mouse button to actually create the link, the route is correct in avoiding the obstacle.
Is there a way to have the link route “preview” to match what will be created?
Thanks in advance
Well, my first thought was you just had to set the AvoidsNodes property in the NewLinkPrototype. But that doesn’t seem to work on the initial linking (although AvoidsNodes seems to work on a re-link).
Let me read some code… I’ll get back to you.
One possibility is to add the temporary link that the GoToolLinkingNew tool uses to the document rather than to the view:
[code] [Serializable]
public class RealTimeLinkingTool : GoToolLinkingNew {
public RealTimeLinkingTool(GoView view) : base(view) {}
protected override IGoLink CreateTemporaryLink(IGoPort fromPort, IGoPort toPort) {
IGoLink link = base.CreateTemporaryLink(fromPort, toPort);
link.GoObject.Remove();
this.View.Document.Add(link.GoObject);
return link;
}
public override void Stop() {
if (this.Link != null) this.Link.GoObject.Remove();
base.Stop();
}
}[/code]
But note that if you have code that is tracking GoDocument changes, it will be called during this new link drawing operation, even though the user might cancel out.