Ejemplo n.º 1
0
        private void UpdateCursor(Joint hand)
        {
            var   point = kinectSensor.MapSkeletonPointToDepth(hand.Position, kinectSensor.DepthStream.Format);
            float x     = point.X;
            float y     = point.Y;
            float z     = point.Depth;

            x = (float)(x * window.ActualWidth / kinectSensor.DepthStream.FrameWidth);
            y = (float)(y * window.ActualHeight / kinectSensor.DepthStream.FrameHeight);

            Point cursorPoint = new Point(x, y);

            HandleCursorEvents(cursorPoint, z);
            cursorAdorner.UpdateCursor(cursorPoint);
        }
Ejemplo n.º 2
0
        private void AnimateCursorAwayFromLockPosition(KinectCursorEventArgs e, CursorAdorner cursor, ref Point lockPoint, ref Point cursorPoint)
        {
            DoubleAnimation moveLeft = new DoubleAnimation(lockPoint.X, cursorPoint.X, new Duration(TimeSpan.FromMilliseconds(UnlockInterval)));

            Storyboard.SetTarget(moveLeft, cursor.CursorVisual);
            Storyboard.SetTargetProperty(moveLeft, new PropertyPath(Canvas.LeftProperty));
            DoubleAnimation moveTop = new DoubleAnimation(lockPoint.Y, cursorPoint.Y, new Duration(TimeSpan.FromMilliseconds(UnlockInterval)));

            Storyboard.SetTarget(moveTop, cursor.CursorVisual);
            Storyboard.SetTargetProperty(moveTop, new PropertyPath(Canvas.TopProperty));
            move = new Storyboard();
            move.Children.Add(moveTop);
            move.Children.Add(moveLeft);
            move.Completed += delegate
            {
                move.Stop(cursor);
                cursor.UpdateCursor(new Point(e.X, e.Y), false);
                this.RaiseEvent(new KinectCursorEventArgs(KinectCursorUnlockEvent, new Point(e.X, e.Y), e.Z)
                {
                    Cursor = e.Cursor
                });
            };
            move.Begin(cursor, true);
        }