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