Paint.BaseGame.ConvertGestureType C# (CSharp) Méthode

ConvertGestureType() protected méthode

Converts a MonoGame.GestureType into our TouchType representation
protected ConvertGestureType ( GestureType gestureType ) : TouchType
gestureType GestureType /// The monogame gesture type. ///
Résultat TouchType
        protected TouchType ConvertGestureType(GestureType gestureType)
        {
            /* If the user taps the screen then we get a single Tap
             * If the user touches the screen and drags then we get several FreeDrag events and a final DragComplete event.
             * We keep track of the previous GestureType so that we can characterise the first FreeDrag as a StartDrag.  This
             * allows the Canvas control to track where the drag started - I've decided that while a drag continues then all input
             * should be handled by the control where the drag started, even if the user accidentally moves outside that control.
             * Makes for a better user experience.
             */

            TouchType returnValue;

            switch (gestureType)
            {
                case GestureType.Tap:
                    returnValue = TouchType.Tap;
                    break;

                case GestureType.FreeDrag:
                    if (this.previousTouchType != TouchType.FreeDrag && this.previousTouchType != TouchType.StartDrag)
                    {
                        returnValue = TouchType.StartDrag;
                    }
                    else
                    {
                        returnValue = TouchType.FreeDrag;
                    }

                    break;

                case GestureType.DragComplete:
                default:
                    returnValue = TouchType.DragComplete;
                    break;
            }

            this.previousTouchType = returnValue;

            return returnValue;
        }