Hi,
The NodeInserted event occurs when the connector is inserted in the document but before it is connected to any shape. For your scenario it is best to use a timer to check if the inserted connector is connected on both of its ends and remove it if it is not. The following is a simple example:
private NLineShape m_Connector;
private Timer m_ConnectionTimer;
private void InitializeDocument()
{
document.EventSinkService.NodeInserted += new ChildNodeEventHandler(OnEventSinkServiceNodeInserted);
m_ConnectionTimer = new Timer();
m_ConnectionTimer.Interval = 100;
m_ConnectionTimer.Tick += new EventHandler(OnConnectionTick);
}
private void OnEventSinkServiceNodeInserted(NChildNodeEventArgs args)
{
m_Connector = args.Child as NLineShape;
if (m_Connector != null)
{
m_ConnectionTimer.Start();
}
}
private void OnConnectionTick(object sender, EventArgs e)
{
NLayer layer = (NLayer)m_Connector.ParentNode;
if (m_Connector.FromShape == null || m_Connector.ToShape == null)
{
// The line shape is not connected on both ends so remove it
layer.RemoveChild(m_Connector);
}
m_ConnectionTimer.Stop();
}
Best Regards,
Nevron Support Team