Swap FromNode and Tonode of a GoLink


#1

Hi,
Is it possible that I can swap the “FromNode” and “ToNode” of a GoLink after this link being added to document? Basically I need to change the “Direction” of a link dynamically.
I have tried this code:
GraphNode tempNode = (GraphNode)l.FromNode;
l.FromNode = (GraphNode)l.ToNode;
l.ToNode = tempNode;
my GraphNode is derived from GoBasicNode, GraphLink l is derived from GoLabeledLink.
The compiler complains:
Property or indexer ‘Northwoods.Go.GoLabeledLink.FromNode’ cannot be assigned to – it is read only
Thanks,
Wendy


#2

The problem is that there might be many ports that the link could be connected to on a node. So it would be unclear how to connect the link to a node.
But you should be able to swap ports, if that is allowed/permitted/valid in your application.
IGoPort port1 = l.FromPort;
IGoPort port2 = l.ToPort;
l.FromPort = port2;
l.ToPort = port1;