Preventing placement of unconnected connectors
Thanks for using Syncfusion product.
We are glad to inform you that we have modified your code snippet to achieve your requirement. You were using Connector’s “ConnectionType” to identifying connection type is incoming/outgoing while connecting the nodes. We suggest you to use Node.CentralPort’s “ConnectionType” instead of Connector.ConnectionType while connecting the Nodes using connector tool to achieve your requirement. Please refer the below modified code snippet and sample for your references.
Here is the code snippet:
[C#]
public class MyLineConnectorTool : LineConnectorTool
{
public MyLineConnectorTool(DiagramController controller)
: base(controller)
{
HeadDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;
Name = "LineConnectorTool";
}
public override Tool ProcessMouseDown(MouseEventArgs evtArgs)
{
PointF mouseLocation = Controller.ConvertToModelCoordinates(evtArgs.Location);
var nd = Controller.GetNodeAtPoint(mouseLocation);
if (nd != null && (nd.CentralPort.ConnectionPointType == ConnectionPointType.Outgoing
|| nd.CentralPort.ConnectionPointType == ConnectionPointType.IncomingOutgoing))
{
return base.ProcessMouseDown(evtArgs);
}
else
return null;
}
public override Tool ProcessMouseUp(MouseEventArgs evtArgs)
{
PointF mouseLocation = Controller.ConvertToModelCoordinates(evtArgs.Location);
var nd = Controller.GetNodeAtPoint(mouseLocation);
if (nd != null && (nd.CentralPort.ConnectionPointType == ConnectionPointType.Incoming
|| nd.CentralPort.ConnectionPointType == ConnectionPointType.IncomingOutgoing))
{
return base.ProcessMouseUp(evtArgs);
}
else
{
this.Controller.Model.BeginUpdate();
this.InAction = false;
this.Controller.Model.EndUpdate();
return null;
}
}
}
Here is the Sample:
Sample
Please let us know if any concerns.
Regards,
Naganathan K G
Thanks for your update.
Please let us know if you need further assistance.
Regards,
Naganathan K G
- 3 Replies
- 2 Participants
-
AL Andrew Le Couteur Bisson
- May 11, 2015 02:41 PM UTC
- May 13, 2015 05:01 AM UTC