Esempio n. 1
0
 public void ClearState()
 {
     Status             = GestureStatus.NotStarted;
     UpdatedInThisFrame = false;
     Error    = GestureFailure.None;
     LeftHand = RightHand = null;
 }
    public void DoUpdate(ModeStatus _currentMode, SubMenuModeStatus _currentSubMenuMode)
    {
        GestureStatus currentGesture = GetGesture();

        if (_currentMode == ModeStatus.Drawing)
        {
            switch (currentGesture)
            {
            case GestureStatus.StartDrag:
                OnStartDrag();
                break;

            case GestureStatus.Dragging:
                OnDragging();
                break;

            case GestureStatus.DoneDragging:
                DoneDragging();
                break;
            }
        }

        // check for hand lost
        if (GetLost())
        {
            manager.HandLost();
        }
    }
Esempio n. 3
0
        bool HandleTouchInteractions(GestureStatus status, APointF point)
        {
            if (!_isSwipeEnabled)
            {
                return(false);
            }

            switch (status)
            {
            case GestureStatus.Started:
                return(!ProcessTouchDown(point));

            case GestureStatus.Running:
                return(!ProcessTouchMove(point));

            case GestureStatus.Canceled:
            case GestureStatus.Completed:
                ProcessTouchUp(point);
                break;
            }

            _isTouchDown = false;

            return(true);
        }
Esempio n. 4
0
 //function that calculates the win of rock gesture
 public void GetWinner_Rock(int rand)
 {
     GestureReact();
     GestureReact1();
     GestureReact2();
     if (rand == 0)
     {
         gs            = GestureStatus.Rock;
         textBox1.Text = "Play Again? Remove your hand!";
         gs1           = GestureStatus1.doubt;
         gs2           = GestureStatus2.doubt;
     }
     else if (rand == 1)
     {
         gs            = GestureStatus.Scissors;
         textBox1.Text = "Play Again? Remove your hand!";
         gs1           = GestureStatus1.smile;
         gs2           = GestureStatus2.nosmile;
     }
     else if (rand == 2)
     {
         gs            = GestureStatus.Paper;
         textBox1.Text = "Play Again? Remove your hand!";
         gs1           = GestureStatus1.nosmile;
         gs2           = GestureStatus2.smile;
     }
 }
        // ジェスチャーを検出した
        void gesture_GestureRecognized(object sender, GestureRecognizedEventArgs e)
        {
            gestureStatus = GestureStatus.Recognized;

              // 手のトラッキングを開始する
              hands.StartTracking(e.EndPosition);
        }
Esempio n. 6
0
        // ジェスチャーを検出した
        void gesture_GestureRecognized(object sender, GestureRecognizedEventArgs e)
        {
            gestureStatus = GestureStatus.Recognized;

            // 手のトラッキングを開始する
            hands.StartTracking(e.EndPosition);
        }
Esempio n. 7
0
        void HandleTouchInteractions(NSSet touches, GestureStatus gestureStatus)
        {
            var    anyObject = touches.AnyObject as UITouch;
            nfloat x         = anyObject.LocationInView(this).X;
            nfloat y         = anyObject.LocationInView(this).Y;

            HandleTouchInteractions(gestureStatus, new CGPoint(x, y));
        }
        public void PanRaisesRunningEventTest()
        {
            var view = new View();
            var pan  = new PanGestureRecognizer();

            GestureStatus target = GestureStatus.Canceled;

            pan.PanUpdated += (object sender, PanUpdatedEventArgs e) => {
                target = e.StatusType;
            };

            ((IPanGestureController)pan).SendPan(view, gestureId: 0, totalX: 5, totalY: 10);
            Assert.AreEqual(GestureStatus.Running, target);
        }
        public void PanRaisesCanceledEventTest()
        {
            var view = new View();
            var pan  = new PanGestureRecognizer();

            GestureStatus target = GestureStatus.Started;

            pan.PanUpdated += (object sender, PanUpdatedEventArgs e) => {
                target = e.StatusType;
            };

            ((IPanGestureController)pan).SendPanCanceled(view, 0);
            Assert.AreEqual(GestureStatus.Canceled, target);
        }
