Пример #1
0
 protected override void OnKinectCursorMove(object sender, KinectCursorEventArgs e)
 {
     if (e.Z < handDepth - PushThreshold)
     {
         RaiseEvent(new RoutedEventArgs(ClickEvent));
     }
 }
Пример #2
0
        protected override void OnKinectCursorLeave(object sender, KinectCursorEventArgs e)
        {
            if (this.Opacity == 0)
            {
                return;
            }
            base.OnKinectCursorLeave(sender, e);
            if (!isLockOn)
            {
                return;
            }
            e.Cursor.UpdateCursor(new Point(e.X, e.Y), false);

            var rootVisual = FindAncestor <Window>(this);
            var point      = this.TransformToAncestor(rootVisual).Transform(new Point(0, 0));

            var x = point.X + this.ActualWidth / 2;
            var y = point.Y + this.ActualHeight / 2;

            var cursor = e.Cursor;

            //找到目的位置
            Point lockPoint = new Point(x - cursor.CursorVisual.ActualWidth / 2, y - cursor.CursorVisual.ActualHeight / 2);
            //当前位置
            Point cursorPoint = new Point(e.X - cursor.CursorVisual.ActualWidth / 2, e.Y - cursor.CursorVisual.ActualHeight / 2);

            AnimateCursorAwayFromLockPosition(e, cursor, ref lockPoint, ref cursorPoint);
        }
Пример #3
0
        protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
        {
            if (this.Opacity == 0)
            {
                return;
            }
            if (!this.isLockOn)
            {
                return;
            }

            //获取按钮位置
            var rootVisual = FindAncestor <Window>(this);
            var point      = this.TransformToAncestor(rootVisual).Transform(new Point(0, 0));

            var x = point.X + this.ActualWidth / 2;
            var y = point.Y + this.ActualHeight / 2;

            var cursor = e.Cursor;

            cursor.UpdateCursor(new Point(e.X, e.Y), true);

            //找到目的位置
            Point lockPoint = new Point(x - cursor.CursorVisual.ActualWidth / 2, y - cursor.CursorVisual.ActualHeight / 2);
            //当前位置
            Point cursorPoint = new Point(e.X - cursor.CursorVisual.ActualWidth / 2, e.Y - cursor.CursorVisual.ActualHeight / 2);

            //将光标从当前位置传送到目的位置
            AnimateCursorToLockPosition(e, x, y, cursor, ref lockPoint, ref cursorPoint);
            base.OnKinectCursorEnter(sender, e);
        }
Пример #4
0
        private void AnimateCursorToLockPosition(KinectCursorEventArgs e, double x, double y, CursorAdorner cursor, ref Point lockPoint, ref Point cursorPoint)
        {
            DoubleAnimation moveLeft = new DoubleAnimation(cursorPoint.X, lockPoint.X, new Duration(TimeSpan.FromMilliseconds(LockInterval)));

            Storyboard.SetTarget(moveLeft, cursor.CursorVisual);
            Storyboard.SetTargetProperty(moveLeft, new PropertyPath(Canvas.LeftProperty));

            DoubleAnimation moveTop = new DoubleAnimation(cursorPoint.Y, lockPoint.Y, new Duration(TimeSpan.FromMilliseconds(LockInterval)));

            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
            {
                this.RaiseEvent(new KinectCursorEventArgs(KinectCursorLockEvent, new Point(x, y), e.Z)
                {
                    Cursor = e.Cursor
                });
            };
            if (move != null)
            {
                move.Stop(e.Cursor);
            }
            move.Begin(cursor, false);
        }
Пример #5
0
 protected override void OnKinectCursorLeave(object sender, KinectCursorEventArgs e)
 {
     if (timerEnabled)
     {
         e.Cursor.StopCursorAnimation();
         hoverTimer.Stop();
     }
 }
Пример #6
0
 protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     if (timerEnabled)
     {
         hoverTimer.Interval = TimeSpan.FromMilliseconds(HoverInterval);
         e.Cursor.AnimateCursor(HoverInterval);
         hoverTimer.Start();
     }
 }
Пример #7
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);
        }
Пример #8
0
 protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     handDepth = e.Z;
 }
Пример #9
0
 protected virtual void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     RaiseEvent(new RoutedEventArgs(ClickEvent));
 }
Пример #10
0
 protected virtual void OnKinectCursorLeave(object sender, KinectCursorEventArgs e)
 {
 }
Пример #11
0
 protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     InitializeSwipe();
     base.OnKinectCursorEnter(sender, e);
 }
Пример #12
0
 void KinectMgr_swipeDetected(object sender, KinectCursorEventArgs e)
 {
     DeInitializeSwipe();
     RaiseEvent(new RoutedEventArgs(ClickEvent));
 }
Пример #13
0
 void KinectMgr_swipeOutofBoundDetected(object sender, KinectCursorEventArgs e)
 {
     DeInitializeSwipe();
     RaiseEvent(new KinectCursorEventArgs(SwipeOutOfBoundsEvent));
 }