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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

22934 Dec 29,2004 01:47 PM Dec 30,2004 08:58 AM Windows Forms 3
loading
Tags: Diagram
Eric Silver
Asked On December 29, 2004 01:47 PM

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?

Eric Silver
Replied On December 29, 2004 02:06 PM

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?

Administrator [Syncfusion]
Replied On December 30, 2004 08:41 AM

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

Administrator [Syncfusion]
Replied On December 30, 2004 08:58 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;