protected virtual GestureEnd EndMove(bool isInertial, ManipulationDelta cumulative, ManipulationVelocities velocities, Point position)
        {
            this.dragLock = DragLock.Unset;
            this.dragging = false;
            double angle = 0.0;

            if (isInertial)
            {
#if !WINDOWS_PHONE
                angle = GestureService.AngleFromVector(velocities.Linear.X, velocities.Linear.Y);
#else
                angle = GestureService.AngleFromVector(velocities.LinearVelocity.X, velocities.LinearVelocity.Y);
#endif
                if (angle <= 45.0 || angle >= 315.0)
                {
                    angle = 0.0;
                }
                else if (angle >= 135.0 && angle <= 225.0)
                {
                    angle = 180.0;
                }
                this.ReleaseMouseCaptureAtGestureOrigin();
            }
            return(new GestureEnd(angle, isInertial, cumulative.Translation, position));
        }
Exemple #2
0
        //***********************************************************************************************************************

        //***********************************************************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="Args"></param>
        //-----------------------------------------------------------------------------------------------------------------------
        private void NotifyUp(InputCompletedArgs Args)
        {
            //-------------------------------------------------------------------------------------------------------------------
            EventArgs Result = EventArgs.Empty;

            this.DragLockValue = DragLock.Unset;
            this.Dragging      = false;
            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            if ((Args.TotalTranslation.X != 0.0) || (Args.TotalTranslation.Y != 0.0))
            {
                //---------------------------------------------------------------------------------------------------------------
                DragEventArgs DragEvent = new DragEventArgs();

                DragEvent.CumulativeDistance = Args.TotalTranslation;

                DragEvent.MarkAsFinalTouchManipulation();

                Result = DragEvent;
                //---------------------------------------------------------------------------------------------------------------
            }
            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            this.RaiseGestureEnd(Result);
            //-------------------------------------------------------------------------------------------------------------------
        }
 protected virtual GestureStart StartMove(object container, Point position)
 {
     this.gestureSource = new WeakReference(container);
     this.gestureOrigin = position;
     this.dragLock      = DragLock.Unset;
     this.dragging      = false;
     return(new GestureStart(position));
 }
 protected void NotifyDown(InputBaseArgs args)
 {
     GestureEventArgs e = new GestureEventArgs();
     _gestureSource = new WeakReference(args.Source);
     _gestureOrigin = args.Origin;
     _dragLock = DragLock.Unset;
     _dragging = false;
     RaiseGestureStart(e);
 }
Exemple #5
0
    protected void NotifyDown(InputBaseArgs args)
    {
        GestureEventArgs e = new GestureEventArgs();

        _gestureSource = new WeakReference(args.Source);
        _gestureOrigin = args.Origin;
        _dragLock      = DragLock.Unset;
        _dragging      = false;
        RaiseGestureStart(e);
    }
Exemple #6
0
        //***********************************************************************************************************************

        //***********************************************************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="Args"></param>
        //-----------------------------------------------------------------------------------------------------------------------
        private void NotifyMove(InputDeltaArgs Args)
        {
            //-------------------------------------------------------------------------------------------------------------------
            if ((Math.Abs(Args.CumulativeTranslation.X) > this.DeadZoneInPixels.Width) ||
                (Math.Abs(Args.CumulativeTranslation.Y) > this.DeadZoneInPixels.Height))
            {
                //---------------------------------------------------------------------------------------------------------------
                this.GestureManipulation = Args.Origin;

                if (!this.Dragging)
                {
                    this.ReleaseMouseCaptureAtGestureOrigin();
                }

                this.Dragging = true;
                //---------------------------------------------------------------------------------------------------------------

                //---------------------------------------------------------------------------------------------------------------
                if (this.DragLockValue == DragLock.Unset)
                {
                    //-----------------------------------------------------------------------------------------------------------
                    double Value = AngleFromVector(Args.CumulativeTranslation.X, Args.CumulativeTranslation.Y) % 180.0;
                    //-----------------------------------------------------------------------------------------------------------

                    //-----------------------------------------------------------------------------------------------------------
                    if ((Value <= 45.0) || (Value >= 135.0))
                    {
                        this.DragLockValue = DragLock.Horizontal;
                    }
                    //-----------------------------------------------------------------------------------------------------------
                    else if ((Value > 45.0) && (Value < 135.0))
                    {
                        this.DragLockValue = DragLock.Vertical;
                    }
                    //-----------------------------------------------------------------------------------------------------------
                    else
                    {
                        this.DragLockValue = DragLock.Free;
                    }
                    //-----------------------------------------------------------------------------------------------------------
                }
                //---------------------------------------------------------------------------------------------------------------
            }
            //-------------------------------------------------------------------------------------------------------------------

            //-------------------------------------------------------------------------------------------------------------------
            if (this.Dragging)
            {
                this.RaiseDragEvents(Args);
            }
            //-------------------------------------------------------------------------------------------------------------------
        }
