Beispiel #1
0
        private void GiveFeedbackHandler(object sender, GiveFeedbackEventArgs e)
        {
            var element = sender as IInputElement;

            if (element == null)
            {
                return;
            }

            var endPositionForConnection = e.Effects == DragDropEffects.Copy && _snappedToValidInput
                ? _snappedPointOnCanvas
                : Win32RawInput.MousePointInUiElement(_cgv.XOperatorCanvas);

            UpdateConnectionUI(endPositionForConnection);
            _snappedToValidInput = false;   // Sadly this can lead to jittering because the feedback-handler is called more frequently then the DragOver event
        }
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
        public void DoDragDropRewireConnection(ConnectionLine cl)
        {
            _dragStartPositionOnCanvas = Win32RawInput.MousePointInUiElement(_cgv.XOperatorCanvas);
            _snappedToValidInput       = false;

            var dragData = new DataObject(CONNECTION_LINE_OUTPUT_IDENTIFIER, cl.Output);

            // We have to restart the temp connection, because DoDragDrop triggers DragCompleted
            cl.HitTestDisabledDuringDrag = false;

            RewireExistingConnection(cl, _dragStartPositionOnCanvas, cl.Output.Func.EvaluationIndex);
            DragDrop.AddGiveFeedbackHandler(_cgv, GiveFeedbackHandler);
            DragDrop.DoDragDrop(_cgv, dragData, DragDropEffects.All);

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

            DragDrop.RemoveGiveFeedbackHandler(_cgv, GiveFeedbackHandler);
            Stop(new Vector(), null);
        }