The reason to have separate ports is because you really want to have links logically and physically connected at different point on the node. The prototypical example of this is with the nodes in an arithmetic circuit – we have to distinguish the inputs to a “Subtract” node.
If you just want to have the links connect at the closest point or side, then you want what you have discovered: have a single port which is the whole node. This is actually the default behavior in GoXam.
Having a single port per node is simpler of course, because each link doesn’t need to know the port identification for each end. If you want to convert your app to just using a single port per node, remove all of the go:Node.PortId attached properties identifying the ports. Then you can remove all uses of the port identifier (a.k.a parameter).
What we are trying to achieve having four ports is as follows:
Yes, that’s possible. In a Diagram.SelectionMoved or .SelectionCopied event handler, for all of the links that are connected to moved nodes, you would have to modify each link data’s FromPort or ToPort properties.
thanks ,
Something like:
foreach (Part part in myDiagram.SelectedParts) {
Node node = part as Node;
if (node == null) continue;
foreach (FrameworkElement port in node.Ports) {
foreach (Link link in node.FindLinksIntoPort(Node.GetPortId(port))) {
var linkdata = link.Data as …; // your link data Type
linkdata.ToPort = …; // find desired port id
}
foreach (Link link in node.FindLinksOutOfPort(Node.GetPortId(port))) {
var linkdata = link.Data as …; // your link data Type
linkdata.FromPort = …; // find desired port id
}
}
}