private void OnHandPointerLeave(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (!KinectRegion.GetIsPrimaryHandPointerOver(this))
     {
         VisualStateManager.GoToState(this, "Normal", true);
     }
 }
Example #2
0
        private void OnHandPointerGripRelease(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            this.lastGripReleaseTimeStamp = kinectHandPointerEventArgs.HandPointer.TimestampOfLastUpdate;

            if (this.Equals(kinectHandPointerEventArgs.HandPointer.Captured))
            {
                kinectHandPointerEventArgs.Handled = true;
                this.lastGripState = GripState.Released;
                this.DoTransformAnimations();

                if (this.scrollViewerInertiaScroller.AnimationState != AnimationState.Inertial)
                {
                    if (this.AttemptInertialScroll())
                    {
                        return;
                    }
                }

                if (this.scrollViewerInertiaScroller.SlowEnoughForSelection)
                {
                    kinectHandPointerEventArgs.HandPointer.Capture(null);
                }
            }

            gripStatus = "U";
        }
 private void OnHandPointerEnter(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (KinectRegion.GetIsPrimaryHandPointerOver(this))
     {
         VisualStateManager.GoToState(this, "MouseOver", true);
     }
 }
Example #4
0
        /// <summary>
        /// Sends the events and updates the attached properties having to do
        /// with this hand pointer being over any elements.
        /// </summary>
        /// <param name="handPointer">The hand pointer we are working with</param>
        /// <param name="primaryHandOfPrimaryUserChanged"> Did the primary hand of the primary user change </param>
        /// <param name="oldIntersectedElements">The list of elements this hand pointer used to intersect</param>
        private static void DoIntersectionNotifications(HandPointer handPointer, bool primaryHandOfPrimaryUserChanged, HashSet <UIElement> oldIntersectedElements)
        {
            var wasPrimaryHandOfPrimaryUser = primaryHandOfPrimaryUserChanged ? !handPointer.IsPrimaryHandOfPrimaryUser : handPointer.IsPrimaryHandOfPrimaryUser;

            // Leave any elements we aren't in any more
            foreach (var oldIntersectedElement in oldIntersectedElements)
            {
                if (!handPointer.EnteredElements.Contains(oldIntersectedElement))
                {
                    // We are no longer over this element.

                    // If we were or still are the HandPointer for the primary user's
                    // primary hand then clear out the attatched DP for this.
                    if (wasPrimaryHandOfPrimaryUser)
                    {
                        KinectRegion.SetIsPrimaryHandPointerOver(oldIntersectedElement, false);
                    }

                    // Tell this element that this hand pointer has left
                    var leaveArgs = new HandPointerEventArgs(handPointer, KinectRegion.HandPointerLeaveEvent, oldIntersectedElement);
                    oldIntersectedElement.RaiseEvent(leaveArgs);
                }
                else
                {
                    if (wasPrimaryHandOfPrimaryUser && !handPointer.IsPrimaryHandOfPrimaryUser)
                    {
                        // Hand pointer didn't leave the element but it is no longer the primary
                        KinectRegion.SetIsPrimaryHandPointerOver(oldIntersectedElement, false);
                    }
                }
            }

            // Enter any elements that we are now in
            foreach (var newEnteredElement in handPointer.EnteredElements)
            {
                if (!oldIntersectedElements.Contains(newEnteredElement))
                {
                    // Tell this element the hand pointer entered.

                    // Set the attached DP for this
                    if (handPointer.IsPrimaryHandOfPrimaryUser)
                    {
                        KinectRegion.SetIsPrimaryHandPointerOver(newEnteredElement, true);
                    }

                    // Send the routed event for this.
                    var enterArgs = new HandPointerEventArgs(handPointer, KinectRegion.HandPointerEnterEvent, newEnteredElement);
                    newEnteredElement.RaiseEvent(enterArgs);
                }
                else
                {
                    if (!wasPrimaryHandOfPrimaryUser && handPointer.IsPrimaryHandOfPrimaryUser)
                    {
                        // Hand pointer was already in this element but it became the primary
                        KinectRegion.SetIsPrimaryHandPointerOver(newEnteredElement, true);
                    }
                }
            }
        }
 private void OnHandPointerPress(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (this.capturedHandPointer == null && handPointerEventArgs.HandPointer.IsPrimaryUser && handPointerEventArgs.HandPointer.IsPrimaryHandOfUser)
     {
         handPointerEventArgs.HandPointer.Capture(this);
         handPointerEventArgs.Handled = true;
     }
 }