Esempio n. 10
0
        public void PinchCompletedTest()
        {
            var view  = new View();
            var pinch = new PinchGestureRecognizer();

            GestureStatus result = GestureStatus.Canceled;

            pinch.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => {
                result = e.Status;
            };

            ((IPinchGestureController)pinch).SendPinchEnded(view);
            Assert.AreEqual(GestureStatus.Completed, result);
        }
Esempio n. 11
0
        private void HandleUpCancelEvent(GestureStatus status, double xDelta, double yDelta)
        {
            if (!_panStarted)
            {
                return;
            }
            _panStarted = false;

            UpdatePan(status, xDelta, yDelta);

            Parent?.RequestDisallowInterceptTouchEvent(false);

            _startX = null;
            _startY = null;
        }
Esempio n. 12
0
        private void HandleUpCancelEvent(MotionEvent e)
        {
            var xDelta = GetTotalX(e);
            var yDelta = GetTotalY(e);

            GestureStatus status = e.ActionMasked == MotionEventActions.Up && _didSwipe == false ? GestureStatus.Completed : GestureStatus.Canceled;

            Element.OnPanUpdated(Element, new PanUpdatedEventArgs(status, _gestureId, xDelta, yDelta));
            _lastTouchHandlerId = null;

            Parent?.RequestDisallowInterceptTouchEvent(false);

            _startX   = null;
            _startY   = null;
            _didSwipe = false;
        }
Esempio n. 13
0
        public void PinchStartedTest()
        {
            var view  = new View();
            var pinch = new PinchGestureRecognizer();

            GestureStatus result      = GestureStatus.Canceled;
            var           point       = new Point(10, 10);
            var           resultPoint = Point.Zero;

            pinch.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => {
                result      = e.Status;
                resultPoint = e.ScaleOrigin;
            };

            ((IPinchGestureController)pinch).SendPinchStarted(view, point);
            Assert.AreEqual(GestureStatus.Started, result);
            Assert.AreEqual(point, resultPoint);
        }
 /// <summary>
 /// Checks the gesture.
 /// </summary>
 /// <param name="skeleton">The skeleton.</param>
 /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
 public GesturePartResult CheckGesture(Skeleton skeleton, AllFramesReadyEventArgs e, GestureStatus gestureStatus)
 {
     if ((skeleton.Joints[JointType.Head].Position.X - gestureStatus.headPoint.X) < accuracy &&
         (skeleton.Joints[JointType.Head].Position.X - gestureStatus.headPoint.X) > -accuracy &&
         (skeleton.Joints[JointType.Head].Position.Y - gestureStatus.headPoint.Y) < accuracy &&
         (skeleton.Joints[JointType.Head].Position.Y - gestureStatus.headPoint.Y) > -accuracy &&
         (skeleton.Joints[JointType.Head].Position.Z - gestureStatus.headPoint.Z) < accuracy &&
         (skeleton.Joints[JointType.Head].Position.Z - gestureStatus.headPoint.Z) > -accuracy)
     {
         // Head does not moved.
         return GesturePartResult.Fail;
     }
     else
     {
         // Head moved, and new point will be update.
         gestureStatus.headPoint = skeleton.Joints[JointType.Head].Position;
         return GesturePartResult.Suceed;
     }
 }
