Exemple #1
0
        void Input_MouseUpOverPin(NodePin targetPin)
        {
            _targetPin = targetPin;

            if (ValidateConnection(targetPin) != ValidationResult.Valid)
            {
                NodeEditor.Logger.Log <NodeEditorPinConnector>(GetErrorMessage(ValidateConnection(targetPin)));
                return;
            }

            NodeEditor.Logger.Log <NodeEditorPinConnector>("Connecting pin '{0}' in '{1}' to '{2}' in '{3}'",
                                                           _sourcePin.Name,
                                                           _sourcePin.Node.Name,
                                                           targetPin.Name,
                                                           targetPin.Node.Name);

            NodeConnection connection = null;
            NodePin        startPin   = null;
            NodePin        endPin     = null;

            if (IsModifyingConnection())
            {
                startPin = _modifyingConnection.SourcePin;
            }
            else
            {
                startPin = _sourcePin;
            }

            endPin = targetPin;

            connection = new NodeConnection(startPin, endPin);

            if (IsModifyingConnection())
            {
                _graph.Replace(_modifyingConnection, connection);
            }
            else
            {
                _graph.Connect(connection);
            }

            _view.EndDrawState();

            _modifyingConnection = null;
            _sourcePin           = null;
        }