Пример #1
0
 private void OnQueryInteractionStatus(object sender, QueryInteractionStatusEventArgs queryInteractionStatusEventArgs)
 {
     if (this.Equals(queryInteractionStatusEventArgs.HandPointer.Captured))
     {
         queryInteractionStatusEventArgs.IsInGripInteraction = this.lastGripState == GripState.Gripped;
         queryInteractionStatusEventArgs.Handled             = true;
     }
 }
Пример #2
0
        private void OnQuery(object sender, QueryInteractionStatusEventArgs handPointerEventArgs)
        {

            //If a grip detected change the cursor image to grip
            if (handPointerEventArgs.HandPointer.HandEventType == HandEventType.Grip)
            {
                isGripinInteraction = true;
                handPointerEventArgs.IsInGripInteraction = true;
            }

           //If Grip Release detected change the cursor image to open
            else if (handPointerEventArgs.HandPointer.HandEventType == HandEventType.GripRelease)
            {
                isGripinInteraction = false;
                handPointerEventArgs.IsInGripInteraction = false;
            }

            //If no change in state do not change the cursor
            else if (handPointerEventArgs.HandPointer.HandEventType == HandEventType.None)
            {
                handPointerEventArgs.IsInGripInteraction = isGripinInteraction;
            }

            handPointerEventArgs.Handled = true;
        }
 private void OnQueryInteractionStatus(object sender, QueryInteractionStatusEventArgs queryInteractionStatusEventArgs)
 {
     if (this.Equals(queryInteractionStatusEventArgs.HandPointer.Captured))
     {
         queryInteractionStatusEventArgs.IsInGripInteraction = this.lastGripState == GripState.Gripped;
         queryInteractionStatusEventArgs.Handled = true;
     }
 }
Пример #4
0
        private void HandleHandPointerChanges(
            HandPointer handPointer, bool pressedChanged, bool positionChanged, bool primaryHandOfPrimaryUserChanged, bool removed)
        {
            bool doPress = false;
            bool doRelease = false;
            bool doMove = false;
            bool doLostCapture = false;
            bool doGrip = false;
            bool doGripRelease = false;

            if (removed)
            {
                // Deny the existence of this hand pointer
                doRelease = handPointer.IsPressed;
                doLostCapture = handPointer.Captured != null;
            }
            else
            {
                if (pressedChanged)
                {
                    doPress = handPointer.IsPressed;
                    doRelease = !handPointer.IsPressed;
                }

                if (positionChanged)
                {
                    doMove = true;
                }

                doGrip = handPointer.HandEventType == HandEventType.Grip;
                doGripRelease = handPointer.HandEventType == HandEventType.GripRelease;
            }

            if (doLostCapture)
            {
                SwitchCapture(handPointer, handPointer.Captured, null);
            }

            var targetElement = handPointer.Captured;
            if (targetElement == null)
            {
                var position = handPointer.GetPosition(this.InteractionRootElement);
                targetElement = this.HitTest(position);
            }

            // Update internal enter/leave state
            HashSet<UIElement> oldIntersectingElements;
            this.UpdateIntersections(handPointer, removed ? null : targetElement, out oldIntersectingElements);

            // See if this hand pointer is participating in a grip-initiated
            // interaction.
            var newIsInGripInteraction = false;
            if (targetElement != null)
            {
                var args = new QueryInteractionStatusEventArgs(handPointer, this.InteractionRootElement);
                targetElement.RaiseEvent(args);

                if (args.Handled && args.IsInGripInteraction)
                {
                    newIsInGripInteraction = true;
                }
            }

            handPointer.IsInGripInteraction = newIsInGripInteraction;

            //// After this point there should be no more changes to the internal
            //// state of the handPointers.  We don't want event handlers calling us
            //// when our internal state is inconsistent.

            DoIntersectionNotifications(handPointer, primaryHandOfPrimaryUserChanged, oldIntersectingElements);

            if (targetElement == null)
            {
                return;
            }

            if (doGrip)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerGripEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doGripRelease)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerGripReleaseEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doPress)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerPressEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doMove)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerMoveEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doRelease)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerPressReleaseEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }
        }
Пример #5
0
        private void HandleHandPointerChanges(
            HandPointer handPointer, bool pressedChanged, bool positionChanged, bool primaryHandOfPrimaryUserChanged, bool removed)
        {
            bool doPress       = false;
            bool doRelease     = false;
            bool doMove        = false;
            bool doLostCapture = false;
            bool doGrip        = false;
            bool doGripRelease = false;

            // bool doSwipe = false;

            if (removed)
            {
                // Deny the existence of this hand pointer
                doRelease     = handPointer.IsPressed;
                doLostCapture = handPointer.Captured != null;
            }
            else
            {
                if (pressedChanged)
                {
                    doPress   = handPointer.IsPressed;
                    doRelease = !handPointer.IsPressed;
                }

                if (positionChanged)
                {
                    doMove = true;
                }

                doGrip        = handPointer.HandEventType == HandEventType.Grip;
                doGripRelease = handPointer.HandEventType == HandEventType.GripRelease;
            }

            if (doLostCapture)
            {
                SwitchCapture(handPointer, handPointer.Captured, null);
            }

            var targetElement = handPointer.Captured;

            if (targetElement == null)
            {
                var position = handPointer.GetPosition(this.InteractionRootElement);
                targetElement = this.HitTest(position);
            }

            // Update internal enter/leave state
            HashSet <UIElement> oldIntersectingElements;

            this.UpdateIntersections(handPointer, removed ? null : targetElement, out oldIntersectingElements);

            // See if this hand pointer is participating in a grip-initiated
            // interaction.
            var newIsInGripInteraction = false;

            if (targetElement != null)
            {
                var args = new QueryInteractionStatusEventArgs(handPointer, this.InteractionRootElement);
                targetElement.RaiseEvent(args);

                if (args.Handled && args.IsInGripInteraction)
                {
                    newIsInGripInteraction = true;
                }
            }

            handPointer.IsInGripInteraction = newIsInGripInteraction;

            //// After this point there should be no more changes to the internal
            //// state of the handPointers.  We don't want event handlers calling us
            //// when our internal state is inconsistent.

            DoIntersectionNotifications(handPointer, primaryHandOfPrimaryUserChanged, oldIntersectingElements);

            if (targetElement == null)
            {
                return;
            }

            if (doGrip)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerGripEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doGripRelease)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerGripReleaseEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doPress)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerPressEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doMove)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerMoveEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }

            if (doRelease)
            {
                var args = CreateEventArgs(KinectRegion.HandPointerPressReleaseEvent, targetElement, handPointer);
                targetElement.RaiseEvent(args);
            }
        }
Пример #6
0
 private void OnQuery(object sender, QueryInteractionStatusEventArgs e)
 {
     switch (e.HandPointer.HandEventType)
     {
         case HandEventType.Grip:
             _isInGripInteraction = true;
             e.IsInGripInteraction = true;
             break;
         case HandEventType.GripRelease:
             _isInGripInteraction = false;
             e.IsInGripInteraction = false;
             break;
         case HandEventType.None:
             e.IsInGripInteraction = _isInGripInteraction;
             break;
     }
     e.Handled = true;
 }