Beispiel #1
0
 // Creates an unfinished Connection that should be updated during DragDelta events and either removed or connected
 public ConnectionLine(Operator parentOp, IConnectionLineSource source, OperatorPart output)
 {
     ParentOp = parentOp;
     Source   = source;
     Output   = output;
     CreateLineGeometry();
     IsSelected              = false;
     ID                      = Guid.Empty;
     IsHitTestVisible        = false;
     _thumb.IsHitTestVisible = false;
     MouseLeftButtonDown    += ConnectionLine_MouseLeftButtonDownHandler;
 }
Beispiel #2
0
        public void DoDragDropNewConnection(IConnectionLineSource sourceWidget, OperatorPart output)
        {
            _dragStartPositionOnCanvas = Win32RawInput.MousePointInUiElement(_cgv.XOperatorCanvas);
            _snappedToValidInput       = false;

            var dragData = new DataObject(CONNECTION_LINE_OUTPUT_IDENTIFIER, output);

            // We have to restart the temp connection, because DoDragDrop triggers DragCompleted
            Start(_dragStartPositionOnCanvas, sourceWidget, output.Func.EvaluationIndex);
            DragDrop.AddGiveFeedbackHandler(_cgv, GiveFeedbackHandler);
            DragDrop.DoDragDrop(_cgv, dragData, DragDropEffects.All);

            // Importat! This line is not reached until drop is completed.

            DragDrop.RemoveGiveFeedbackHandler(_cgv, GiveFeedbackHandler);
            Stop(new Vector(), null);
        }
Beispiel #3
0
        /// <summary>
        /// Start drag a new connection. Called from InputWidget and OperatorWidget when staring to drag from output thumb
        /// </summary>
        public void Start(Point p, IConnectionLineSource src, int outputIdx)
        {
            _sourceOutputIndex = -1;
            if (outputIdx < 0 || outputIdx >= src.Outputs.Count)
            {
                return;
            }

            _sourceOutputIndex = outputIdx;
            _sourceWidget      = src;
            _startPosition     = p;

            // NOTE: In the long term, this should be capable of handling simultaneously creating multiple connection
            _lastPosition = _startPosition;

            var cl = new ConnectionLine(_sourceWidget.CV.CompositionGraphView.CompositionOperator, _sourceWidget, _sourceWidget.Outputs[outputIdx]);

            _sourceWidget.CV.CompositionGraphView.UnfinishedConnections.Add(cl);
            _sourceWidget.CV.CompositionGraphView.XOperatorCanvas.Children.Add(cl);

            cl.UpdateDuringConstruction(_lastPosition);
        }
Beispiel #4
0
        public ConnectionLine(Guid id, Operator parentOp, IConnectionLineSource source, IConnectionLineTarget target, OperatorPart output, OperatorPart input)
        {
            //IsHitTestVisible = false;
            ID       = id;
            ParentOp = parentOp;
            Source   = source;
            Target   = target;
            Output   = output;
            Input    = input;
            CreateLineGeometry();
            IsSelected = false;

            if (!Output.Parent.Visible || !Input.Parent.Visible)
            {
                Opacity          = 0;
                IsHitTestVisible = false;
            }
            ToolTip              = Output.ToString() + " -> " + Input.ToString() + "\n" + "(Drag with CTRL to disconnect)";
            MouseLeftButtonDown += ConnectionLine_MouseLeftButtonDownHandler;

            Loaded   += ConnectionLine_Loaded;
            Unloaded += OnUnloaded;
        }