Profile Picture

Checking a connection is valid

Posted By Jeremy Abercrombie 13 Years Ago
Author
Message
Jeremy Abercrombie
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 5, Visits: 1

Thanks that worked really well. I just had to add a refresh after I remove the invalid connector so the screen updates nicely.

 

Thanks again,

Jeremy.

 



Nevron Support
Posted 13 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

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



Jeremy Abercrombie
Posted 13 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: Forum Members
Last Active: 13 Years Ago
Posts: 5, Visits: 1

I am looking at incorporating the Nevron diagram tool to model a process in our software. I need to validate the diagram as the user creates it. When a line is inserted using the connection tool how can I check if it is connected at both ends and what it is connected to? I have used the EventSinkService to get notified that a shape has been added and I can cast it to an NLineShape but I don't know how to check what it is connected to.

I thought about the Connected and Connecting events but they only fire when something is actually connected and only tell you about each end of the connection independantly. Also, if a user just drags a connection on the diagram and doesn't connect it to anything you don't get these events.

 

Thanks for your help,

Jeremy.

 





Similar Topics


Reading This Topic