Exemplo n.º 1
0
        protected override void OnKinectCursorLeave(object sender, KinectCursorEventArgs e)
        {
            if (this.Opacity == 0)
            {
                return;
            }
            if (!isLockOn)
            {
                return;
            }
            base.OnKinectCursorLeave(sender, e);

            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;

            //Find the aim position
            Point lockPoint = new Point(x - cursor.CursorVisual.ActualWidth / 2, y - cursor.CursorVisual.ActualHeight / 2);
            //Current position
            Point cursorPoint = new Point(e.X - cursor.CursorVisual.ActualWidth / 2, e.Y - cursor.CursorVisual.ActualHeight / 2);

            AnimateCursorAwayFromLockPosition(e, cursor, ref lockPoint, ref cursorPoint);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
        {
            if (this.Opacity == 0)
            {
                return;
            }
            if (!this.isLockOn)
            {
                return;
            }

            base.OnKinectCursorEnter(sender, e);

            //Get the position of the button
            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);

            //Find the aim position
            Point lockPoint = new Point(x - cursor.CursorVisual.ActualWidth / 2, y - cursor.CursorVisual.ActualHeight / 2);
            //Current position
            Point cursorPoint = new Point(e.X - cursor.CursorVisual.ActualWidth / 2, e.Y - cursor.CursorVisual.ActualHeight / 2);

            //Put the cursor on the aim position
            AnimateCursorToLockPosition(e, x, y, cursor, ref lockPoint, ref cursorPoint);
        }
Exemplo n.º 4
0
 protected override void OnKinectCursorMove(object sender, KinectCursorEventArgs e)
 {
     if (e.Z < handDepth - PushThreshold)
     {
         RaiseEvent(new RoutedEventArgs(ClickEvent));
     }
 }
Exemplo n.º 5
0
 protected override void OnKinectCursorLeave(object sender, KinectCursorEventArgs e)
 {
     if (timerEnabled)
     {
         e.Cursor.StopCursorAnimation();
         hoverTimer.Stop();
     }
 }
Exemplo n.º 6
0
 protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     if (timerEnabled)
     {
         hoverTimer.Interval = TimeSpan.FromMilliseconds(HoverInterval);
         e.Cursor.AnimateCursor(HoverInterval);
         hoverTimer.Start();
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 8
0
 protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     handDepth = e.Z;
 }
Exemplo n.º 9
0
 protected virtual void OnKinectCursorMove(object sender, KinectCursorEventArgs e)
 {
 }
Exemplo n.º 10
0
 protected virtual void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     RaiseEvent(new RoutedEventArgs(ClickEvent));
 }
Exemplo n.º 11
0
        private void Button_KinectCursorLeave(object sender, GestureTraceLibrary.KinectCursorEventArgs e)
        {
            var button = sender as GestureTraceLibrary.KinectButton;

            button.Background = new SolidColorBrush(Colors.CadetBlue);
        }
Exemplo n.º 12
0
 protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e)
 {
     InitializeSwipe();
     base.OnKinectCursorEnter(sender, e);
 }
Exemplo n.º 13
0
 private void kinectMgr_swipeDetected(object sender, KinectCursorEventArgs e)
 {
     DeInitializeSwipe();
     RaiseEvent(new RoutedEventArgs(ClickEvent));
 }
Exemplo n.º 14
0
 private void kinectMgr_swipeOutofBoundDetected(object sender, KinectCursorEventArgs e)
 {
     DeInitializeSwipe();
     RaiseEvent(new KinectCursorEventArgs(SwipeOutOfBoundsEvent));
 }