Hello Syncfusion staff,
I am trying to validate the connections depending on the types and quantity of the connected nodes. I partially achieved that goal following this link https://www.syncfusion.com/forums/137361/sf-diagram-port-to-port-connection-restrictions, but that was not enough. I need to add extra constraints at the port level to complete that functionality, but I did not find a way of doing it. I would be grateful if you could indicate to me which port-related methods are used to do that. Additionally, I also would appreciate it if you could post an example of it.
Thank you,
Tomas
Hello Karkuvel,
In that example we can "stop" the connection if the condition is met (target.PortType == PortType.NonConnection), but we cannot assess the following cases:
1) Limit the number of connection allowed for a particular port.
2) "Block" a connection depending on the source, instead of the target only.
3) Disable connection between node "A" and "B", if it is already connected to the node "C".
Is it possible to expand the previous example to include those conditions too?
Thank you for your help,
Tomas.
|
Limit the number of connection allowed for a particular port. |
Added ‘MaxConnectionAllowed’ property and ‘CanConnect()’ method in CustomPort class to limit the number of Connection. | ||
|
"Block" a connection depending on the source, instead of the target only. |
Blocking connection in source side has two scenario: Case 1: While creating new connection (Changes added in SetTool method)
Case 2: Modifying existing connector’s source-end (Changes added in ValidateConnection method)
| ||
|
Disable connection between node "A" and "B", if it is already connected to the node "C". |
We have restricted the connection between two nodes, if there is common neighbor for both the nodes.
|
Hi Prakash, I will try to proposed solution first, to check if they satisfy the requirement.
Thank you,
Tomas
Hello Karkuvel,
The solution seems to work, though It is not able to cancel the "link", if the port is the source instead of the target. Also, I would like to change the decorator of the target and/or the source when the connection is successful and/or not. However, due to the design of my application, I do not have direct access to this.Resources["keyword"] where keyword may be "Ellipse". Is there a way to set the Connector's Target/SourceDecorator and Target/SourceDecoratorStyle without using this.Resource?, and is it possible to differentiate between hovering on a port and connecting to it?.
Thank you,
Tomas.
|
Query |
Response | |
|
The solution seems to work, though It is not able to cancel the "link", if the port is the source instead of the target. |
If you want to delete the connector instead of not connecting with the source you can use the Delete Command to delete the connector. Please find the code example below.
| |
|
I would like to change the decorator of the target and/or the source when the connection is successful and/or not.
|
We have analyzed your requirement of the need to change the Target or Source Decorator based on your conditions. For this, we have SourceDecorator and TargetDecorator properties in our Connector. Please follow the below documentation link to know more about Source and Target Decorators.
Documentation link: https://help.syncfusion.com/wpf/diagram/connector/appearanceandvalidation#decorator
| |
|
However, due to the design of my application, I do not have direct access to this.Resources["keyword"] where keyword may be "Ellipse". Is there a way to set the Connector's Target/SourceDecorator and Target/SourceDecoratorStyle without using this.Resource?
|
We have analyzed your requirement to change the Source and Target Decorator and Source and Target Decorator Style without using the this.Resources[“keyword]. We can achieve your requirement by writing the required style and shape in any resource dictionary file that will access all over the application or we have to write the necessary style and shape in C# code itself.
We have prepared a simple sample to achieve your requirement. In the sample, we have implemented both solutions. Please find the sample link below.
Sample link: https://www.syncfusion.com/downloads/support/forum/168378/ze/Resources_sample-1152897058
| |
|
is it possible to differentiate between hovering on a port and connecting to it?.
|
We need some clarification on your query. Did you need to highlight the connector or port while hovering and connecting? Please provide the required information that will help us to provide the proper solution to your requirement. |
Thank you Karkuvel. Though, I do not want to delete the connection, I just want to set the sourceNode/port as null if the right condition, on the source, is met. So, my problem is that using the canConnect() method for the source does not work when you are starting the connection in the port you are assessing.
Yes, I would like to highlight the connector while passing above the port. So, it shows, let's say, in green if is a valid connection, or red if it isn't..
Thank you,
Tomas
|
diagram.PortVisibility = PortVisibility.ValidConnection;
|
Hello Deepa,
My question references the example provided by Prakash, and the way it determines when the port is "full" (max. number of connection was reached). It works if you check the target port, but it seems to fail if the port is the source of the connection.
Also, the color of the connection should change briefly to show the status of the connection/port availability (rejected or available/done). The idea is to use that variation as a visual aid.
Thank you,
Tomas
|
Query |
Response |
|
My question references the example provided by Prakash, and the way it determines when the port is "full" (max. number of connection was reached). It works if you check the target port, but it seems to fail if the port is the source of the connection |
It is working fine in our side. If source port reaches maximum number of connection, then new connection could not be initialized from the source port. |
|
Also, the color of the connection should change briefly to show the status of the connection/port availability (rejected or available/done). The idea is to use that variation as a visual aid. |
We have highlighted the source port as red color while mouse hover on the source port, to indicate that new connection could be initialize from the source port anymore and that source port reached maximum number of out connectors.
If target port reaches maximum number of in-connectors, and we are trying to drop a connector on it, then connector will be turned into red color, to indicate that new connector could not be dropped on the port any more.
Also we have highlighted the source and target ports as yellow color, when ports have 2 (maximum number of connectors count) in-connectors or out-connectors to indicate that particular port is full. |
Hello Syncfusion Staff,
I tried the proposed solutions, but they did not solve the issue. I need to change the decorator of the connector when a connection is successful, but I do not have access to this.resource[] due to the design of my app. Is there a way of setting it dynamically without using this.resource?
Note: I read
https://help.syncfusion.com/wpf/diagram/connector/appearanceandvalidation#decorator and used
App.Current.MainWindow.Resources[" "]
but those method did not work in my project. App.axml,cs is not the "root" of my project, the WPF form is rendered within a Winform form.
Thank you,
Tomas.