Exemplo n.º 1
0
        private void ResetGesturePoint(GesturePoint point)
        {
            bool startRemoving = false;

            for (int i = gesturePoints.Count; i >= 0; i--)
            {
                if (startRemoving)
                {
                    gesturePoints.RemoveAt(i);
                }
                else
                if (gesturePoints[i].Equals(point))
                {
                    startRemoving = true;
                }
            }
        }
Exemplo n.º 2
0
        private void HandleGestureTracking(float x, float y, float z)
        {
            if (!gesturePointTrackingEnabled)
            {
                return;
            }
            // check to see if xOutOfBounds is being used
            if (xOutOfBoundsLength != 0 && initialSwipeX == 0)
            {
                initialSwipeX = x;
            }

            GesturePoint newPoint = new GesturePoint()
            {
                X = x, Y = y, Z = z, T = DateTime.Now
            };

            gesturePoints.Add(newPoint);

            GesturePoint startPoint = gesturePoints[0];
            var          point      = new Point(x, y);


            //check for deviation
            if (Math.Abs(newPoint.Y - startPoint.Y) > swipeDeviation)
            {
                //Debug.WriteLine("Y out of bounds");
                if (swipeOutofBoundDetected != null)
                {
                    swipeOutofBoundDetected(this, new KinectCursorEventArgs(point)
                    {
                        Z = z, Cursor = cursorAdorner
                    });
                }
                ResetGesturePoint(gesturePoints.Count);
                return;
            }
            if ((newPoint.T - startPoint.T).Milliseconds > swipeTime) //check time
            {
                gesturePoints.RemoveAt(0);
                startPoint = gesturePoints[0];
            }
            if ((swipeLength < 0 && newPoint.X - startPoint.X < swipeLength) || // check to see if distance has been achieved swipe left
                (swipeLength > 0 && newPoint.X - startPoint.X > swipeLength))    // check to see if distance has been achieved swipe right
            {
                gesturePoints.Clear();

                //throw local event
                if (swipeDetected != null)
                {
                    swipeDetected(this, new KinectCursorEventArgs(point)
                    {
                        Z = z, Cursor = cursorAdorner
                    });
                }
                return;
            }
            if (xOutOfBoundsLength != 0 &&
                ((xOutOfBoundsLength < 0 && newPoint.X - initialSwipeX < xOutOfBoundsLength) || // check to see if distance has been achieved swipe left
                 (xOutOfBoundsLength > 0 && newPoint.X - initialSwipeX > xOutOfBoundsLength))
                )
            {
                if (swipeOutofBoundDetected != null)
                {
                    swipeOutofBoundDetected(this, new KinectCursorEventArgs(point)
                    {
                        Z = z, Cursor = cursorAdorner
                    });
                }
            }
        }