Esempio n. 15
0
        void HandleTouchInteractions(GestureStatus status, CGPoint point)
        {
            switch (status)
            {
            case GestureStatus.Started:
                ProcessTouchDown(point);
                break;

            case GestureStatus.Running:
                ProcessTouchMove(point);
                break;

            case GestureStatus.Canceled:
            case GestureStatus.Completed:
                ProcessTouchUp();
                break;
            }

            _isTouchDown = false;
        }
        /// <summary>
        /// Checks the gesture.
        /// </summary>
        /// <param name="skeleton">The skeleton.</param>
        /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
        public GesturePartResult CheckGesture(Skeleton skeleton, AllFramesReadyEventArgs e, GestureStatus gestureStatus)
        {
            // Don't check if user is not making a fast
            if (!gestureStatus.isMakingAFast)
            {
                return GesturePartResult.Fail;
            }

            // Right in front of Shoulders
            if (skeleton.Joints[JointType.HandRight].Position.Z < skeleton.Joints[JointType.ElbowRight].Position.Z)
            {
                // Hands are higher then start point
                if (skeleton.Joints[JointType.HandRight].Position.Z > gestureStatus.startPoint.Z + 0.1)
                {
                    return GesturePartResult.Suceed;
                }

                return GesturePartResult.Fail;
            }

            return GesturePartResult.Fail;
        }
 public PinchGestureUpdatedEventArgs(GestureStatus status)
 {
     Status = status;
 }
Esempio n. 18
0
 public PanUpdatedEventArgs(GestureStatus type, int gestureId, double totalx, double totaly) : this(type, gestureId)
 {
     TotalX = totalx;
     TotalY = totaly;
 }
 /// <summary>
 /// Checks the gesture.
 /// </summary>
 /// <param name="skeleton">The skeleton.</param>
 /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
 public GesturePartResult CheckGesture(Skeleton skeleton, AllFramesReadyEventArgs e, GestureStatus gestureStatus)
 {
     if ((skeleton.Joints[JointType.Head].Position.X - gestureStatus.headPoint.X) < accuracy &&
         (skeleton.Joints[JointType.Head].Position.X - gestureStatus.headPoint.X) > -accuracy &&
         (skeleton.Joints[JointType.Head].Position.Y - gestureStatus.headPoint.Y) < accuracy &&
         (skeleton.Joints[JointType.Head].Position.Y - gestureStatus.headPoint.Y) > -accuracy &&
         (skeleton.Joints[JointType.Head].Position.Z - gestureStatus.headPoint.Z) < accuracy &&
         (skeleton.Joints[JointType.Head].Position.Z - gestureStatus.headPoint.Z) > -accuracy)
     {
         // Head does not moved.
         return(GesturePartResult.Fail);
     }
     else
     {
         // Head moved, and new point will be update.
         gestureStatus.headPoint = skeleton.Joints[JointType.Head].Position;
         return(GesturePartResult.Suceed);
     }
 }
Esempio n. 20
0
 private PanUpdatedEventArgs GetPanUpdatedEventArgs(GestureStatus status, double totalX = 0, double totalY = 0)
 => new PanUpdatedEventArgs(status, _gestureId, totalX, totalY);
 // ジェスチャーを検出した
 void gesture_GestureRecognized(object sender, GestureRecognizedEventArgs e)
 {
     gestureStatus = GestureStatus.Recognized;
 }
 // ジェスチャーが変更された
 void gesture_GestureChanged(object sender, EventArgs e)
 {
     gestureStatus = GestureStatus.Unrecognize;
 }
Esempio n. 23
0
		public PanUpdatedEventArgs(GestureStatus type, int gestureId, double totalx, double totaly) : this(type, gestureId)
		{
			TotalX = totalx;
			TotalY = totaly;
		}
