How to remove artifacts after remove connection line?


Author
Message
Maxim Dobryakov
Maxim Dobryakov
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
Hello, All

I have implemented functionality to remove connection between two shapes in some cases (see EventSinkServiceOnConnected method in demo project). But it code cause creation of artifacts (see attached picture).

How to remove these artifacts after remove connection line?

For any case I have attached demo project to reproduce problem (rename file before extract from ZIP archive). Just try to connect two shapes to reproduce problem.

Thanks
Attachments
artifacts.png (113 views, 12.00 KB)
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

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


Maxim Dobryakov
Maxim Dobryakov
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
Hello,

Could you please explain hack with Timer? As I understand you use it for postpone removing.

How do you think is it possible to solve problem without timer? It will do my code more unclear.

Thanks
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search