Links GoIconicNodes

I am using GoIconicNodes in my application and I am very happy with the functionality it provides but I am getting some complaints from users concerning how links connect with GoIconicNodes. As far as I know, GoIconicNodes have only one port in the middle of the object. This means that links will visually connect with the node at any point of the icon, the middle/left, right corner, bottom right etc.
It just so happens that my users want to only be able to connect links to certain parts of the node and they don’t want to visually see a port on the side of the node (like in the ProtoApp application).
So my question is, is it possible to make a GoIconicNode do this? I don’t really want to change the node type this late in the game if I can avoid it.
Thanks!
Joy

Sure, that should be easy to do. You didn’t say what parts of the node they do want links to be connected to. You can control that by overriding various GoPort methods, such as GetFromLinkPoint, GetFromLinkDir, GetToLinkPoint, and GetToLinkDir. There are examples of this in the samples directories.
For the most common case(s) you might not even have to do any overrides–setting the FromSpot and ToSpot, and perhaps changing the PortObject to be the Icon instead of the whole node, may be sufficient for your needs.

Ok, I ended up using the Demo1 example to help me figure this out. Now I am basically doing an imitation of the MultiPortNode by assigning 4 ports per GoIconicNode. It’s working great but I’m having trouble programmatically creating links now.
In the past, I would simply set the FromPort and ToPort for the link and that was the end of it. But now I somehow need to figure out which port on the fromnode and the tonode are closest to each other. Do you have any ideas on how I can do this?
Thanks!
Joy

If you are putting the four ports in the middle of each side/top/bottom of the icon, it might be easier to use a GoBoxPort instead, since that automatically make sure each link connects at one of those four points.
But it does also specify a link direction to make sure there is an end segment in the link that is perpendicular to the side/top/bottom where the link connects with the port or PortObject.

Is there an example of how to use a GoBoxPort with a GoIconicNode?

Ok, I have been messing around with the GoBoxPort and maybe I am using it wrong - but it just looks like a regular port but in the shape of a square. What I need are only 4 possible locations on the node to connect links: top/middle, bottom/middle, left/middle, right/middle. And there can be no port at the center of the node because users need to be able to double-click on the node to invoke an action. Does that make sense?? Now knowing all that, do you still think a GoBoxPort will work for me??

Try setting the GoPort.Style to GoPortStyle.None; that way people can’t see it.
Try setting the GoPort.PortObject to be either the GoIconicNode.Icon, or to be the whole node, depending on whether you want to have links go through the label to get to the icon.