Esempio n. 24
0
    GestureStatus GetGesture() // get hand gesture
    {
        GestureStatus _gestureStatus = GestureStatus.None;

        isHandTracked = false;
        rightTracked  = false;
        leftTracked   = false;

        foreach (var controller in CoreServices.InputSystem.DetectedControllers)
        {
            if (controller.ControllerHandedness.ToString() == "Right")
            {
                rightTracked = true;
            }
            else if (controller.ControllerHandedness.ToString() == "Left")
            {
                leftTracked = true;
            }

            if (controller.ControllerHandedness.ToString() == "Right" || controller.ControllerHandedness.ToString() == "Left")
            {
                isHandTracked = true;
            }

            foreach (MixedRealityInteractionMapping inputMapping in controller.Interactions)
            {
                // hand position
                if (isHandTracked)
                {
                    handPosition = inputMapping.PositionData;
                }

                if (inputMapping.Description == "Select")
                {
                    if (inputMapping.BoolData)
                    {
                        if (controller.ControllerHandedness.ToString() == "Left")
                        {
                            leftSelected = true;
                        }
                        else if (controller.ControllerHandedness.ToString() == "Right")
                        {
                            rightSelected = true;
                        }

                        if (enableDragging)
                        {
                            // drawing
                            if (prevGestureStatus != _gestureStatus)
                            {
                                _gestureStatus = GestureStatus.Dragging;
                            }
                            else
                            {
                                _gestureStatus = GestureStatus.StartDrag;
                            }
                        }

                        isHandSelected = true;
                    }
                    else
                    {
                        if (prevGestureStatus == GestureStatus.Dragging)
                        {
                            _gestureStatus = GestureStatus.DoneDragging;
                        }

                        isHandSelected = false;
                    }
                }
            }
        }

        // check for two hands
        if (leftSelected && rightSelected)
        {
            canDoubleTap = false;
        }
        else
        {
            canDoubleTap = true;
        }

        leftSelected = false; rightSelected = false;

        prevGestureStatus = _gestureStatus;

        return(_gestureStatus);
    }
Esempio n. 25
0
 protected virtual void OnFailed(GestureEventArgs e)
 {
     GestureFailed?.Invoke(this, e);
     this.status = GestureStatus.FAILED;
 }
Esempio n. 26
0
 public LongTapUpdatedEventArgs(GestureStatus status, double timestamp)
 {
     Status    = status;
     TimeStamp = timestamp;
 }
Esempio n. 27
0
 protected virtual void OnContinued(GestureEventArgs e)
 {
     GestureContinued?.Invoke(this, e);
     this.status = GestureStatus.CONTINUE;
 }
Esempio n. 28
0
 protected virtual void OnRegistered(GestureEventArgs e)
 {
     GestureRegistered?.Invoke(this, e);
     this.status = GestureStatus.REGISTERED;
 }
