コード例 #1
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;
        }
コード例 #2
0
ファイル: ConnectorModel.cs プロジェクト: sm6srw/Dynamo
 /// <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;
 }
コード例 #3
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)
 {
     Debug.WriteLine("Creating a connector between ports {0}(owner:{1}) and {2}(owner:{3}).", 
         start.GUID, start.Owner == null?"null":start.Owner.NickName, end.GUID, end.Owner == null?"null":end.Owner.NickName);
     Start = start;
     Start.Connectors.Add(this);
     Connect(end);
     GUID = guid;
 }
コード例 #4
0
 protected override void PortDisconnectedHandler(PortModel obj)
 {
     OnClear();
 }
コード例 #5
0
 protected override void PortConnectedHandler(PortModel arg1, ConnectorModel arg2)
 {
     UpdateUpstream();
 }
コード例 #6
0
 /// <summary>
 /// Map old Guids to new Models in the IdReferenceResolver.
 /// </summary>
 /// <param name="node">The newly created node.</param>
 /// <param name="inPorts">The deserialized input ports.</param>
 /// <param name="outPorts">The deserialized output ports.</param>
 /// <param name="resolver">The IdReferenceResolver used during deserialization.</param>
 private static void RemapPorts(NodeModel node, PortModel[] inPorts, PortModel[] outPorts, IdReferenceResolver resolver)
 {
     foreach (var p in node.InPorts)
     {
         resolver.AddToReferenceMap(inPorts[p.Index].GUID, p);
     }
     foreach (var p in node.OutPorts)
     {
         resolver.AddToReferenceMap(outPorts[p.Index].GUID, p);
     }
 }