Relinking

Hi Walter…
I have worked on successfully putting restrictions on the links, and now I have the case when somone tries to move the source link to another port my restrictions kick in only when moving a destination port…
The behaviour
Reconnect a destination port to another port (fine)
Reconnect a source port to another port (I want to fix)
In the example below I work out what can connect to what using the following method:
IsValidLink((Link)this.Link, (Node)this.OriginalStartPort.GoObject.TopLevelObject, (Node)gp.GoObject.TopLevelObject);
now this relinking method is causing me problems when i want to reconnect the source port
The nearest port on the link and the orginalstartport, in my method I look at both of these nodes and have meta information in them both to work out what can connect to what
OriginalStartPort.GoObject has my meta information in it, the problem is that, StartNode is a temporary link if only I could resolve this to the node its connected to it would allow me to finish the method
any ideas?
Please see the code below
public override IGoPort PickNearestPort(PointF dc)
{
IGoPort gp = base.PickNearestPort(dc);
// If the link doesn’t exist that means
// that we only have two nodes and the picknearest port function
// cannot snap to another port, because one doesn’t exist
// in the near facinity
if (gp != null)
{
bool destinationAllowed = false;
destinationAllowed = IsValidLink((Link)this.Link, (Node)this.OriginalStartPort.GoObject.TopLevelObject, (Node)gp.GoObject.TopLevelObject);
if (destinationAllowed != true)
{
this.View.Cursor = Cursors.No;
}
else
{
this.View.Cursor = Cursors.Hand;
}
}
else
{
return null ;
}

return base.PickNearestPort(dc);
}

I want to do this in GoLinking…
But im having an accessibility problem on the portobject
((Northwoods.Go.GoToolLinking.GoTemporaryPort)StartPort).PortObject.ParentNode

The expected customization is to override the GoToolRelinking.IsValidLink(IGoPort, IGoPort) method. This should get you the behavior you want whether relinking the “from” end or the “to” end of the link.
Your overriding PickNearestPort is the wrong time to be trying to filter out ports according to your own predicate, because the base method chooses nearby ports that satisfy IsValidLink.
So I would put the logic that you have in your predicate into the override of GoToolRelinking.IsValidLink.