Esempio n. 29
0
        private void UpdatePan(GestureStatus status, double totalX = 0, double totalY = 0)
        {
            var args = GetPanUpdatedEventArgs(status, totalX, totalY);

            Element.OnPanUpdated(args, _isSwiped);
        }
 public PinchGestureUpdatedEventArgs(GestureStatus status, double scale, Point origin) : this(status)
 {
     ScaleOrigin = origin;
     Scale       = scale;
 }
 // ジェスチャーの検出中
 void gesture_GestureProgress(object sender, GestureProgressEventArgs e)
 {
     gestureStatus = GestureStatus.Progress;
 }
        /// <summary>
        /// Consume a packet from the buffer if possible, then advance the buffer index.
        /// </summary>
        /// <param name="buffer">Byte buffer to decode</param>
        /// <param name="index">(Ref) Index to read into buffer</param>
        /// <exception cref="WearableProxyProtocolException">Thrown when a packet cannot be decoded and the buffer
        /// must be discarded.</exception>
        /// <exception cref="IndexOutOfRangeException">Thrown when a packet was partially consumed but ran out of
        /// buffer contents.</exception>
        public override void ProcessPacket(byte[] buffer, ref int index)
        {
            PacketTypeCode packetType = DecodePacketType(buffer, ref index);

            switch (packetType)
            {
            case PacketTypeCode.KeepAlive:
            {
                CheckFooter(buffer, ref index);

                if (KeepAlive != null)
                {
                    KeepAlive.Invoke();
                }

                break;
            }

            case PacketTypeCode.PingQuery:
            {
                CheckFooter(buffer, ref index);

                if (PingQuery != null)
                {
                    PingQuery.Invoke();
                }

                break;
            }

            case PacketTypeCode.PingResponse:
            {
                CheckFooter(buffer, ref index);

                if (PingResponse != null)
                {
                    PingResponse.Invoke();
                }

                break;
            }

            case PacketTypeCode.SensorFrame:
            {
                SensorFrame frame = DecodeSensorFrame(buffer, ref index);
                CheckFooter(buffer, ref index);

                if (NewSensorFrame != null)
                {
                    NewSensorFrame.Invoke(frame);
                }

                break;
            }

            case PacketTypeCode.DeviceList:
            {
                Device[] devices = DecodeDeviceList(buffer, ref index);
                CheckFooter(buffer, ref index);

                if (DeviceList != null)
                {
                    DeviceList.Invoke(devices);
                }

                break;
            }

            case PacketTypeCode.ConnectionStatus:
            {
                Device?         device;
                ConnectionState status = DecodeConnectionStatus(buffer, ref index, out device);
                CheckFooter(buffer, ref index);

                if (ConnectionStatus != null)
                {
                    ConnectionStatus.Invoke(status, device);
                }

                break;
            }

            case PacketTypeCode.SensorStatus:
            {
                bool     enabled;
                SensorId sensor = DecodeSensorStatus(buffer, ref index, out enabled);
                CheckFooter(buffer, ref index);

                if (SensorStatus != null)
                {
                    SensorStatus.Invoke(sensor, enabled);
                }

                break;
            }

            case PacketTypeCode.UpdateIntervalValue:
            {
                SensorUpdateInterval rate = DecodeUpdateInterval(buffer, ref index);
                CheckFooter(buffer, ref index);

                if (SensorUpdateIntervalValue != null)
                {
                    SensorUpdateIntervalValue.Invoke(rate);
                }

                break;
            }

            case PacketTypeCode.GestureStatus:
            {
                bool      enabled;
                GestureId gesture = DecodeGestureStatus(buffer, ref index, out enabled);
                CheckFooter(buffer, ref index);

                if (GestureStatus != null)
                {
                    GestureStatus.Invoke(gesture, enabled);
                }

                break;
            }

            case PacketTypeCode.RotationSourceValue:
            {
                RotationSensorSource source = DecodeRotationSource(buffer, ref index);
                CheckFooter(buffer, ref index);

                if (RotationSourceValue != null)
                {
                    RotationSourceValue.Invoke(source);
                }

                break;
            }

            case PacketTypeCode.SensorControl:
            case PacketTypeCode.SetRssiFilter:
            case PacketTypeCode.InitiateDeviceSearch:
            case PacketTypeCode.StopDeviceSearch:
            case PacketTypeCode.ConnectToDevice:
            case PacketTypeCode.DisconnectFromDevice:
            case PacketTypeCode.QueryConnectionStatus:
            case PacketTypeCode.QueryUpdateInterval:
            case PacketTypeCode.SetUpdateInterval:
            case PacketTypeCode.QuerySensorStatus:
            case PacketTypeCode.GestureControl:
            case PacketTypeCode.QueryRotationSource:
            case PacketTypeCode.SetRotationSource:
                // This is a known, but contextually-invalid packet type
                throw new WearableProxyProtocolException(WearableConstants.ProxyProviderInvalidPacketError);

            default:
                // This is an unknown or invalid packet type
                throw new WearableProxyProtocolException(WearableConstants.ProxyProviderInvalidPacketError);
            }
        }
