public bool Connect(dynPortModel p) { //test if the port that you are connecting too is not the start port or the end port //of the current connector if (p.Equals(pStart) || p.Equals(pEnd)) { return(false); } //if the selected connector is also an output connector, return false //output ports can't be connected to eachother if (p.PortType == PortType.OUTPUT) { return(false); } //test if the port that you are connecting to is an input and //already has other connectors if (p.PortType == PortType.INPUT && p.Connectors.Count > 0) { p.Disconnect(p.Connectors[0]); } //turn the line solid pEnd = p; if (pEnd != null) { p.Connect(this); } return(true); }
private dynConnectorModel(dynNodeModel start, dynNodeModel end, int startIndex, int endIndex, int portType) { Stopwatch sw = new Stopwatch(); sw.Start(); pStart = start.OutPorts[startIndex]; dynPortModel endPort = null; if (portType == 0) { endPort = end.InPorts[endIndex]; } pStart.Connect(this); this.Connect(endPort); sw.Stop(); Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed)); }