Hi,
The best approach for your scenario is to subscribe to the NodeInserted event of the document’s event sink service, add the created connectors to a list and use a timer to delete those of them you do not need. The following is a simple source code:
public MainForm()
{
// Your initializing code here
InitializeComponent();
m_Connectors = new List<NRoutableConnector>();
...
// Subscribe to the NodeInserted event
ctlDrawingDocument.EventSinkService.NodeInserted += new ChildNodeEventHandler(EventSinkService_NodeInserted);
// Initialize the timer
m_Timer = new Timer();
m_Timer.Interval = 100;
m_Timer.Tick += new EventHandler(Timer_Tick);
}
private void EventSinkService_NodeInserted(NChildNodeEventArgs args)
{
NRoutableConnector connector = args.Child as NRoutableConnector;
if (connector != null)
{
m_Connectors.Add(connector);
if (m_Timer.Enabled == false)
{
// Start the processing timer if it is stopped
m_Timer.Start();
}
}
}
private void Timer_Tick(object sender, System.EventArgs e)
{
// Evaluate the connectors and remove one or more of them based on your logic
for (int i = 0, count = m_Connectors.Count; i < count; i++)
{
NRoutableConnector connector = (NRoutableConnector)m_Connectors[i];
ctlDrawingDocument.ActiveLayer.RemoveChild(connector);
}
// Clear the processed connectors and stop the timer
m_Connectors.Clear();
m_Timer.Stop();
}
Best Regards,
Nevron Support Team