Esempio n. 33
0
		public PanUpdatedEventArgs(GestureStatus type, int gestureId)
		{
			StatusType = type;
			GestureId = gestureId;
		}
        /// <summary>
        /// Checks the gesture.
        /// </summary>
        /// <param name="skeleton">The skeleton.</param>
        /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
        public GesturePartResult CheckGesture(Skeleton skeleton, AllFramesReadyEventArgs e, GestureStatus gestureStatus)
        {
            // Right in front of Shoulders
            if (skeleton.Joints[JointType.HandRight].Position.Z > skeleton.Joints[JointType.ShoulderRight].Position.Z - 0.15)
            {
                return GesturePartResult.Pausing;
            }

            DepthImageFrame depthFrame = e.OpenDepthImageFrame();
            byte[] handBytes = null;

            if (depthFrame == null)
            {
                return GesturePartResult.Fail;
            }

            try
            {
                if (skeleton.Joints[JointType.HandRight].Position.X == 0 || skeleton.Joints[JointType.HandRight].Position.Y == 0)
                {
                    return GesturePartResult.Fail;
                }

                DepthImagePoint rightHandPoint = depthFrame.MapFromSkeletonPoint(skeleton.Joints[JointType.HandRight].Position);

                int intRightX = (int)rightHandPoint.X - (int)50;
                int intRightY = (int)rightHandPoint.Y - (int)60;

                Int32Rect rectRightHand = new Int32Rect(
                              (intRightX < 0) ? 0 : (intRightX + 100 >= depthFrame.Width) ? depthFrame.Width - 100 : intRightX,
                              (intRightY < 0) ? 0 : (intRightY + 100 >= depthFrame.Height) ? depthFrame.Height - 100 : intRightY,
                               100,
                               100
                             );

                handBytes = GenerateColoredBytes(depthFrame, rectRightHand, rightHandPoint.Depth);

                // Judge if making a fist and saving the starting / ending point
                // if 'no'->'yes' record the starting point
                // if 'yes'->'no' record the ending point

                // Initialize unmanged memory to hold the array.
                try
                {
                    // Create image and show it
                    MIplImage source = new MIplImage();
                    IntPtr sourcePtr = CvInvoke.cvCreateImage(new System.Drawing.Size(rectRightHand.Width, rectRightHand.Height),
                        Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_8U, 3);
                    source = (MIplImage)Marshal.PtrToStructure(sourcePtr, typeof(MIplImage));

                    // Copy the array to unmanaged memory.
                    Marshal.Copy(handBytes, 0, source.imageData, rectRightHand.Width * rectRightHand.Height * 3);
                    CvInvoke.cvShowImage("Source", sourcePtr);
                }
                finally
                {
                    // Free the unmanaged memory.
                }

                if (isMakingAFist(handBytes, rectRightHand))
                {
                    if (!gestureStatus.isMakingAFast)
                    {
                        gestureStatus.startPoint.X = skeleton.Joints[JointType.HandRight].Position.X;
                        gestureStatus.startPoint.Y = skeleton.Joints[JointType.HandRight].Position.Y;
                        gestureStatus.startPoint.Z = skeleton.Joints[JointType.HandRight].Position.Z;
                    }
                    gestureStatus.isMakingAFast = true;
                }
                else
                {
                    if (gestureStatus.isMakingAFast)
                    {
                        gestureStatus.startPoint.X = skeleton.Joints[JointType.HandRight].Position.X;
                        gestureStatus.startPoint.Y = skeleton.Joints[JointType.HandRight].Position.Y;
                        gestureStatus.startPoint.Z = skeleton.Joints[JointType.HandRight].Position.Z;
                    }
                    gestureStatus.isMakingAFast = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AfterConvert : " + ex.Message);
                depthFrame.Dispose();
                return GesturePartResult.Fail;
            }
            depthFrame.Dispose();
            //TODO
            return GesturePartResult.Suceed;
        }
 // ジェスチャーの検出中
 void gesture_GestureProgress(object sender, GestureProgressEventArgs e)
 {
     gestureStatus = GestureStatus.Progress;
       Trace.WriteLine(e.Gesture + ":" + e.Progress);
 }
Esempio n. 36
0
        /// <summary>
        /// Checks the gesture.
        /// </summary>
        /// <param name="skeleton">The skeleton.</param>
        /// <returns>GesturePartResult based on if the gesture part has been completed</returns>
        public GesturePartResult CheckGesture(Skeleton skeleton, AllFramesReadyEventArgs e, GestureStatus gestureStatus)
        {
            // Don't check if user is not making a fast
            if (!gestureStatus.isMakingAFast)
            {
                return(GesturePartResult.Fail);
            }

            // Right in front of Shoulders
            if (skeleton.Joints[JointType.HandRight].Position.Z < skeleton.Joints[JointType.ElbowRight].Position.Z)
            {
                // Hands are higher then start point
                if (skeleton.Joints[JointType.HandRight].Position.Y < gestureStatus.startPoint.Y - 0.1)
                {
                    return(GesturePartResult.Suceed);
                }

                return(GesturePartResult.Fail);
            }

            return(GesturePartResult.Fail);
        }
Esempio n. 37
0
 private void UpdatePan(GestureStatus status, double totalX = 0, double totalY = 0)
 => Element.OnPanUpdated(GetPanUpdatedEventArgs(status, totalX, totalY));
Esempio n. 38
0
 public PanUpdatedEventArgs(GestureStatus type, int gestureId)
 {
     StatusType = type;
     GestureId  = gestureId;
 }
Esempio n. 39
0
 protected virtual void OnTerminated(GestureEventArgs e)
 {
     GestureTerminated?.Invoke(this, e);
     this.status = GestureStatus.TERMINATED;
 }
Esempio n. 40
0
        public void RenderFeedback(GestureStatus status)
        {
            // set ProgressBar.Value
            var GesturePercentage = status.GetGesturePercentage();

            if (status.Succeeded)
            {
                this.ProgressBar.Value = 1.0; // set to 100% directly
                this.Stopwatch.Restart();     // restart MainInstruction cooldown because gesture was completed
            }
            else
            {
                this.ProgressBar.Value = GesturePercentage;
                //if (this.ProgressBar.Value == 1) // it means the gesture was completed on the last frame
                //{
                //    this.ProgressBar.Value = 0.0;
                //}
                //else if (status.AccumulatedError >= 1.0) // it means gesture was broken
                //{
                //    this.ProgressBar.Value = 0.0;
                //}
                //else
                //{
                //    this.ProgressBar.Value = this.ProgressBar.Value * 0.5 + GesturePercentage * 0.5;
                //}
            }

            // set FailureBar.Value
            if (status.Broke)
            {
                this.FailureBar.Value      = 1.0;
                this.FailureBar.Foreground = Brushes.DarkGray;
                this.Stopwatch.Restart(); // restart MainInstruction cooldown because gesture was broke
            }
            else if (GesturePercentage >= 1)
            {
                this.FailureBar.Value = 0.0;
            }
            else
            {
                this.FailureBar.Value      = this.FailureBar.Value * 0.5 + status.AccumulatedError * 0.5;
                this.FailureBar.Foreground = Brushes.LightGray;
            }

            // set MainInstruction
            // MainInstruction is updated only after a cooldown
            // this makes it easier for the user to read the instruction
            var cooldown = 0;
            var elapsed  = this.Stopwatch.ElapsedMilliseconds;

            if (elapsed > cooldown)
            {
                this.CurrentStepTextBlock.Text = status.MainInstruction; //Name;
                elapsed = 0;
                this.Stopwatch.Restart();
            }

            // set CompletedCount
            this.CompletedTimesTextBlock.Text = status.CompletedCount.ToString();
            this.Height =
                this.MainGestureAndPoseNameTextBlock.ActualHeight +
                this.ProgressBar.ActualHeight +
                this.CurrentStepTextBlock.ActualHeight +
                10;
        }