/// <summary>
 /// Removes a Connection that contains the connector parameter
 /// </summary>
 /// <param name="connector">The connector parameter</param>
 internal void RemoveConnectionByConnector(Connector connector)
 {
     if (Connections.Count != 0)
     {
         Connection connectionToRemove = Connections.First(x => x.Connectors.Contains(connector));
         if (connectionToRemove != null)
         {
             RemoveConnection(connectionToRemove);
         }
     }
 }
        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);
            }
        }