public 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; } }
private void HandleGestureTracking(float x, float y, float z) { if (!_gesturePointTrackingEnabled) return; 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); if (Math.Abs(newPoint.Y - startPoint.Y) > _swipeDeviation) { // Debug.WriteLine("Y is out of bounds"); if (SwipeOutOfBoundsDetected != null) SwipeOutOfBoundsDetected(this, new KinectCursorEventArgs(point) { Z = z, Cursor = _cursorAdorner }); ResetGesturePoint(GesturePoints.Count); return; } if ((newPoint.T - startPoint.T).Milliseconds > _swipeTime) // this checks the time { GesturePoints.RemoveAt(0); startPoint = GesturePoints[0]; } if ((_swipeLength < 0 && newPoint.X - startPoint.X < _swipeLength) || (_swipeLength > 0 && newPoint.X - startPoint.X > _swipeLength)) { GesturePoints.Clear(); // throw local event if (SwipeDeteted != null) SwipeDeteted(this, new KinectCursorEventArgs(point) { Z = z, Cursor = _cursorAdorner }); return; } if (_xOutOfBoundsLength != 0 && ((_xOutOfBoundsLength < 0 && newPoint.X - _initialSwipeX < _xOutOfBoundsLength) || (_xOutOfBoundsLength > 0 && newPoint.X - _initialSwipeX > _xOutOfBoundsLength))) { if (SwipeOutOfBoundsDetected != null) SwipeOutOfBoundsDetected(this, new KinectCursorEventArgs(point) { Z = z, Cursor = _cursorAdorner }); } }