private void Node_PortRemoved(object sender, Node.PortChangedEventArgs e) { if (e.Port.FlowDirection == Port.Direction.Input) { RemovePort(InputPorts.ElementAt(e.Index)); } else { RemovePort(OutputPorts.ElementAt(e.Index)); } Parent.Parent.Invalidate(); }
private void Node_PortAdded(object sender, Node.PortChangedEventArgs e) { if (e.Port.FlowDirection == Port.Direction.Input) { var connector = new InputGraphConnector((InputPort)e.Port, this); AddPort(connector); } if (e.Port.FlowDirection == Port.Direction.Output) { var connector = new OutputGraphConnector((OutputPort)e.Port, this); AddPort(connector); } // GraphConnector connector; // foreach (var con in MConnectors.OfType<GraphConnector>().Where(c => c.Type == ConnectorType.InputConnector)) { // for (int i = 0; i < Node.InputPorts.Count; i++) { // if (Node.InputPorts[i] == con.Port) { // con.Index = i; // } // } // } // foreach (var con in MConnectors.OfType<GraphConnector>().Where(c => c.Type == ConnectorType.OutputConnector)) { // for (int i = 0; i < Node.OutputPorts.Count; i++) { // if (Node.OutputPorts[i] == con.Port) { // con.Index = i; // } // } // } // var index = e.Index; // if (e.Port.FlowDirection == Port.Direction.Input) { // if (index == -1) index = MConnectors.Count(c => c.Type == ConnectorType.InputConnector); // connector = new GraphConnector(e.Port, this, index) { Tag = e.Port }; // } else { // if (index == -1) index = MConnectors.Count(c => c.Type == ConnectorType.OutputConnector); // connector = new GraphConnector(e.Port, this, index) { Tag = e.Port }; // } // MConnectors.Add(connector); // UpdateHeight(); // ParentView.ParentPanel.Invalidate(); }