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