How to get the connection relationship of all nodes, such as putting the connection relationship of all nodes in the data structure
list
array or link list ?
Hi Tealer,
Requirement: How to get list of connectors that are connected to a node
You can get the list of connectors which are being connected to a node by using InConnectors, OutConnectors, InOutConnectors properties of INodeInfo class.
Code snippet:
|
foreach (INode node in diagram.Nodes as IEnumerable<object>) { //List of IN and OUT connectors are connected to a node. IEnumerable<object> InOutConnectionsList = (node.Info as INodeInfo).InOutConnectors as IEnumerable<object>;
//list of IN connectors are connected to a node. IEnumerable<object> InConnectionsList = (node.Info as INodeInfo).InConnectors as IEnumerable<object>;
//list of OUT connectors are connected to a node. IEnumerable<object> OutConnectionsList = (node.Info as INodeInfo).OutConnectors as IEnumerable<object>; } |
Regards,
Deepa Thiruppathy
Thank you for reply.
I tested the code you gave, I found a problem;
If the connector in the picture below is connected to an endpoint on another connector, InOutConnectors, InConnectors, and OutConnectors have no way to correctly return this connection relationship.
Take the following picture as an example, the InOutConnectors of node 1 are the same as the InOutConnectors of node 2, and node 3 should also have the same InOutConnectors, but now the InOutConnectors of node 3 are now separate and have nothing to do with the InOutConnectors of node 1 and node 2 This will cause a lot of trouble for parsing the logical relationship of nodes.
Hi Tealer,
You have created a connector to Node3 from a connector using ConnectorPort which is connected between Node 1 and Node 2. You are not created a connector between Node1 and Node3. There is no any direct relationship between Node1 and Node3. To get proper connectors collection, connect Node 1 to Node3 and Node1 to Node2.
Thank you for your reply. Although the nodes do not have a connection relationship, but the connectors that are connected together have a connection relationship. How to obtain the connection relationship of the connectors?
Hi Tealer,
Requirement: Requirement: How to get list of connectors that are connected to a connector using ports.
You can get the list of connectors which are being connected to a connector by using InConnectors, OutConnectors, properties of IConnectorPortInfo class.
Code snippet:
|
foreach (IConnector connector in diagram.Connectors as IEnumerable<object>) { foreach (IConnectorPort connectorPort in connector.Ports as IEnumerable<object>) { //List of IN connectors are connected to a connector port. IEnumerable<object> InConnectionsList = (connectorPort.Info as IConnectorPortInfo).InConnectors as IEnumerable<object>;
//list of OUT connectors are connected to a connector port. IEnumerable<object> OutConnectionsList = (connectorPort.Info as IConnectorPortInfo).OutConnectors as IEnumerable<object>; } } |
It doesn't work on my project, InConnectionsList and OutConnectionsList are always NULL.
Hi Tealer,
Requirement: How to get list of connectors that are connected to a Connector and Node
We have created a simple sample to achieve your requirement. When elements are selected, we have displayed the in and out connections count in the text box. If still you are facing any issues, please revert us with sample or application that you are using.
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/InAndOutConnectorsCount-1995684202
Regards,
Deepa Thiruppathy
I modified my project according to the code you replied, but the problem still exists, I try to get the connector in the whole diagram, but the IEnumerable<object> of the connector I get is always null.
Here is my project:
https://drive.google.com/file/d/1OCMG-BMEjYZoQLoIgCzFDtxSvG-WNxbe/view?usp=sharing
Hi Tealer,
Reported issue: Connector’s collection in ViewModel returns null
We have validated the reported issue in your shared project. You have created the project in MVVM pattern. We can notice that you have not bind the Connectors property from View to ViewModel. We request you to update the proper binding to the Connectors collection. We have modified the project that you have shared.
Code snippet:
|
<local:Diagram x:Name="diagram" Nodes="{Binding Nodes}" Connectors="{Binding Connectors}" ItemAddedCommand="{Binding ItemAddedCommand}" Swimlanes="{Binding Swimlanes}" /> |
Modified project: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SyncfusionWpfTest1Modified2057474816
Thank you for your help,
This project is woking good now !
You are welcome. Please let us know if you require any further assistance.