ColoredNode and Links

How to limit links on ColoredNode object at Demo1 example?



I have to limit to 1 links per object.



Thank You

I assume you mean 1 link per port.
I suggest using your own GoPort class that is like the LimitedNodePort class in the LimitedNode example class of Demo1. Of course you can strip out all the code dealing with context menus and changing the color of the port depending on the number of links.

yes, i am sorry, i mean 1 link per port.



and what should i do if i want ColoredNode object add port automatically when link is created ?



Thank You

Best Regards

This might not be exactly like what you want, but I suggest you look at the AutoLinkNode example class. There’s a special port in the middle, an AutoLinkingPort, that overrides a couple of methods to automatically create a new port and link to that instead.
But maybe instead you want to allow the link to be completed normally, and then just create a new port, without linking to that new port. If so, then just do that, either in the same manner of overriding GoPort.Add[Source/Destination]Link, or perhaps more cleanly by implementing GoView.LinkCreated and .LinkRelinked event handlers.


How to add “one by one” port removal capabilty to AutoLinkNode ?



I have try to add remove port to AutoLinkNode, but its remove all port, instead one port.



Thank You

Best Regards

Sounds like you need to debug your code. Removing a port will also remove the links connected to it. But unless the link is connected to another port on the same node, that removal shouldn’t cause any other ports on the node to be affected at all.