Exemple #7
0
        //***********************************************************************************************************************

        //-----------------------------------------------------------------------------------------------------------------------
        #endregion
        //***********************************************************************************************************************

        //***********************************************************************************************************************
        #region         // Section des Procédures de Traitement
        //-----------------------------------------------------------------------------------------------------------------------

        //***********************************************************************************************************************
        /// <summary>
        ///
        /// </summary>
        /// <param name="Args"></param>
        //-----------------------------------------------------------------------------------------------------------------------
        private void NotifyDown(InputBaseArgs Args)
        {
            //-------------------------------------------------------------------------------------------------------------------
            GestureEventArgs NewArgs = new GestureEventArgs();

            this.GestureSource       = new WeakReference(Args.Source);
            this.GestureOrigin       = Args.Origin;
            this.GestureManipulation = Args.Origin;
            this.DragLockValue       = DragLock.Unset;
            this.Dragging            = false;

            this.RaiseGestureStart(NewArgs);
            //-------------------------------------------------------------------------------------------------------------------
        }
 private DragLock GetDragLockForMove(ManipulationDelta cumulative)
 {
     if (!this.dragging)
     {
         this.ReleaseMouseCaptureAtGestureOrigin();
     }
     this.dragging = true;
     if (this.dragLock == DragLock.Unset)
     {
         double num = GestureService.AngleFromVector(cumulative.Translation.X, cumulative.Translation.Y) % 180.0;
         this.dragLock = num <= 45.0 || num >= 135.0 ? DragLock.Horizontal : DragLock.Vertical;
     }
     return(this.dragLock);
 }
Exemple #9
0
    void On_Drag(Gesture gesture)
    {
        if (m_gestureLock != GestureLock.Drag || gesture.touchCount != 1)
        {
            return;
        }

        // Example Inputs (where sw = screen widths)
        //      0.1 sw in 0.2 sec (slow drag)
        //      0.5 sw in 0.2 sec (medium drag)
        //      1 sw in 0.2 sec (fast drag)

        // Calculate drag position
        var drag = new Drag();

        drag.time = Time.time;
        Engine.cameraUI.ScreenPointToWorldPosition(m_cameraRailPlane, gesture.position, out drag.localPosition);
        drag.localPosition = transform.InverseTransformPoint(drag.localPosition);

        if (m_dragLock == DragLock.None)
        {
            m_dragLock = Mathf.Abs(gesture.deltaPosition.x) > Mathf.Abs(gesture.deltaPosition.y) ? DragLock.Horizontal : DragLock.Vertical;
        }

        if (m_dragLock == DragLock.Horizontal)
        {
            var railPos = CalculateElasticPosition(
                m_startPositions.x,
                (drag.localPosition.x - m_startDrag.localPosition.x),
                m_rig.railMagnitude,
                0.5f,
                1f
                );

            SetMainRailPosition(railPos);
        }
        else
        {
            var zoomPos = CalculateElasticPosition(
                m_startPositions.y,
                (drag.localPosition.y - m_startDrag.localPosition.y),
                m_rig.zoomRailMagnitude,
                0.5f,
                1f
                );

            SetZoomRailPosition(zoomPos);
        }
    }
Exemple #10
0
    void On_DragStart2Fingers(Gesture gesture)
    {
        if (m_gestureLock != GestureLock.None)
        {
            return;
        }
        var drag = new Drag();

        drag.time = Time.time;

        Engine.cameraUI.ScreenPointToWorldPosition(m_cameraRailPlane, gesture.startPosition, out drag.localPosition);
        drag.localPosition = transform.InverseTransformPoint(drag.localPosition);

        m_gestureLock       = GestureLock.DoubleDrag;
        m_dragLock          = DragLock.None;
        m_startDrag         = drag;
        m_startPositions[2] = GetNormalizedTiltAngle();
        m_isDragging        = true;
    }
Exemple #11
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);
    }
        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);
            }
        }
Exemple #13
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);
        }
    }
        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);
        }
 protected virtual GestureStart StartMove(object container, Point position)
 {
     this.gestureSource = new WeakReference(container);
     this.gestureOrigin = position;
     this.dragLock = DragLock.Unset;
     this.dragging = false;
     return new GestureStart(position);
 }
 protected virtual GestureEnd EndMove(bool isInertial, ManipulationDelta cumulative, ManipulationVelocities velocities, Point position)
 {
     this.dragLock = DragLock.Unset;
     this.dragging = false;
     double angle = 0.0;
     if (isInertial)
     {
         angle = GestureService.AngleFromVector(velocities.Linear.X, velocities.Linear.Y);
         if (angle <= 45.0 || angle >= 315.0)
         {
             angle = 0.0;
         }
         else if (angle >= 135.0 && angle <= 225.0)
         {
             angle = 180.0;
         }
         this.ReleaseMouseCaptureAtGestureOrigin();
     }
     return new GestureEnd(angle, isInertial, cumulative.Translation, position);
 }
 private DragLock GetDragLockForMove(ManipulationDelta cumulative)
 {
     if (!this.dragging)
     {
         this.ReleaseMouseCaptureAtGestureOrigin();
     }
     this.dragging = true;
     if (this.dragLock == DragLock.Unset)
     {
         double num = GestureService.AngleFromVector(cumulative.Translation.X, cumulative.Translation.Y) % 180.0;
         this.dragLock = num <= 45.0 || num >= 135.0 ? DragLock.Horizontal : DragLock.Vertical;
     }
     return this.dragLock;
 }