Example #6
0
 private void OnHandPointerGrip(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
 {
     if (kinectHandPointerEventArgs.HandPointer.IsPrimaryUser && kinectHandPointerEventArgs.HandPointer.IsPrimaryHandOfUser && kinectHandPointerEventArgs.HandPointer.IsInteractive)
     {
         this.HandleHandPointerGrip(kinectHandPointerEventArgs.HandPointer);
         kinectHandPointerEventArgs.Handled = true;
     }
 }
 private void OnHandPointerPress(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (this.capturedHandPointer == null && handPointerEventArgs.HandPointer.IsPrimaryUser && handPointerEventArgs.HandPointer.IsPrimaryHandOfUser)
     {
         handPointerEventArgs.HandPointer.Capture(this);
         handPointerEventArgs.Handled = true;
     }
 }
 private void OnHandPointerCaptured(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (this.capturedHandPointer == null)
     {
         this.capturedHandPointer = handPointerEventArgs.HandPointer;
         this.IsPressed = true;
         handPointerEventArgs.Handled = true;
     }
 }
 private void OnHandPointerCaptured(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (this.capturedHandPointer == null)
     {
         this.capturedHandPointer     = handPointerEventArgs.HandPointer;
         this.IsPressed               = true;
         handPointerEventArgs.Handled = true;
     }
 }
 private void OnHandPointerLostCapture(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (this.capturedHandPointer == handPointerEventArgs.HandPointer)
     {
         this.capturedHandPointer     = null;
         this.IsPressed               = false;
         handPointerEventArgs.Handled = true;
     }
 }
Example #11
0
 private void OnHandPointerLostCapture(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
 {
     if (this.capturedHandPointer == kinectHandPointerEventArgs.HandPointer)
     {
         this.capturedHandPointer = null;
         this.lastGripState       = GripState.Released;
         this.scrollMoveTimer.Start();
         kinectHandPointerEventArgs.Handled = true;
         this.DoTransformAnimations();
     }
 }
Example #12
0
 private void OnHandPointerEnter(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
 {
     if (kinectHandPointerEventArgs.HandPointer.IsPrimaryHandOfPrimaryUser)
     {
         kinectHandPointerEventArgs.Handled = true;
         if (this.grippedHandpointer == kinectHandPointerEventArgs.HandPointer)
         {
             this.HandleHandPointerGrip(kinectHandPointerEventArgs.HandPointer);
             this.grippedHandpointer = null;
         }
     }
 }
Example #13
0
        private void OnHandPointerCaptured(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            if (this.capturedHandPointer != null)
            {
                // Release capture on any previous captured handpointer
                this.capturedHandPointer.Capture(null);
            }

            this.capturedHandPointer           = kinectHandPointerEventArgs.HandPointer;
            kinectHandPointerEventArgs.Handled = true;
            this.SetScrollBarVisualState("GripScrolling");
            this.scrollMoveTimer.Stop();
        }
Example #14
0
        private void OnHandPointerPress(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            if (this.Equals(kinectHandPointerEventArgs.HandPointer.Captured))
            {
                kinectHandPointerEventArgs.Handled = true;

                if (this.scrollViewerInertiaScroller.AnimationState == AnimationState.Inertial && kinectHandPointerEventArgs.HandPointer.IsInteractive)
                {
                    // release capture on a press event if we're in the middle of inertial scrolling
                    kinectHandPointerEventArgs.HandPointer.Capture(null);
                    this.lastGripState = GripState.Released;
                    this.scrollViewerInertiaScroller.Stop();
                }
            }
        }
        private void OnHandPointerPressRelease(object sender, HandPointerEventArgs handPointerEventArgs)
        {
            if (this.capturedHandPointer == handPointerEventArgs.HandPointer)
            {
                bool isWithinReleaseArea = true;

                // Remember what we need since after we release capture,
                // this.capturedHandPointer will be null
                var point = handPointerEventArgs.HandPointer.GetPosition(this);

                // point is relative to upper left of control, translate to center
                point.X -= this.ActualWidth / 2;
                point.Y -= this.ActualHeight / 2;

                double regionWidth  = handPointerEventArgs.HandPointer.Owner.InteractionRootElement.ActualWidth;
                double regionHeight = handPointerEventArgs.HandPointer.Owner.InteractionRootElement.ActualHeight;

                // convert to screen space
                point.X /= regionWidth;
                point.Y /= regionHeight;

                handPointerEventArgs.HandPointer.Capture(null);

                if (point.Y < ReleaseYCutoff)
                {
                    isWithinReleaseArea = Math.Sqrt((point.X * point.X) + (point.Y * point.Y)) < ReleaseRadius;
                }

                if (isWithinReleaseArea)
                {
                    this.OnClick();
                    VisualStateManager.GoToState(this, "MouseOver", true);
                }
                else
                {
                    VisualStateManager.GoToState(this, "Normal", true);
                }

                handPointerEventArgs.Handled = true;
            }
        }
        private void OnHandPointerPress(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            if (this.Equals(kinectHandPointerEventArgs.HandPointer.Captured))
            {
                kinectHandPointerEventArgs.Handled = true;

                if (this.scrollViewerInertiaScroller.AnimationState == AnimationState.Inertial && kinectHandPointerEventArgs.HandPointer.IsInteractive)
                {
                    // release capture on a press event if we're in the middle of inertial scrolling
                    kinectHandPointerEventArgs.HandPointer.Capture(null);
                    this.lastGripState = GripState.Released;
                    this.scrollViewerInertiaScroller.Stop();
                }
            }
        }
 private void OnHandPointerLostCapture(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (this.capturedHandPointer == handPointerEventArgs.HandPointer)
     {
         this.capturedHandPointer = null;
         this.IsPressed = false;
         handPointerEventArgs.Handled = true;
     }
 }
 private void OngRripReleaseHandler(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     griped = 1;
 }
        private void OnPressHandler(object sender, HandPointerEventArgs handPointerEventArgs)
        {

            mouse_event(WM_RBUTTONDOWN, 0, 0, 0, 0);
            Thread.Sleep(50);
            mouse_event(WM_RBUTTONUP, 0, 0, 0, 0);
            Thread.Sleep(100);
        }
        /// <summary>
        /// Handles when the user releases the press on the on-screen shape.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected override void OnPressReleaseHandler(object sender, HandPointerEventArgs args)
        {
            this.isPressed = false;

            /* Change the button colour! */
            SetVisibleButtonUp();
            //this.onScreenShape.Fill = new SolidColorBrush(Colors.Green);

            /* Notify on the appropriate event. */
            ButtonReleased(sender, args);
        }
        private void OnHandPointerGrip(object sender, HandPointerEventArgs handPointerEventArgs)
        {

            var button = sender as KinectCircleButton;
            if (handPointerEventArgs.HandPointer.IsInGripInteraction == true)
            {
                int buttonContent;
                GripOverButton = true;
                KinectRegion.AddQueryInteractionStatusHandler(kinectRegion, OnQuery);
                KinectRegion.AddHandPointerGripReleaseHandler(kinectRegion, OnHandPointerGripRelase);

                var Tree = button.Parent as Canvas;
                Tree.Children.Remove(button);
                buttonContent = (int)button.Content;
                GripApple = myApple[buttonContent];
                Tree.Children.Remove(myApple[buttonContent].Figure);
                Treenum = GripApple.TreeNumber;
                handPointerEventArgs.Handled = true;
            }
        }
        private void OnHandPointerCaptured(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            if (this.capturedHandPointer != null)
            {
                // Release capture on any previous captured handpointer
                this.capturedHandPointer.Capture(null);
            }

            this.capturedHandPointer = kinectHandPointerEventArgs.HandPointer;
            kinectHandPointerEventArgs.Handled = true;
            this.SetScrollBarVisualState("GripScrolling");
            this.scrollMoveTimer.Stop();
        }
        private void OnHandPointerEnter(object sender, HandPointerEventArgs e)
        {
            if (!e.HandPointer.IsPrimaryHandOfUser || !e.HandPointer.IsPrimaryUser)
            {
                return;
            }

            this.activeHandpointer = e.HandPointer;
            this.IsHandPointerOver = true;
            this.repeatTimer.Start();
            ((MainWindow)System.Windows.Application.Current.MainWindow).glove.ActivateMotor(positivePins, valuesMax);
        }
Example #24
0
        private void OnHandPointerLeave(object sender, HandPointerEventArgs e)
        {
            if (this.activeHandpointer != e.HandPointer)
            {
                return;
            }

            this.activeHandpointer = null;
            this.IsHandPointerOver = false;
            this.repeatTimer.Stop();
        }
        private void OnHandPointerPressRelease(object sender, HandPointerEventArgs handPointerEventArgs)
        {
            if (this.capturedHandPointer == handPointerEventArgs.HandPointer)
            {
                bool isWithinReleaseArea = true;

                // Remember what we need since after we release capture,
                // this.capturedHandPointer will be null
                var point = handPointerEventArgs.HandPointer.GetPosition(this);

                // point is relative to upper left of control, translate to center
                point.X -= this.ActualWidth / 2;
                point.Y -= this.ActualHeight / 2;

                double regionWidth = handPointerEventArgs.HandPointer.Owner.InteractionRootElement.ActualWidth;
                double regionHeight = handPointerEventArgs.HandPointer.Owner.InteractionRootElement.ActualHeight;

                // convert to screen space
                point.X /= regionWidth;
                point.Y /= regionHeight;

                handPointerEventArgs.HandPointer.Capture(null);

                if (point.Y < ReleaseYCutoff)
                {
                    isWithinReleaseArea = Math.Sqrt((point.X * point.X) + (point.Y * point.Y)) < ReleaseRadius;
                }

                if (isWithinReleaseArea)
                {
                    this.OnClick();
                    VisualStateManager.GoToState(this, "MouseOver", true);
                }
                else
                {
                    VisualStateManager.GoToState(this, "Normal", true);
                }

                handPointerEventArgs.Handled = true;
            }
        }
        private void PressionKinect(object sender, HandPointerEventArgs args)
        {
            var x = args.HandPointer.GetPosition(CanvasCombat).X;
            var y = args.HandPointer.GetPosition(CanvasCombat).Y;
            GestionCombat.LancerSoinZone(x, y);

            var affichageTir = AfficherTir(x, y, 100, 100, 0.8, new SolidColorBrush(Colors.Fuchsia));

            var truc = new Thread(DetruireControleCanvas);
            truc.Start(affichageTir);
            Debug.WriteLine("Nouveau timer");
        }
 private void OnHandPointerLeave(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (!KinectRegion.GetIsPrimaryHandPointerOver(this))
     {
         VisualStateManager.GoToState(this, "Normal", true);
     }
 }
 private void OnHandPointerEnter(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     if (KinectRegion.GetIsPrimaryHandPointerOver(this))
     {
         VisualStateManager.GoToState(this, "MouseOver", true);
     }
 }
 private void OnHandPointerGrip(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
 {
     if (kinectHandPointerEventArgs.HandPointer.IsPrimaryUser && kinectHandPointerEventArgs.HandPointer.IsPrimaryHandOfUser && kinectHandPointerEventArgs.HandPointer.IsInteractive)
     {
         this.HandleHandPointerGrip(kinectHandPointerEventArgs.HandPointer);
         kinectHandPointerEventArgs.Handled = true;
     }
 }
 private void kinectRegion_HandPointerGripRelease(object sender, Microsoft.Kinect.Toolkit.Controls.HandPointerEventArgs e)
 {
     timer.Tick -= drawPoints;
     timer.Stop();
 }
        private void OnHandPointerGripRelease(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            this.lastGripReleaseTimeStamp = kinectHandPointerEventArgs.HandPointer.TimestampOfLastUpdate;

            if (this.Equals(kinectHandPointerEventArgs.HandPointer.Captured))
            {
                kinectHandPointerEventArgs.Handled = true;
                this.lastGripState = GripState.Released;
                this.DoTransformAnimations();

                if (this.scrollViewerInertiaScroller.AnimationState != AnimationState.Inertial)
                {
                    if (this.AttemptInertialScroll())
                    {
                        return;
                    }
                }

                if (this.scrollViewerInertiaScroller.SlowEnoughForSelection)
                {
                    kinectHandPointerEventArgs.HandPointer.Capture(null);
                }
            }
        }
 private void OnGripRelease(object sender, HandPointerEventArgs e)
 {
     e.HandPointer.Captured = null;
     if (_selectedLetterButton != null)
         _selectedLetterButton.Visibility = Visibility.Visible;
     MainCanvas.Children.Remove(_linkingLine);
     e.Handled = true;
 }
 private void OnHandPointerLostCapture(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
 {
     if (this.capturedHandPointer == kinectHandPointerEventArgs.HandPointer)
     {
         this.capturedHandPointer = null;
         this.lastGripState = GripState.Released;
         this.scrollMoveTimer.Start();
         kinectHandPointerEventArgs.Handled = true;
         this.DoTransformAnimations();
     }
 }
 private void OnGrip(object sender, HandPointerEventArgs e)
 {
     PopupPanel.Children.Clear();
     _selectedLetterButton = sender as KinectTileButton;
     if (_selectedLetterButton == null) 
         return;
     _selectedLetter = _selectedLetterButton.Tag as Letter;
     if (!e.HandPointer.IsInGripInteraction || !e.HandPointer.Capture(MainCanvas)) 
         return;
     var point = e.HandPointer.GetPosition(MainCanvas);
     _linkingLine = new Line
     {
         X1 = point.X,
         X2 = point.X,
         Y1 = point.Y,
         Y2 = point.Y,
         Stroke = new SolidColorBrush(Colors.Red),
         StrokeThickness = 10
     };
     MainCanvas.Children.Add(_linkingLine);
     e.Handled = true;
 }
        private void OnHandPointerGripRelase(object sender, HandPointerEventArgs handPointerEventArgs)
        {
            if (handPointerEventArgs.HandPointer.IsInGripInteraction == false && GripOverButton == true)
            {
                bool check = false;
                Point point = handPointerEventArgs.HandPointer.GetPosition(playfield);
                for (int i = 0; i < basketCount; i++)
                {
                    if ((point.X >= basket[i].Position.X)
                        && (point.X <= basket[i].EndPosition.X)
                        && (point.Y >= basket[i].Position.Y)
                        && (point.Y <= basket[i].EndPosition.Y))
                    {
                        if (GripApple.Color == basket[i].Color)
                        {
                            handPointerEventArgs.Handled = true;
                            gameScore.collectSuccess();
                            check = true;
                            if (gameScore.ApplesLeft == 0)
                            {
                                this.EndGame();
                            }
                        }
                    }
                }

                if (!check)
                {
                    handPointerEventArgs.Handled = true;
                    gameScore.collectFail();
                    check = false;
                    Apple MovingApple = new Apple(GripApple, point.X, point.Y);
                    playfield.Children.Add(MovingApple.Figure);
                    MoveTo(MovingApple, GripApple.Pos.X, GripApple.Pos.Y, point.X, point.Y);
                    KinectRegion.AddQueryInteractionStatusHandler(MovingApple.Figure, OnQuery);
                    KinectRegion.AddHandPointerGripHandler(MovingApple.Figure, OnHandPointerGrip);
                    handPointerEventArgs.Handled = true;
                }
            }
            GripOverButton = false;
        }
        private void OnHandPointerEnter(object sender, HandPointerEventArgs e)
        {
            if (_selectedLetterButton == null || _selectedLetter == null) 
                return;
            var letterButton = sender as KinectTileButton;
            if (letterButton == null) 
                return;

            var letter = letterButton.Tag as Letter;
            var position = e.HandPointer.GetPosition(MainCanvas);

            if (letter != null && (!Equals(_selectedLetterButton, letterButton) && _selectedLetter.SmallLetter == letter.SmallLetter))
            {
                _selectedLetter = null;
                _linkingLine.X2 = position.X;
                _linkingLine.Y2 = position.Y;
                _linkingLine.Stroke = new SolidColorBrush(Colors.Green);
                        
                _selectedLetterButton.IsEnabled = false;
                letterButton.IsEnabled = false;
                _selectedLetterButton.Foreground = new SolidColorBrush(Colors.Green);
                letterButton.Foreground = new SolidColorBrush(Colors.Green);
                NotifySuccess();
            }
            else
            {
                _selectedLetter = null;
                MainCanvas.Children.Remove(_linkingLine);
                NotifyFail();
            }
            _linkingLine = null;
            e.Handled = true;
        }
 private void OnPressRelaaseHandler(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     /*** ***/
 }
 private void OnHandPointerEnter(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
 {
     if (kinectHandPointerEventArgs.HandPointer.IsPrimaryHandOfPrimaryUser)
     {
         kinectHandPointerEventArgs.Handled = true;
         if (this.grippedHandpointer == kinectHandPointerEventArgs.HandPointer)
         {
             this.HandleHandPointerGrip(kinectHandPointerEventArgs.HandPointer);
             this.grippedHandpointer = null;
         }
     }
 }
        private void OnMoveHandler(object sender, HandPointerEventArgs handPointerEventArgs)
        {
            if (griped == 0)
            {
                mouse_event(WM_LBUTTONDOWN, 0, 0, 0, 0);
            }
            else if (griped == 1)
            {
                mouse_event(WM_LBUTTONUP, 0, 0, 0, 0);

                griped = -1;
            }

            var xPosition = handPointerEventArgs.HandPointer.GetPosition(this.ZonaCursor).X;
            var yPosition = handPointerEventArgs.HandPointer.GetPosition(this.ZonaCursor).Y;
           Console.WriteLine("x :" + xPosition + "y" + yPosition);
            SetCursorPos((int)xPosition, (int)yPosition);


        }
        private void OnHandPointerMove(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            if (this.Equals(kinectHandPointerEventArgs.HandPointer.Captured))
            {
                kinectHandPointerEventArgs.Handled = true;

                var currentPosition = kinectHandPointerEventArgs.HandPointer.GetPosition(this);

                this.sampleTracker.AddSample(currentPosition.X, currentPosition.Y, kinectHandPointerEventArgs.HandPointer.TimestampOfLastUpdate);
                this.lastTimeStamp = kinectHandPointerEventArgs.HandPointer.TimestampOfLastUpdate;
                if (this.lastGripState == GripState.Released)
                {
                    return;
                }

                if (this.scrollViewerInertiaScroller.AnimationState == AnimationState.Inertial)
                {
                    this.scrollViewerInertiaScroller.Stop();
                }

                if (!kinectHandPointerEventArgs.HandPointer.IsInteractive)
                {
                    if (this.AttemptInertialScroll())
                    {
                        this.lastGripState = GripState.Released;
                        return;                       
                    }
                }
                
                var diffVector = this.gripPoint - currentPosition;

                var horizontalScaleOrigin = 0.0;
                var verticalScaleOrigin = 0.0;
                this.horizontalScale = 1.0;
                this.verticalScale = 1.0;
                this.horizontalTranslation = 0.0;
                this.verticalTranslation = 0.0;
                const double EaseFactor = 1.0 / HorizontalTranslationMax;

                if (this.HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    var scrollOffset = diffVector.X + this.startingScrollOffset.X;
                    this.ScrollToHorizontalOffset(scrollOffset);

                    if (scrollOffset < 0)
                    {
                        var easedOutTranslation = Math.Tanh(-scrollOffset * EaseFactor) * HorizontalTranslationMax;
                        horizontalScaleOrigin = this.ActualWidth;
                        this.horizontalTranslation = easedOutTranslation;
                    }
                    else if (scrollOffset > this.ScrollableWidth)
                    {
                        var easedOutTranslation = Math.Tanh((this.ScrollableWidth - scrollOffset) * EaseFactor) * HorizontalTranslationMax;
                        this.horizontalTranslation = easedOutTranslation;
                    }

                    if (Math.Abs(this.horizontalTranslation) > double.Epsilon)
                    {
                        this.horizontalScale = 1.0 - (HorizontalScaleDownMax * (Math.Abs(this.horizontalTranslation) / HorizontalTranslationMax));
                    }
                }

                if (this.VerticalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    var scrollOffset = diffVector.Y + this.startingScrollOffset.Y;
                    this.ScrollToVerticalOffset(scrollOffset);
                    if (scrollOffset < 0)
                    {
                        this.verticalTranslation = Math.Min(-scrollOffset, VerticalTranslationMax);
                        verticalScaleOrigin = this.ActualHeight;
                    }
                    else if (scrollOffset > this.ScrollableHeight)
                    {
                        this.verticalTranslation = Math.Max(this.ScrollableHeight - scrollOffset, -VerticalTranslationMax);
                    }

                    if (Math.Abs(this.verticalTranslation) > double.Epsilon)
                    {
                        this.verticalScale = 1.0 - (VerticalScaleDownMax * (Math.Abs(this.verticalTranslation) / VerticalTranslationMax));
                    }
                }

                if (this.scrollContentPresenter != null)
                {
                    if (this.HasTransform())
                    {
                        var transformGroup = new TransformGroup();
                        this.translateTransform = new TranslateTransform(this.horizontalTranslation, this.verticalTranslation);
                        this.scaleTransform = new ScaleTransform(
                            this.horizontalScale, this.verticalScale, horizontalScaleOrigin, verticalScaleOrigin);
                        transformGroup.Children.Add(this.translateTransform);
                        transformGroup.Children.Add(this.scaleTransform);
                        this.scrollContentPresenter.RenderTransform = transformGroup;
                    }
                    else
                    {
                        this.scrollContentPresenter.RenderTransform = Transform.Identity;
                    }
                }
            }
        }
 private void OnHandGripHandler(object sender, HandPointerEventArgs handPointerEventArgs)
 {
     griped = 0;
 }
 /// <summary>
 /// Handle when the object is pressed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 protected override void OnPressHandler(object sender, HandPointerEventArgs args)
 {
 }
Example #43
0
        private void OnHandPointerEnter(object sender, HandPointerEventArgs e)
        {
            if (!e.HandPointer.IsPrimaryHandOfUser || !e.HandPointer.IsPrimaryUser)
            {
                return;
            }

            this.activeHandpointer = e.HandPointer;
            this.IsHandPointerOver = true;
            this.repeatTimer.Start();
        }
Example #44
0
        private void OnHandPointerMove(object sender, HandPointerEventArgs kinectHandPointerEventArgs)
        {
            if (this.Equals(kinectHandPointerEventArgs.HandPointer.Captured))
            {
                kinectHandPointerEventArgs.Handled = true;

                var currentPosition = kinectHandPointerEventArgs.HandPointer.GetPosition(this);

                this.sampleTracker.AddSample(currentPosition.X, currentPosition.Y, kinectHandPointerEventArgs.HandPointer.TimestampOfLastUpdate);
                this.lastTimeStamp = kinectHandPointerEventArgs.HandPointer.TimestampOfLastUpdate;
                if (this.lastGripState == GripState.Released)
                {
                    return;
                }

                if (this.scrollViewerInertiaScroller.AnimationState == AnimationState.Inertial)
                {
                    this.scrollViewerInertiaScroller.Stop();
                }

                if (!kinectHandPointerEventArgs.HandPointer.IsInteractive)
                {
                    if (this.AttemptInertialScroll())
                    {
                        this.lastGripState = GripState.Released;
                        return;
                    }
                }

                var diffVector = this.gripPoint - currentPosition;

                var horizontalScaleOrigin = 0.0;
                var verticalScaleOrigin   = 0.0;
                this.horizontalScale       = 1.0;
                this.verticalScale         = 1.0;
                this.horizontalTranslation = 0.0;
                this.verticalTranslation   = 0.0;
                const double EaseFactor = 1.0 / HorizontalTranslationMax;

                if (this.HorizontalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    var scrollOffset = diffVector.X + this.startingScrollOffset.X;
                    this.ScrollToHorizontalOffset(scrollOffset);

                    if (scrollOffset < 0)
                    {
                        var easedOutTranslation = Math.Tanh(-scrollOffset * EaseFactor) * HorizontalTranslationMax;
                        horizontalScaleOrigin      = this.ActualWidth;
                        this.horizontalTranslation = easedOutTranslation;
                    }
                    else if (scrollOffset > this.ScrollableWidth)
                    {
                        var easedOutTranslation = Math.Tanh((this.ScrollableWidth - scrollOffset) * EaseFactor) * HorizontalTranslationMax;
                        this.horizontalTranslation = easedOutTranslation;
                    }

                    if (Math.Abs(this.horizontalTranslation) > double.Epsilon)
                    {
                        this.horizontalScale = 1.0 - (HorizontalScaleDownMax * (Math.Abs(this.horizontalTranslation) / HorizontalTranslationMax));
                    }
                }

                if (this.VerticalScrollBarVisibility != ScrollBarVisibility.Disabled)
                {
                    var scrollOffset = diffVector.Y + this.startingScrollOffset.Y;
                    this.ScrollToVerticalOffset(scrollOffset);
                    if (scrollOffset < 0)
                    {
                        this.verticalTranslation = Math.Min(-scrollOffset, VerticalTranslationMax);
                        verticalScaleOrigin      = this.ActualHeight;
                    }
                    else if (scrollOffset > this.ScrollableHeight)
                    {
                        this.verticalTranslation = Math.Max(this.ScrollableHeight - scrollOffset, -VerticalTranslationMax);
                    }

                    if (Math.Abs(this.verticalTranslation) > double.Epsilon)
                    {
                        this.verticalScale = 1.0 - (VerticalScaleDownMax * (Math.Abs(this.verticalTranslation) / VerticalTranslationMax));
                    }
                }

                if (this.scrollContentPresenter != null)
                {
                    if (this.HasTransform())
                    {
                        var transformGroup = new TransformGroup();
                        this.translateTransform = new TranslateTransform(this.horizontalTranslation, this.verticalTranslation);
                        this.scaleTransform     = new ScaleTransform(
                            this.horizontalScale, this.verticalScale, horizontalScaleOrigin, verticalScaleOrigin);
                        transformGroup.Children.Add(this.translateTransform);
                        transformGroup.Children.Add(this.scaleTransform);
                        this.scrollContentPresenter.RenderTransform = transformGroup;
                    }
                    else
                    {
                        this.scrollContentPresenter.RenderTransform = Transform.Identity;
                    }
                }
            }
        }
        private void OnHandPointerLeave(object sender, HandPointerEventArgs e)
        {
            if (this.activeHandpointer != e.HandPointer)
            {
                return;
            }

            this.activeHandpointer = null;
            this.IsHandPointerOver = false;
            this.repeatTimer.Stop();

            ((MainWindow)System.Windows.Application.Current.MainWindow).glove.ActivateMotor(positivePins, valuesMinium);
        }
 private void kinectRegion_HandPointerGrip(object sender, Microsoft.Kinect.Toolkit.Controls.HandPointerEventArgs e)
 {
     timer.Tick    += new EventHandler(drawPoints);
     timer.Interval = 41;
     timer.Start();
 }