Ejemplo n.º 1
0
        public void AddPushPoint(TimePoint point)
        {
            if (!initialized)
            {
                Initialize();
            }

            int max = this.LineSize - 1;

            for (int i = max; i > 0; i--)
            {
                points[i] = points[i - 1];
            }

            points[0] = point;
            if (points[0].X != 0)
            {
                bool result = this.AnalyzePoints(points);

                if (result)
                {
                    if (PushCaptured != null)
                    {
                        PushCaptured(this, EventArgs.Empty);
                    }

                    for (int i = 0; i < this.LineSize; i++)
                    {
                        points[i] = new TimePoint();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void AddSwipePoint(TimePoint point)
        {
            if (!initialized)
            {
                Initialize();
            }

            int max = this.LineSize - 1;

            for (int i = max; i > 0; i--)
            {
                points[i] = points[i - 1];
            }

            points[0] = point;
            if (points[0].X != 0)
            {
                bool result = this.AnalyzePoints(points);

                if (result)
                {
                    if (SwipeCaptured != null)
                    {
                        var direction = points[0].X > points[last].X ? SwipeDirection.Right : SwipeDirection.Left;
                        SwipeCaptured(null,
                                      new SwipeEventArgs(direction));
                    }

                    for (int i = 0; i < this.LineSize; i++)
                    {
                        points[i] = new TimePoint();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void AddPushPoint(TimePoint point)
        {
            if (!initialized)
                Initialize();

            int max = this.LineSize - 1;
            for (int i = max; i > 0; i--)
            {
                points[i] = points[i - 1];
            }

            points[0] = point;
            if (points[0].X != 0)
            {
                bool result = this.AnalyzePoints(points);

                if (result)
                {

                    if (PushCaptured != null)
                    {
                        PushCaptured(this, EventArgs.Empty);
                    }

                    for (int i = 0; i < this.LineSize; i++)
                    {
                        points[i] = new TimePoint();
                    }
                }

            }
        }
Ejemplo n.º 4
0
        public void AddSwipePoint(TimePoint point)
        {
            if (!initialized)
                Initialize();

            int max = this.LineSize - 1;
            for (int i = max; i > 0; i--)
            {
                points[i] = points[i - 1];
            }

            points[0] = point;
            if (points[0].X != 0)
            {
                bool result = this.AnalyzePoints(points);

                if (result)
                {

                    if (SwipeCaptured != null)
                    {
                        var direction = points[0].X > points[last].X ? SwipeDirection.Right : SwipeDirection.Left;
                        SwipeCaptured(null,
                            new SwipeEventArgs(direction));
                    }

                    for (int i = 0; i < this.LineSize; i++)
                    {
                        points[i] = new TimePoint();
                    }
                }

            }
        }
Ejemplo n.º 5
0
        public void Initialize()
        {
            if (!initialized)
            {
                LineSize    = 7;
                MinZDelta   = 70;
                last        = LineSize - 1;
                MaxTimeSpan = TimeSpan.FromMilliseconds(300);

                points = new TimePoint[this.LineSize];
                for (int i = 0; i < this.LineSize; i++)
                {
                    points[i] = new TimePoint();
                }
                initialized = true;
            }
        }
Ejemplo n.º 6
0
        void ReaderThread()
        {
            while (this.ShouldRun)
            {
                this.context.WaitOneUpdateAll(this.depth);

                var users = this.userGenerator.GetUsers();

                if (users.Length > 0)
                {
                    var firstUser = users[0];
                    if (this.skeletonCapbility.IsTracking(firstUser))
                    {
                        var rightHand  = this.GetJointPosition(firstUser, SkeletonJoint.RightHand);
                        var rightPoint =
                            new TimePoint()
                        {
                            X    = rightHand.position.X,
                            Y    = rightHand.position.Y,
                            Z    = rightHand.position.Z,
                            Time = DateTime.Now
                        };

                        this.rightSwipe.AddSwipePoint(rightPoint);
                        this.push.AddPushPoint(rightPoint);

                        var leftHand = this.GetJointPosition(firstUser, SkeletonJoint.LeftHand);

                        this.leftSwipe.AddSwipePoint(
                            new TimePoint()
                        {
                            X    = leftHand.position.X,
                            Y    = leftHand.position.Y,
                            Z    = leftHand.position.Z,
                            Time = DateTime.Now
                        });
                    }
                }
            }
        }
Ejemplo n.º 7
0
        bool AnalyzePoints(TimePoint[] points)
        {
            if (points[0].Time == DateTime.MinValue || points[last].Time == DateTime.MinValue)
                return false;

            float z1 = points[0].Z;
            float z2 = points[last].Z;

            if (Math.Abs(z1 - z2) < MinZDelta)
                return false;

            if (points[last].Time - points[0].Time > this.MaxTimeSpan)
                return false;

            return true;
        }
Ejemplo n.º 8
0
        public void Initialize()
        {
            if (!initialized)
            {
                LineSize = 7;
                MinZDelta = 70;
                last = LineSize - 1;
                MaxTimeSpan = TimeSpan.FromMilliseconds(300);

                points = new TimePoint[this.LineSize];
                for (int i = 0; i < this.LineSize; i++)
                    points[i] = new TimePoint();
                initialized = true;
            }
        }
Ejemplo n.º 9
0
        bool AnalyzePoints(TimePoint[] points)
        {
            if (points[0].Time == DateTime.MinValue || points[last].Time == DateTime.MinValue)
                return false;

            float x1 = points[0].X;
            float y1 = points[0].Y;
            float x2 = points[last].X;
            float y2 = points[last].Y;

            if (Math.Abs(x1 - x2) < MinXDelta)
                return false;

            if (y1 - y2 > MaxYDelta)
                return false;

            if (points[last].Time - points[0].Time > this.MaxTimeSpan)
                return false;

            for (int i = 1; i < LineSize - 2; i++)
            {
                if (Math.Abs((points[i].Y - y1)) > MaxYDelta)
                    return false;

                float result =
                    (y1 - y1) * points[i].X +
                    (x2 - x1) * points[i].Y +
                    (x1 * y2 - x2 * y1);

                if (result > Math.Abs(result))
                {
                    return false;
                }
            }
            return true;
        }