I have some difficulties in making changes in the node in my implementation.
I drag and drop a node on the Godiagram and add ports to the node according to my data object and then assign this data object to the node.UserObject property. This fine works fine.
Next The user change the data obejct (e.g. add port, remove port, etc.) which trigger a event received by the node object. In the eventsink function, the node object will be updated according to the newly changed data object namely removeport and add port. this part works fine too.
However, an error occurs when I connect a link to the node because the newly created port are not found in the node. I am pretty sure that the port is added in the eventsink function in the node class.
I am wondering if it is because there are two copies of the node object, one in the View and another in the Document ( I do use Document.AddCopy function in the View.DoExternalDrop method.
Hope it is clea and appreciate any help!
What is the error message?
there is no error message from GoDiagram. The error is not findig the desired port, which should be added to the node. But appearntly the port is not added.
How are you trying to find a port?
Is the value of node.Ports.Count what you would expect?
I have a function FindPort in Node Class
GoPortObj FindPort(string name)
foreach(GoPortObj port in this.Ports)
if(port.Name==name) return port;
There is no Count property as Ports is GoPortsEnumerator object.
Ah, perhaps we added the Count property in version 2.5, and you are using an older version. No matter, you can still count them, or display the names of all of them.
Also, are you sure that the node that you are searching is the one you expect to have the port? If you have set GoDocument.MaintainsPartID to true, each node will have a unique PartID, so you can tell them apart, if they belong to the same GoDocument.