Ejemplo n.º 1
0
        private void XOperatorWidgetThumb_Drop(object sender, DragEventArgs e)
        {
            var mousePosition     = e.GetPosition(this);
            var inputZonesForDrag = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(this);
            var zoneBelowMouse    = OperatorWidgetInputZoneManager.FindZoneBelowMouse(inputZonesForDrag, mousePosition);

            if (zoneBelowMouse != null)
            {
                CV.CompositionGraphView.ConnectionDragHelper.Stop(new Vector(0, 0), zoneBelowMouse);
            }
            e.Handled = true;
        }
Ejemplo n.º 2
0
        /**
         * This function is called by IConnectionTargets when
         * the end of a connection is dragged over them.
         *
         * To "snap" valid connections, we save the zone so the
         * GiveFeedbackHandler can use its position.
         */
        public void HandleDragOverEvent(DragEventArgs e, IConnectionLineTarget targetWidget)
        {
            e.Effects = DragDropEffects.None;
            e.Handled = true;

            var connectionStartOutput = e.Data.GetData(CONNECTION_LINE_OUTPUT_IDENTIFIER) as OperatorPart;

            if (connectionStartOutput == null)
            {
                return;  // Skip non-connection drop data
            }
            // We can't use Mouse.GetPosition() also see
            // http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.getposition(v=vs.110).aspx
            var mousePosition     = e.GetPosition(targetWidget as UIElement);
            var inputZonesForDrag = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(targetWidget);
            var zoneBelowMouse    = OperatorWidgetInputZoneManager.FindZoneBelowMouse(inputZonesForDrag, mousePosition);

            if (zoneBelowMouse != null)
            {
                zoneBelowMouse.IsBelowMouse = true;
                _snappedToValidInput        = zoneBelowMouse.Input.Type == connectionStartOutput.Type ||
                                              zoneBelowMouse.Input.Type == FunctionType.Generic;

                if (_snappedToValidInput)
                {
                    e.Effects             = DragDropEffects.Copy;
                    _snappedPointOnCanvas = targetWidget.PositionOnCanvas + new Vector(zoneBelowMouse.LeftPosition + 0.5 * zoneBelowMouse.Width, targetWidget.Height);
                }
            }

            if (mousePosition == _lastDragOverPosition)
            {
                return;
            }

            _lastDragOverPosition = mousePosition;
            targetWidget.UpdateInputZonesUIFromDescription(inputZonesForDrag);
        }