Example #1
0
        public BasePositionProvider(string id)
        {
            if (String.IsNullOrEmpty(id))
                throw new ArgumentNullException("id");

            Id = id;
            CurrentPoint = new GesturePoint();
        }
Example #2
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;
                }
            }
        }
Example #3
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;
            }
            //Check time
            if ((newPoint.T - startPoint.T).Milliseconds > swipeTime)
            {
                gesturePoints.RemoveAt(0);
                startPoint = gesturePoints[0];
            }
            //Check to see if distance has been achieves swipe left/right
            if ((swipeLength < 0 && newPoint.X - startPoint.X < swipeLength) ||
                (swipeLength > 0 && newPoint.X - startPoint.X > swipeLength))
            {
                gesturePoints.Clear();
                //throw local event
                if (swipeDetected != null)
                {
                    swipeDetected(this, new KinectCursorEventArgs(point)
                    {
                        Z = z, Cursor = cursorAdorner
                    });
                }
                return;
            }
            //Check to see if distance has been achieve swipe left/right
            if (xOutOfBoundsLength != 0 &&
                ((xOutOfBoundsLength < 0 && newPoint.X - initialSwipeX < xOutOfBoundsLength) ||
                 (xOutOfBoundsLength > 0 && newPoint.X - initialSwipeX > xOutOfBoundsLength)))
            {
                if (swipeOutofBoundDetected != null)
                {
                    swipeOutofBoundDetected(this, new KinectCursorEventArgs(point)
                    {
                        Z = z, Cursor = cursorAdorner
                    });
                }
            }
        }
Example #4
0
        public void Update(GesturePoint currentPoint)
        {
            if (lastPoint == null)
            {
                lastPoint = new GesturePoint();
                lastPoint.CopyFrom(currentPoint);

                updateTimer.Reset();
                updateTimer.Start();
            }
            else
            {
                if (updateTimer.Elapsed > latency)
                {
                    var vector = currentPoint.Position - lastPoint.Position;
                    lastPoint.CopyFrom(currentPoint);

                    ProcessGestureVector(vector);

                    updateTimer.Restart();
                }
            }
        }
Example #5
0
 public void Reset()
 {
     lastPoint = null;
     updateTimer.Stop();
     currentGesture = SimpleGesture.None;
 }