/// <summary> /// Deletes the connection by deleting all its Connectors, InterNodes /// and also removing the Logic References (Previous/Next) from the respective connection's LogicElements : Start and End /// </summary> /// <param name="connection"></param> internal void RemoveConnection(Connection connection) { if (connection != null) { connection.Connectors.ForEach(x => this.Connectors.Remove(x)); connection.InterNodes.ForEach(x => this.InterNodes.Remove(x)); if(connection.Start != null)(connection.Start as LogicElement).Next.Remove(connection.End as LogicElement); if(connection.End != null)(connection.End as LogicElement).Previous.Remove(connection.Start as LogicElement); if (Connections.Contains(connection)) Connections.Remove(connection); } }
public void CreateNewConnection() { // Create a new interNode that will be previewed as the SelectedObject var newInterNode = new InterNode() { Name = "InterNode" + (InterNodes.Count + 1), IsNew = true }; InterNodes.Add(newInterNode); SelectedObject = newInterNode; // Create a connector that will be referenced as interConnector and connect the PreviousObject with the new Internode var connector = new Connector() { Name = "Connector" + (Connectors.Count + 1), IsNew = true, }; Connectors.Add(connector); interConnector = connector; interConnector.Start = PreviousObject; // We only create a logic connection if it is starting from a Logic Element // Because if the PreviousObject is not a logic element, that means it is an interNode // and we're still building a connection. if (PreviousObject is LogicElement) { newConnection = new Connection(); Connections.Add(newConnection); newConnection.Start = PreviousObject as LogicElement; newConnection.Connectors.Add(connector); } }