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

Ports

We are currently evaluating your product. One of the things we need to do is traverse all of the links in the diagram. I understand how to do that using IGraphNode and IGraphEdge. In addition to determining the ToNode and FromNode, we also need to know what port the link is connected to on the symbol. I found that one of the link ports is a port on a symbol but the other port is a port anchored to the link. I need the port anchored on the other symbol. How do I get this? We still want the user to be able to add links to the diagram using the normal graphical interface. Ideally, we would like to see the SourcePort set to ToNode.MyPort and the TargetPort set to FromNode.MyPort. Thanks in advance for your help.

4 Replies

AD Administrator Syncfusion Team October 20, 2005 05:14 AM UTC

Hi Chris, Links and symbols connect to each other through a Syncfusion.Windows.Forms.Diagram.Connection object. The Connection instance will have a reference to the ports on the two objects (the link and the symbol) that it is connecting. Assuming that you have the Port(on the Symbol or the Link) that makes up one part of the connection, the foreign or connecting port can be retrieved through this Connection class. The following KB articles should give you an idea how to go about using Connections to access the Symbols and Ports on either side of a link: http://www.syncfusion.com/Support/article.aspx?id=10556, http://www.syncfusion.com/support/kb/diagram/Default.aspx This link goes over the basics of how symbols, links, ports and connections all fit together - http://www.syncfusion.com/support/kb/diagram/Default.aspx. I hope this helps. Please let us know if we can assist you in any other way. Regards, Prakash Surendra Syncfusion Inc.,


CC Chris C October 20, 2005 06:52 PM UTC

Hi Prakash, Thanks so much for the information. However, it still doesn''t quite solve my problem. For example, suppose I have two symbols, A and B and each one has a port, A.Port1 and B.Port1. I insert a link between the symbols using those ports. We would like to write some XML data to a separate file when we save the diagram. For each link we need the foreign ports on either side of a connection. If I loop through the connections for symbol A, I can get A.Port1 but how do I get B.Port1. I understand the example you pointed me at regarding the ConnectionsChangeComplete event but that actually happens in two parts. There is an event for one side of the connection and a separate event for the other side. We want to start with either a symbol or the link itself and determine both symbols ports in one step. Can this be done? I thought about having a custom link class and saving the information when the ConnectionsChangeComplete event fires. It seems like there should be an easier way to do it. We are very pleased with the evaluation thus far and almost certain that we will be using SyncFusion for our application development. Thanks for your help. Chris


AD Administrator Syncfusion Team October 21, 2005 07:23 PM UTC

Hi Chris, I am glad that your evaluation of Essential Diagram is proceeding well. We will do our best to ensure that you remain satisfied with the Syncfusion experience. As for this issue, Symbols and Links have the SymbolBase.Connections property that you can use to iterate the list of connections that exist on the Symbol/Link. You could then use the Connection.GetForeignPort(IPortContainer) method to get hold of the connection''s foreign port. For instance, if you are working with the Link''s connections, then calling Connection.GetForeignPort(IPortContainer), where a reference to the Link will be the IPortContainer, will return the Port on the Symbol that the Link is connecting to. Once you have the Port, you can access the host Symbol by calling the Port.Container property. A similar approach can be used for retrieving the Link from the Symbol as well. The following code shows how to use a Link''s Connections collection to get hold of the Symbols on the tail and head ends of the Link, Link mylink; /*Reference to the link*/ ConnectionCollection connections = mylink.Connections; Symbol tailsymbol = null; Symbol headsymbol = null; foreach(Connection conn in mylink.Connections) { Port foreignport = conn.GetForeignPort(mylink); if((tailsymbol == null) && ((mylink.TailPort == conn.SourcePort) || (mylink.TailPort == conn.TargetPort))) { if(foreignport != null) tailsymbol = foreignport.Container as Symbol; } if((headsymbol == null) && ((mylink.HeadPort == conn.SourcePort) || (mylink.HeadPort == conn.TargetPort))) { if(foreignport != null) headsymbol = foreignport.Container as Symbol; } } Thanks, Prakash Surendra Syncfusion Inc.,


CC Chris C October 24, 2005 02:12 PM UTC

Hi Prakash, Thanks so much for your help. That is exactly what I needed. We are definitely using Syncfusion for our development. Chris

Loader.
Live Chat Icon For mobile
Up arrow icon