public void OnConnectionDragCompleted(Point currentDragPoint,
                                              ConnectionViewModel newConnection,
                                              ConnectorViewModel sourceConnector)
        {
            this.currentDragPoint = currentDragPoint;
            if (connectingTo)
            {
                InputConnectorViewModel nearbyConnector = FindNearbyInputConnector(newConnection, currentDragPoint);

                if (nearbyConnector == null)
                {
                    RequestNodePickerWindow(newConnection);
                    // pick
                    return;
                }

                if (nearbyConnector == null || sourceConnector.Element == nearbyConnector.Element)
                {
                    Connections.Remove(newConnection);
                    return;
                }

                ConnectionViewModel existingConnection = nearbyConnector.Connection;
                if (existingConnection != null)
                {
                    Connections.Remove(existingConnection);
                }

                newConnection.To = nearbyConnector;
            }
            else
            {
                OutputConnectorViewModel nearbyConnector = FindNearbyOutputConnector(newConnection, currentDragPoint);

                foreach (ConnectionViewModel con in Connections.Where(c => c.To == newConnection.To && c.From != null).ToList())
                {
                    Connections.Remove(con);
                }

                if (nearbyConnector == null)
                {
                    RequestNodePickerWindow(newConnection);
                    // pick
                    return;
                }

                if (nearbyConnector == null || sourceConnector.Element == nearbyConnector.Element)
                {
                    Connections.Remove(newConnection);
                    return;
                }

                newConnection.From = nearbyConnector;
            }
        }
Пример #2
0
 public ConnectionViewModel(OutputConnectorViewModel from, InputConnectorViewModel to)
 {
     From = from;
     To   = to;
 }
Пример #3
0
 public ConnectionViewModel(OutputConnectorViewModel from)
 {
     From = from;
 }
        protected void AddOutputConnector(string name, IOType iotype, Color color)
        {
            var outputConnector = new OutputConnectorViewModel(this, iotype, name, color);

            OutputConnectors.Add(outputConnector);
        }