/// <summary>
 /// Callback when thimer posture manager is stoped
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnTimeOutPosture(object sender, ElapsedEventArgs e)
 {
     m_refTimerPostureManager.Stop();
     m_refPostureRecognized = EnumPosture.POSTURE_NONE;
     PropertiesPluginKinect.Instance.SavePosturerecognize = EnumPosture.POSTURE_NONE;
     m_refAuthorizedGesture = true;
 }
        /// <summary>
        /// Convert EnumPosture to EnumKinectgestureRecognize
        /// </summary>
        /// <param name="posture">Posture treated</param>
        /// <returns>gesture recognized</returns>
        private EnumKinectGestureRecognize ConvertPostureEnum(EnumPosture posture)
        {
            switch (posture)
            {
                case EnumPosture.POSTURE_T:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_T;

                case EnumPosture.POSTURE_V:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_V;

                case EnumPosture.POSTURE_A:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_A;

                case EnumPosture.POSTURE_U:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_U;

                case EnumPosture.POSTURE_WAIT:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_WAIT;

                case EnumPosture.POSTURE_HOME:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_HOME;

                case EnumPosture.POSTURE_STAY:
                    return EnumKinectGestureRecognize.KINECT_RECOGNIZE_STAY;
            }

            return EnumKinectGestureRecognize.KINECT_RECOGNIZE_NONE;
        }
 /// <summary>
 /// Callback when a gesture checker detect a posture
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnPosture(object sender, GesturesEventArgs e)
 {
     // Posture detect in first time
     if(PropertiesPluginKinect.Instance.SavePosturerecognize != e.Posture)
     {
         RaiseUserGestureDetected(ConvertPostureEnum(e.Posture));
     }
     m_refPostureRecognized = e.Posture;
     PropertiesPluginKinect.Instance.SavePosturerecognize = e.Posture;
     m_refAuthorizedGesture = false;
     ResetTimerPosture();
 }
        public GestureRecognizerManager(UserData user)
        {
            //m_InstanceGestureRecognizerManager = this;

            m_refUser = user;

            #region Variables initialisation

            // Instantiate timer for manage gesture recognize
            m_refTimerGestureManager = new Timer();
            m_refTimerGestureManager.Interval = PropertiesPluginKinect.Instance.GestureRecognizedTime;
            m_refTimerGestureManager.Elapsed += OnTimeOutGesture;

            // Initialize buffer gesture recognition
            m_refGestureRecognized = new List<EnumGesture>();

            // Initialize gesture begin flags
            var ValueGestureAsList = System.Enum.GetValues(typeof(EnumGesture));
            m_refFlagGesturesBegin = new Dictionary<EnumGesture, bool>();
            foreach (EnumGesture gesture in ValueGestureAsList)
            {
                m_refFlagGesturesBegin.Add(gesture, false);
            }

            m_refAuthorizedGesture = true;

            // Instantiate timer for manage when a posture is recognized
            m_refTimerPostureManager = new Timer();
            m_refTimerPostureManager.Interval = PropertiesPluginKinect.Instance.PostureRecognizedTime;
            m_refTimerPostureManager.Elapsed += OnTimeOutPosture;

            m_refPostureRecognized = PropertiesPluginKinect.Instance.SavePosturerecognize;

            if (PropertiesPluginKinect.Instance.SavePosturerecognize != EnumPosture.POSTURE_NONE)
            {
                m_refTimerPostureManager.Start();
            }

            // Initialize posture begin flags
            var ValuePostureAsList = System.Enum.GetValues(typeof(EnumPosture));
            m_refFlagPostureBegin = new Dictionary<EnumPosture, bool>();
            foreach (EnumPosture posture in ValuePostureAsList)
            {
                m_refFlagPostureBegin.Add(posture, false);
            }

            // Listen the Gestures enable changement
            PropertiesPluginKinect.Instance.SynchronizeGesturesState += OnSynchronizeGesturesState;

            #endregion

            #region Gesture Checker initialisation

            if(!PropertiesPluginKinect.Instance.KinectPointingModeEnabled)
            {
                if (PropertiesPluginKinect.Instance.EnableGestureSwipeRight || PropertiesPluginKinect.Instance.EnableGestureSwipeLeft)
                {
                    m_refSwipeHandRightChecker = new SwipeGestureChecker(user, JointType.HandRight);
                    EnableGestureChecker(m_refSwipeHandRightChecker);

                    m_refSwipeHandLeftChecker = new SwipeGestureChecker(user, JointType.HandLeft);
                    EnableGestureChecker(m_refSwipeHandLeftChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGestureWave)
                {
                    m_refHandRightWaveChecker = new WaveGestureChecker(user, JointType.HandRight);
                    EnableGestureChecker(m_refHandRightWaveChecker);

                    m_refHandLeftWaveChecker = new WaveGestureChecker(user, JointType.HandLeft);
                    EnableGestureChecker(m_refHandLeftWaveChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGesturePush)
                {
                    m_refPushRightHandGestureChecker = new PushGestureChecker(user, JointType.HandRight);
                    EnableGestureChecker(m_refPushRightHandGestureChecker);

                    m_refPushLeftHandGestureChecker = new PushGestureChecker(user, JointType.HandLeft);
                    EnableGestureChecker(m_refPushLeftHandGestureChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGestureMaximize)
                {
                    m_refMaximizeGestureChecker = new MaximizeGestureChecker(user);
                    EnableGestureChecker(m_refMaximizeGestureChecker);
                }

                if (PropertiesPluginKinect.Instance.EnableGestureMinimize)
                {
                    m_refMinimizeGestureChecker = new MinimizeGestureChecker(user);
                    EnableGestureChecker(m_refMinimizeGestureChecker);
                }
            }

            if (PropertiesPluginKinect.Instance.EnablePostureA)
            {
                m_refPostureAChecker = new PostureAChecker(user);
                EnablePostureChecker(m_refPostureAChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureHome)
            {
                m_refPostureHomeChecker = new PostureHomeChecker(user);
                EnablePostureChecker(m_refPostureHomeChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureStay)
            {
                m_refPostureStayChecker = new PostureStayChecker(user);
                EnablePostureChecker(m_refPostureStayChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureT)
            {
                m_refPostureTChecker = new PostureTChecker(user);
                EnablePostureChecker(m_refPostureTChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureU)
            {
                m_refPostureUChecker = new PostureUChecker(user);
                EnablePostureChecker(m_refPostureUChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureV)
            {
                m_refPostureVChecker = new PostureVChecker(user);
                EnablePostureChecker(m_refPostureVChecker);
            }

            if (PropertiesPluginKinect.Instance.EnablePostureWait)
            {
                m_refPostureWaitChecker = new PostureWaitChecker(user);
                EnablePostureChecker(m_refPostureWaitChecker);
            }
            #endregion
        }