Conditional Port

I’ve got Ports at my GoObject and i want them the bo only starting a new link when clicking on them, if they meet several conditions. So when i hoover a port the hand is only show when the conditions are fulfilled and when i click the port a new link is only created when the conditions are fulfilled. how can i implement this and which methods need to be overloaded.

For most applications, you just need to set GoPort.IsValidFrom and .IsValidTo appropriately.

For more dynamic conditions, you can override GoPort.CanLinkFrom() and CanLinkTo().

overriding CanLinkFrom() is usefull but doesn’t fulfill my requirements. What I want is the possibillity to supress the generation of a link when i click and hold on a port. CanLinkForm supresses the possibillity to dock the link from the selected port to any other port. but it doesn’t supress the creation of the link

Christian

Did you also either set IsValidTo to false or override CanLinkTo() in the corresponding manner? GoToolLinkingNew won’t start drawing a new link at a port if both predicates are false.

But if you just want to prevent users from drawing links "backward" (i.e. starting at the "to" port and ending at the "from" port), you can just set GoToolLinking.ForwardsOnly to true:
(goView1.FindMouseTool(typeof(GoToolLinkingNew)) as GoToolLinkingNew).ForwardsOnly = true;