We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Why is an event triggered twice when I am creating a link between tow nodes?

The ConnectionsChangeComplete get called twice. Question here is why? I need to be able to capture the act that two nodes were connected with each other. Problem is the events get triggered twice? which one do I use? Also the deleting of a link does not trigger this event as I am asuming it should sine the connections are changing. The only place I have been able to to capture th event is in the ChildrenChangeComplete event. Is this the proper behavior? BTW creating a new link does not trigger the Model_ConnectionsChangeComplete event as it is mentionned in the KB. So it gets quite confusing as to which event to use to capture the following: 1. Adding a new custom symbol to the diagram? 2. Adding a new link between symbols on the diagram? 3. Removing a custom symbol from the diagram? 4. Removing a link between symbols on the diagram?

3 Replies

ES Eric Silver December 29, 2004 07:06 PM UTC

This is what I found out about the two calls when adding a new link first time the Connection.TargetPort.Container is a link and the second time around Connection.TargetPort.Container is a symbol. Is the first event trigger correspond on on going from one symbol to the link and the second event goes is reponsible for the event connecting the newly formed link to the second symbol?


AD Administrator Syncfusion Team December 30, 2004 01:41 PM UTC

Hi Eric, You will have to use the Diagram.ConnectionsChanging and Diagram.ConnectionsChangeComplete events only if you want to get hold of the Symbols that a new Link is connecting. If your intention is to just be notified whenever a new diagram node(Symbol, Shape, Link) is added or removed from the diagram, then the best way to go about this would be by handling the Diagram.ChildrenChanging and Diagram.ChildrenChangeComplete events. The event''s Diagram.NodeCollection.EventArgs event argument provides information about the type of operation(Diagram.CollectionEx.ChangeType.Insert, ChangeType.Remove) through the EventArgs.ChangeType and the node(s) involved in it through the EventArgs.Node/EventArgs.Nodes properties. Examining the Node for it''s Type data will let you determine the type of node that is being added or removed. The following code shows a sample handler, private void diagramComponent_ChildrenChangeComplete(object sender, Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs evtArgs) { if(evtArgs.ChangeType == Syncfusion.Windows.Forms.Diagram.CollectionEx.ChangeType.Insert) { if(evtArgs.Node is Syncfusion.Windows.Forms.Diagram.Symbol) Debug.WriteLine("A Symbol node was added."); else if(evtArgs.Node is Syncfusion.Windows.Forms.Diagram.Link) Debug.WriteLine("A Link node was added."); } else if(evtArgs.ChangeType == Syncfusion.Windows.Forms.Diagram.CollectionEx.ChangeType.Remove) Debug.WriteLine(String.Concat("A ", evtArgs.Node.Name, " type node was removed.")); } There is an Essential Diagram KB article that details this issue. Please refer to the following link - http://www.syncfusion.com/Support/article.aspx?id=10534. Regards, Prakash Syncfusion


AD Administrator Syncfusion Team December 30, 2004 01:58 PM UTC

Eric, You are right about this. When a Link is used to connect two symbols, two Connection objects are created and hence the ConnectionsChanging and ConnectionsChangeComplete events would be generated for each of those. The Connection order(and hence the Source and Target ports for the Connections) is however determined by how the LinkCmd initializes it''s Source and Target ports. When using the LinkTool to draw a Link from Symbol1 to Symbol2, the first ConnectionsChangeComplete event signals the Connection between the port contained in the Symbol(Symbol1 in this case) from which the Link originates(here the Symbol port would be the Connection''s SourcePort and the TargetPort would be the Link''s TailPort). In the subsequent generation of the event, the SourcePort would be the Link''s HeadPort while the Connection''s TargetPort will be the Symbol port(Symbol2 here). I understand that this issue is a little confusing and will add an Essential Diagram KB article detailing it. Regards, Prakash

Loader.
Live Chat Icon For mobile
Up arrow icon