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(); }
public GraphNode(Node node, Guid factoryId, string uniqueName, int pX, int pY, string guid = "") { Node = node; Title = GetName(); NodeOwnerDraw = node is NodeSystemLib2.Generic.INodeUi; Location = new Point(pX, pY); InstanceId = guid == "" ? Guid.NewGuid() : Guid.Parse(guid); FactoryId = factoryId; UniqueName = uniqueName; int InputCount = 0; int OutputCount = 0; foreach (var port in Node.InputPorts) { var connector = new InputGraphConnector(port, this); AddPort(connector); InputCount++; } foreach (var port in Node.OutputPorts) { var connector = new OutputGraphConnector(port, this); AddPort(connector); OutputCount++; } node.PortAdded += Node_PortAdded; node.PortRemoved += Node_PortRemoved; //UpdateHeight(); var descAttr = node.GetAttribute("Description"); if (descAttr != null) { descAttr.Changed += DescAttr_Changed; } if (NodeOwnerDraw) { (node as NodeSystemLib2.Generic.INodeUi).OnLoad(this); } }