One of the Nevron Support team gave me some code about using my Line connector to connect two shapes (one explicitly set as PortType.Inward, shape.Name="PPMDOut")
and other shape with default Type (shape.Name = "PPMDIn").
A Connecting event handler was created.
nDrawingDocument1.EventSinkService.Connecting += new ConnectionCancelEventHandler(EventSinkService_Connecting);
///
/// This event occurs when 2 shapes arre connecting on the drawing veiw. Here is the place where you
/// can cancel the connection if you want.
/// ///
private void EventSinkService_Connecting(NConnectionCancelEventArgs args)
{
NPlug plug = (NPlug)args.Document.GetDescendantFromUniqueId(args.UniqueId1, -1);
NPort port = (NPort)args.Document.GetDescendantFromUniqueId(args.UniqueId2, -1);
if (plug is NStartPlug)
{
// This is a start plug
if (port.Shape.Name == "PPMDOut")
{
// Start plug connection not allowed for Digital Output shapes - show a wanring
// message and cancel the connection
MessageBox.Show("Connecting Start Plugs to a 'Digital Output' shape is not allowed!",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
args.Cancel = true;
}
}
else
{
// This is an end plug
if (port.Shape.Name == "PPMDIn")
{
// End plug connections not allowed for Digital Input shapes - show a warning
// message and cancel the connection
MessageBox.Show("Connecting End Plugs to a 'Digital Input' shape is not allowed!",
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
args.Cancel = true;
}
}
}