One link goings and comings

Hello everybody,

What i would like to do is when i draw a link from textbox1 to textbox2, theres a link that appeare from textbox2 to textbox1…sort of going and coming link…

text --------->text
box1<--------box2

so when your draw one link youve got another one automatically but on the same single port…
Thank you very much for your help if thats possible to do ;)

Using the StateCharter sample as a base for this. It already has a LinkCreated handler to set curviness.



private void goView1_LinkCreated(object sender, Northwoods.Go.GoSelectionEventArgs e) {

GoLabeledLink l = e.GoObject as GoLabeledLink;

if (l != null) {

l.Curviness = 20*this.Doc.NumLinksBetween(l.FromPort, l.ToPort);

l.CalculateRoute();

}



// NEW CODE BELOW THIS LINE



GoBasicNode fromNode = (GoBasicNode)l.FromNode;

GoBasicNode toNode = (GoBasicNode)l.ToNode;

bool backlink = false;

foreach (IGoNode x in toNode.Destinations) {

if (x == fromNode) {

backlink = true;

break;

}

}

if (!backlink) {

Transition lback = new Transition();

GoText lab1 = new GoText();

lab1.Selectable = false;

lab1.Text = “back label”;

lback.MidLabel = lab1;

lback.FromPort = toNode.Port;

lback.ToPort = fromNode.Port;

this.Doc.Add(lback);

}

}



now, you could change this to make sure the number of links one way equals the other. this just creates a back link for the first “to” link.

Hi Jake,
Thanks a lot thats very nice but my like is orthogonals transition and not curviness style…
But thats not a problem what i would like is that the two links are not superimpose…really dont know how to do that at all…
If you can help me would be great
thks a lot

With orthogonals, it’s probably easier (and more conventional) to just have a single link with an arrowhead on each end.



What node class are you using?

If you use a BoxNode class, the right this will happen…







This screenshot is from NodeLinkDemo (Demo1 in 3.0 and earlier)