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); }
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); }
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); }
protected override void OnKinectCursorMove(object sender, KinectCursorEventArgs e) { if (e.Z < handDepth - PushThreshold) { RaiseEvent(new RoutedEventArgs(ClickEvent)); } }
protected override void OnKinectCursorLeave(object sender, KinectCursorEventArgs e) { if (timerEnabled) { e.Cursor.StopCursorAnimation(); hoverTimer.Stop(); } }
protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e) { if (timerEnabled) { hoverTimer.Interval = TimeSpan.FromMilliseconds(HoverInterval); e.Cursor.AnimateCursor(HoverInterval); hoverTimer.Start(); } }
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); }
protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e) { handDepth = e.Z; }
protected virtual void OnKinectCursorMove(object sender, KinectCursorEventArgs e) { }
protected virtual void OnKinectCursorEnter(object sender, KinectCursorEventArgs e) { RaiseEvent(new RoutedEventArgs(ClickEvent)); }
private void Button_KinectCursorLeave(object sender, GestureTraceLibrary.KinectCursorEventArgs e) { var button = sender as GestureTraceLibrary.KinectButton; button.Background = new SolidColorBrush(Colors.CadetBlue); }
protected override void OnKinectCursorEnter(object sender, KinectCursorEventArgs e) { InitializeSwipe(); base.OnKinectCursorEnter(sender, e); }
private void kinectMgr_swipeDetected(object sender, KinectCursorEventArgs e) { DeInitializeSwipe(); RaiseEvent(new RoutedEventArgs(ClickEvent)); }
private void kinectMgr_swipeOutofBoundDetected(object sender, KinectCursorEventArgs e) { DeInitializeSwipe(); RaiseEvent(new KinectCursorEventArgs(SwipeOutOfBoundsEvent)); }