Identifying which port is changed on a GoLink

Hi,



I’m trying to identify when a link is connected to or reconnected from a nodes port. By that I refer to the case when the user drags and connect a link to a node or vice versa or when I programmatically connect a link to a nod.



In both cases there is only one port on the link actually being changed and I want to identify that port, the FromPort or the ToPort.



I have tried with code in the GoLink.OnPortChanged and GoPort.OnLinkChanged with similar result. In GoLink.OnPortChanged I always get a subhint for booth GoLink.ChangedFromPort and GoLink.ChangedToPort. In the port the GoPort.OnLinkChanged is called for booth ports (if the link is connected to two nodes). I have tried different solutions trying to take advantage of the information supplied in the two methods but so far I have not been able to identify the one port that is changed.



Can anyone point me in the right direction?

The DocumentChanged event will be called with a e.Hint of GoLayer.ChangedObject and e.SubHint of GoLink.ChangedFromPort or GoLink.ChangedToPort.



e.Object will be the Golink, e.OldValue will be the old port and e.NewValue will be the new port. note… you will see the port type switch to GoTemporaryPort while the end of the link is being dragged, then another event will be delivered showing the new port.

Jake, thank you for your quick response.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I looked at the DocumentChanged event but I must say I’m still confused. I must be overlooking something.

When I drag one end of a link from a node the DocumentChanged event is always called twice, first with the e.SubHint GoLink.ChangedFromPort and then with GoLink.ChangedToPort.

OnDocumentChanged [subHint: 1302]

OnDocumentChanged [object: Northwoods.Go.GoLink]

OnDocumentChanged [oldVal: Northwoods.Go.GoPort]

OnDocumentChanged [newVal: Northwoods.Go.GoToolLinking+GoTemporaryPort]

OnDocumentChanged [subHint: 1303]

OnDocumentChanged [object: Northwoods.Go.GoLink]

OnDocumentChanged [oldVal: Northwoods.Go.GoPort]

OnDocumentChanged [newVal: Northwoods.Go.GoToolLinking+GoTemporaryPort]

Without releasing the mouse I drag the link and connect it to another node and the DocumentChanged event is called twice again.

OnDocumentChanged [subHint: 1302]

OnDocumentChanged [object: Northwoods.Go.GoLink]

OnDocumentChanged [oldVal: Northwoods.Go.GoToolLinking+GoTemporaryPort]

OnDocumentChanged [newVal: Northwoods.Go.GoPort]

OnDocumentChanged [subHint: 1303]

OnDocumentChanged [object: Northwoods.Go.GoLink]

OnDocumentChanged [oldVal: Northwoods.Go.GoToolLinking+GoTemporaryPort]

OnDocumentChanged [newVal: Northwoods.Go.GoPort]

The problem is to decide which of the two ports on the link actually got a new value since the old value is the GoTemporaryPort in both cases, even for the port on the side of the link that was not reconnected. I’m sure there is a way to solve this but I don’t seem to find it. What am I missing?

In short what I need to know is when a FromPort or a ToPort on a GoLink changes from:
Null to a GoPort (GoPort not being a GoTemporaryPort)
GoPort to another GoPort (none of the GoPorts being GoTemporaryPort)
GoPort to null (GoPort not being a GoTemporaryPort)

Thanks