Exemple #1
0
    public static void SetGestureCondition <T>(T ob, MountType mountType, CircleDirection circleDirection, float progress, UseArea useArea, UsingHand usingHand) where T : IGesture
    {
        if (ob._gestureType == GestureType.circle) // If gesture type is circle.
        {
            Circle_Gesture tempCircle = ob as Circle_Gesture;

            /* Initiate gesture option */
            tempCircle._state       = Gesture.GestureState.STATE_INVALID;
            tempCircle._isChecked   = false;
            tempCircle._isClockwise = -1;
            tempCircle._isPlaying   = false;

            /* Initiate to user options. */
            tempCircle._usingHand  = usingHand;
            tempCircle._mountType  = mountType;
            tempCircle._useArea    = useArea;
            tempCircle.MinProgress = progress;
            if (circleDirection == CircleDirection.Clockwise)
            {
                tempCircle._useDirection = 1;
            }
            else
            {
                tempCircle._useDirection = -1;
            }
        }
    }
 // Method for getting gesture's pointable object.
 public static Pointable GetPointable <T>(T ob) where T : IGesture
 {
     if (ob._gestureType == GestureType.circle)
     {
         Circle_Gesture tempCircle = ob as Circle_Gesture;
         tempCircle._pointable = tempCircle._circle_gesture.Pointable;
         return(tempCircle._pointable);
     }
     else if (ob._gestureType == GestureType.swipe)
     {
         Swipe_Gesture tempSwipe = ob as Swipe_Gesture;
         tempSwipe._pointable = tempSwipe._swipe_gestrue.Pointable;
         return(tempSwipe._pointable);
     }
     else if (ob._gestureType == GestureType.keytab)
     {
         KeyTap_Gesture tempKeyTab = ob as KeyTap_Gesture;
         tempKeyTab._pointable = tempKeyTab._keytab_gesture.Pointable;
         return(tempKeyTab._pointable);
     }
     else if (ob._gestureType == GestureType.screentab)
     {
         ScreenTap_Gesture tempScreenTab = ob as ScreenTap_Gesture;
         tempScreenTab._pointable = tempScreenTab._screentap_gesture.Pointable;
         return(tempScreenTab._pointable);
     }
     else
     {
         return(new Pointable());
     }
 }
    //For circle gesture, direction is clockwise.
    //All gesture object has pointable object. Using this, you can get angle element.
    //Using angle value in the caluculation can be determinded move in any direction.
    public static int IsClockWise <T>(T ob) where T : IGesture
    {
        if (ob._gestureType == GestureType.circle)
        {
            Circle_Gesture tempCircle = ob as Circle_Gesture;

            if (tempCircle._circle_gesture.Pointable.Direction.AngleTo(tempCircle.GetNormal()) <= 3.14 / 2)
            {
                tempCircle._isClockwise = 1; // If direction is clock wise.
            }
            else
            {
                tempCircle._isClockwise = -1; // If direction is counter clock wise.
            }

            return(tempCircle._isClockwise);
        }

        return(0);
    }
Exemple #4
0
    // This method check whether hand user want to use direction is captured.
    public static bool IsEnableGestureHand <T>(T ob) where T : IGesture
    {
        switch (ob._gestureType)                           // Check the gesture type.
        {
        case GestureType.swipe:                            // If GestureType is swipe.
            Swipe_Gesture tempSwipe = ob as Swipe_Gesture; // Wrap gesture type.
            if (tempSwipe._usingHand == UsingHand.All)     // If UsingHand value is All.
            {
                return(true);
            }
            else if ((tempSwipe._usingHand == UsingHand.Left) && (tempSwipe.tempHand.IsLeft))     //If UsingHand value is Left and captured hand side is left.
            {
                return(true);
            }
            else if ((tempSwipe._usingHand == UsingHand.Right) && tempSwipe.tempHand.IsRight)    //If UsingHand value is Right and captured hand side is Right.
            {
                return(true);
            }
            return(false);

        case GestureType.circle:     // If GestureType is circle.
            Circle_Gesture tempCircle = ob as Circle_Gesture;

            if (tempCircle._usingHand == UsingHand.All)
            {
                return(true);
            }
            else if ((tempCircle._usingHand == UsingHand.Left) && (tempCircle.tempHand.IsLeft))
            {
                return(true);
            }
            else if ((tempCircle._usingHand == UsingHand.Right) && tempCircle.tempHand.IsRight)
            {
                return(true);
            }
            return(false);

        case GestureType.keytab:    // If GestureType is keytab.
            KeyTap_Gesture tempKeytab = ob as KeyTap_Gesture;

            if (tempKeytab._usingHand == UsingHand.All)
            {
                return(true);
            }
            else if ((tempKeytab._usingHand == UsingHand.Left) && (tempKeytab.tempHand.IsLeft))
            {
                return(true);
            }
            else if ((tempKeytab._usingHand == UsingHand.Right) && tempKeytab.tempHand.IsRight)
            {
                return(true);
            }
            return(false);

        case GestureType.screentab:    // If GestureType is screentab.
            ScreenTap_Gesture tempScreenTab = ob as ScreenTap_Gesture;

            if (tempScreenTab._usingHand == UsingHand.All)
            {
                return(true);
            }
            else if ((tempScreenTab._usingHand == UsingHand.Left) && (tempScreenTab.tempHand.IsLeft))
            {
                return(true);
            }
            else if ((tempScreenTab._usingHand == UsingHand.Right) && tempScreenTab.tempHand.IsRight)
            {
                return(true);
            }
            return(false);

        case GestureType.grabhand:     // If GestureType is grabbing hand.
            GrabHand_Gesture tempGrabHand = ob as GrabHand_Gesture;

            if (tempGrabHand._usingHand == UsingHand.All)
            {
                return(true);
            }
            else if ((tempGrabHand._usingHand == UsingHand.Left) && tempGrabHand.tempHand.IsLeft)
            {
                return(true);
            }
            else if ((tempGrabHand._usingHand == UsingHand.Right) && tempGrabHand.tempHand.IsRight)
            {
                return(true);
            }
            return(false);

        case GestureType.fliphand:     // If GestureType is fliphand.
            FlipHand_Gesture tempFlipHand = ob as FlipHand_Gesture;

            if (tempFlipHand._usingHand == UsingHand.All)
            {
                return(true);
            }
            else if ((tempFlipHand._usingHand == UsingHand.Left) && (tempFlipHand.tempHand.IsLeft))
            {
                return(true);
            }
            else if ((tempFlipHand._usingHand == UsingHand.Right) && (tempFlipHand.tempHand.IsRight))
            {
                return(true);
            }
            return(false);

        case GestureType.usercustom:     // If GestureType is user custom.
            UserGesture tempUser = ob as UserGesture;

            if (tempUser._usingHand == UsingHand.All)
            {
                return(true);
            }
            else if ((tempUser._usingHand == UsingHand.Left) && (tempUser.tempHand.IsLeft))
            {
                return(true);
            }
            else if ((tempUser._usingHand == UsingHand.Right) && (tempUser.tempHand.IsRight))
            {
                return(true);
            }
            return(false);

        default:
            return(false);
        }
    }