private void RemovePort(OutputPort port) { CodeGraph.Instance.InvalidateSaveButton(); var connectionsToRemove = new List <Edge>(); connectionsToRemove.AddRange(port.PortReference.connections); while (connectionsToRemove.Count > 0) { var conn = connectionsToRemove[0]; CodeGraph.Instance.GraphView.RemoveElement(conn); conn.input.Disconnect(conn); conn.output.Disconnect(conn); // conn = null; connectionsToRemove.RemoveAt(0); } outputContainer.Remove(port.PortReference); OutputPorts.Remove(port); EventPorts.Remove(port); OutputPortDictionary.Remove(port.PortReference); port.PortReference = null; PortCount--; FixPortNames(); Refresh(); }
public void CleanPorts() { CodeGraph.Instance.InvalidateSaveButton(); var portsToRemove = new List <OutputPort>(); (from port in EventPorts let portConnections = port.PortReference.connections.ToList() where portConnections.Count == 0 select port).ToList() .ForEach(port => { outputContainer.Remove(port.PortReference); portsToRemove.Add(port); PortCount--; }); portsToRemove.ForEach(p => { OutputPorts.Remove(p); EventPorts.Remove(p); OutputPortDictionary.Remove(p.PortReference); p.PortReference = null; }); FixPortNames(); Refresh(); }