Esempio n. 1
0
 /// <summary>
 /// Constructor used when only the start and end <see cref="PortModel"/> are known.
 /// </summary>
 /// <param name="start">The start <see cref="PortModel"/>.</param>
 /// <param name="end">The end <see cref="PortModel"/>.</param>
 /// <param name="guid">The unique identifier for the <see cref="ConnectorModel"/>.</param>
 public ConnectorModel(PortModel start, PortModel end, Guid guid)
 {
     Start = start;
     Start.Connect(this);
     Connect(end);
     GUID = guid;
 }
Esempio n. 2
0
        private void Connect(PortModel 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(Start) || p.Equals(End))
            {
                return;
            }

            //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;
            }

            //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
            End = p;

            if (End != null)
            {
                p.Connect(this);
            }

            return;
        }