Preventing highlighting of collapsed subgraph port

We are using GoToolLinkingNew-PickNearestPort()
to highlight valid connection ports. This is
working fine for all the scenarios except one.
If the node containing valid target port
is part of a collapsed subgraph, it is still
getting highlighed. Could you suggest on
how to prevent highlighting of ports of nodes
which are part of collapsed subgraph.

Demo1 highlights the “Snap to” port in red, and avoids collapsed ports.

Look for GraphViewLinkingNewTool in GraphView.


I used same code fragment and figured out that even if subgraph
is collapsed,
IGoPort iport = base.PickNearestPort(dc);
is returning collapsed port instance unlike in demo. Am I doing something wrong in my code which is causing this incorrect

Which SubGraph class are you using? Have you modified Collpase() at all?

GoToolLinking.PickNearestPort depends on GoToolLinking.IsValidLink. Have you overridden that method?

GoToolLinking.IsValidLink depends on GoPort.IsValidLink. Have you overridden that method?

GoPort.IsValidLink depends on several properties and methods, including GoPort.CanLinkFrom and GoPort.CanLinkTo, which include checks for visibility. Have you overridden those methods?


You are absolutely right. I have overriden GoToolLinkingNew.IsValidLink which is causing this behaviour. If I comment out this overriden method, it is working fine. But In my application, I need to have this override in order to check validity of connection between given ports. Could you suggest on how to overcome this problem still keeping this validation logic.

Call the base function first, if it returns true, then run your logic that may conclude false.


Thank you very much for your suggestion. It is working fine