In my code a user can make a new connection eigther by draw directly from the port or by drag/drop a connection from the pallette.
But how do I prevent the user from
Draw a connection from a port?
Connect a connection to a port?
In both cases I want to check for excisting connections in the code and in some cases cancel a new connection or prevent connect to a port
public void RemovePortConnect()
{
var node = Diagram.GetNode("node1");
// To disable the port draw functionality
node.Ports[0].Constraints = PortConstraints.Default;
}
public void AddPortConnect()
{
var node = Diagram.GetNode("node1");
// To enable the port draw functionality
node.Ports[0].Constraints = PortConstraints.Default | PortConstraints.Draw;
}
public void DisablePortConnect()
{
var node = Diagram.GetNode("node1");
// To disable the connector connection functionality from node
node.Constraints = NodeConstraints.Default & ~(NodeConstraints.InConnect | NodeConstraints.OutConnect);
// To disable the connector connection functionality from port
node.Ports[0].Constraints = PortConstraints.Default &~(PortConstraints.InConnect|PortConstraints.OutConnect);
}
public void EnablePortConnect()
{
var node = Diagram.GetNode("node1");
// To enable the connector connection functionality from node
node.Constraints = NodeConstraints.Default;
// To enable the connector connection functionality from port
node.Ports[0].Constraints = PortConstraints.Default ;
} |
Hi,
Sorry for my slow response time.
It seems like a lot of code for a simple feature.
Does the control not offer a simple property like "MaximumConnectionCount" that I can simply set to 1.
Then all this code could be reduced to a few lines?
public void RemovePortConnect()
{
var node = Diagram.GetNode("node1");
// To disable the port draw functionality
node.Ports[0].Constraints = PortConstraints.Default;
}
public void AddPortConnect()
{
var node = Diagram.GetNode("node1");
// To enable the port draw functionality
node.Ports[0].Constraints = PortConstraints.Default | PortConstraints.Draw;
}
public void DisablePortConnect()
{
var node = Diagram.GetNode("node1");
// To disable the connector connection functionality from node
node.Constraints = NodeConstraints.Default & ~(NodeConstraints.InConnect | NodeConstraints.OutConnect);
// To disable the connector connection functionality from port
node.Ports[0].Constraints = PortConstraints.Default &~(PortConstraints.InConnect|PortConstraints.OutConnect);
}
public void EnablePortConnect()
{
var node = Diagram.GetNode("node1");
// To enable the connector connection functionality from node
node.Constraints = NodeConstraints.Default;
// To enable the connector connection functionality from port
node.Ports[0].Constraints = PortConstraints.Default ;
} |
Thanks, I will try your example