Exemplo n.º 1
0
    protected void NotifyUp(InputCompletedArgs args)
    {
        EventArgs e = EventArgs.Empty;

        _dragLock = DragLock.Unset;
        _dragging = false;

        if (args.IsInertial)
        {
            double angle = GestureHelper.AngleFromVector(args.FinalLinearVelocity.X, args.FinalLinearVelocity.Y);
            if (angle <= 45 || angle >= 315)
            {
                angle = 0;
            }
            else if (angle >= 135 && angle <= 225)
            {
                angle = 180;
            }

            FlickEventArgs flickEventArgs = new FlickEventArgs
            {
                Angle = angle
            };
            ReleaseMouseCaptureAtGestureOrigin();
            RaiseFlick(flickEventArgs);
        }
        else if (args.TotalTranslation.X != 0 || args.TotalTranslation.Y != 0)
        {
            DragEventArgs dragEventArgs = new DragEventArgs
            {
                CumulativeDistance = args.TotalTranslation
            };
            dragEventArgs.MarkAsFinalTouchManipulation();
            e = dragEventArgs;
        }

        RaiseGestureEnd(e);
    }
Exemplo n.º 2
0
    protected void NotifyMove(InputDeltaArgs args)
    {
        if (Math.Abs(args.CumulativeTranslation.X) > DeadZoneInPixels.Width || Math.Abs(args.CumulativeTranslation.Y) > DeadZoneInPixels.Height)
        {
            if (!_dragging)
            {
                ReleaseMouseCaptureAtGestureOrigin();
            }

            _dragging = true;

            if (_dragLock == DragLock.Unset)
            {
                double angle = GestureHelper.AngleFromVector(args.CumulativeTranslation.X, args.CumulativeTranslation.Y) % 180;
                _dragLock = angle <= 45 || angle >= 135 ? DragLock.Horizontal : DragLock.Vertical;
            }
        }

        if (_dragging)
        {
            RaiseDragEvents(args);
        }
    }