/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; // Map coordinates from [0.0,1.0] coordinates to UI-relative coordinates double xUI = x * Constants.InteractionRegionWidth; double yUI = y * Constants.InteractionRegionHeight; var uiElement = this.PerformHitTest(xUI, yUI); if (uiElement != null) { interactionInfo.IsPressTarget = true; // If UI framework uses strings as button IDs, use string hash code as ID interactionInfo.PressTargetControlId = uiElement.Id.GetHashCode(); // Designate center of button to be the press attraction point //// TODO: Create your own logic to assign press attraction points if center //// TODO: is not always the desired attraction point. interactionInfo.PressAttractionPointX = ((uiElement.Left + uiElement.Right) / 2.0) / Constants.InteractionRegionWidth; interactionInfo.PressAttractionPointY = ((uiElement.Top + uiElement.Bottom) / 2.0) / Constants.InteractionRegionHeight; } return interactionInfo; }
/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; // Map coordinates from [0.0,1.0] coordinates to UI-relative coordinates double xUI = x * Constants.InteractionRegionWidth; double yUI = y * Constants.InteractionRegionHeight; var uiElement = this.PerformHitTest(xUI, yUI); if (uiElement != null) { interactionInfo.IsPressTarget = true; // If UI framework uses strings as button IDs, use string hash code as ID interactionInfo.PressTargetControlId = uiElement.Id.GetHashCode(); // Designate center of button to be the press attraction point //// TODO: Create your own logic to assign press attraction points if center //// TODO: is not always the desired attraction point. interactionInfo.PressAttractionPointX = ((uiElement.Left + uiElement.Right) / 2.0) / Constants.InteractionRegionWidth; interactionInfo.PressAttractionPointY = ((uiElement.Top + uiElement.Bottom) / 2.0) / Constants.InteractionRegionHeight; } return(interactionInfo); }
public void handleHandMovement(InteractionHandPointer hand) { if (handMoved == null) { return; } currentHandType = hand.HandType; //handle horizontal hand movement if (Math.Abs(hand.X - prevMoveLocation.X) > horizontalSensitivity) { double speed = horizontalSensitivity / DateTime.Now.Subtract(lastHMoveTime).Milliseconds; lastHMoveTime = DateTime.UtcNow; HandMovedDirection dir = (hand.X - prevMoveLocation.X) > 0 ? HandMovedDirection.right : HandMovedDirection.left; var e = new HandMovedEventArgs(dir, MovementType.grip, hand.HandType, new Point(hand.X, hand.Y), speed); handMoved(this, e); prevMoveLocation = new Point(hand.X, hand.Y); } //handle vertical hand movement if (Math.Abs(hand.Y - prevMoveLocation.Y) > verticalSensitivity) { double speed = verticalSensitivity / DateTime.Now.Subtract(lastVMoveTime).Milliseconds; lastVMoveTime = DateTime.UtcNow; HandMovedDirection dir = (hand.Y - prevMoveLocation.Y) > 0 ? HandMovedDirection.down : HandMovedDirection.up; var e = new HandMovedEventArgs(dir, MovementType.grip, hand.HandType, new Point(hand.X, hand.Y), speed); handMoved(this, e); prevMoveLocation = new Point(hand.X, hand.Y); } }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo info = new InteractionInfo(); info.IsGripTarget = true; return info; }
public HandMovedEventArgs(HandMovedDirection dir, MovementType _movementType, InteractionHandType _handType, Point _location, double _speed) { direction = dir; movementType = _movementType; handType = _handType; location = _location; speed = _speed; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo intInfo = new InteractionInfo(); intInfo.IsGripTarget = true; intInfo.IsPressTarget = false; return(intInfo); }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = true, IsGripTarget = true }; return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo result = new InteractionInfo(); result.IsGripTarget = true; result.IsPressTarget = true; result.PressAttractionPointX = 0.5; result.PressAttractionPointY = 0.5; result.PressTargetControlId = 1; return result; }
/// <summary> /// Constructor /// </summary> /// <param name="type">Hand typer</param> /// <param name="tracked">Hand is active or not</param> /// <param name="position">Hand position</param> public HandData(InteractionHandType type) { HandType = type; m_IsActive = false; m_IsPrimaryHand = false; m_IsGrip = false; m_HandRawPosition = new PointF(); m_HandScreenPosition = new PointF(); }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo result = new InteractionInfo(); result.IsGripTarget = true; result.IsPressTarget = true; result.PressAttractionPointX = 0.5; result.PressAttractionPointY = 0.5; result.PressTargetControlId = 1; return(result); }
/// <summary> /// Evènement : si on a les informations de profondeur et du squelette -> définit l'état actuel de la main /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EventInteractionFrameReady(object sender, InteractionFrameReadyEventArgs e) { UserInfo[] userInfos = new UserInfo[InteractionFrame.UserInfoArrayLength]; using (InteractionFrame interactionFrame = e.OpenInteractionFrame()) { if (interactionFrame == null) { return; } interactionFrame.CopyInteractionDataTo(userInfos); } // On parcourt les informations trouvées bool handFound = false; foreach (UserInfo userInfo in userInfos) { // Si mal reconnu ou on déjà trouvé une main qui est affichée if (userInfo.SkeletonTrackingId == 0 || handFound) { continue; } var hands = userInfo.HandPointers; if (hands.Count == 0) // Si aucune main reconnue { continue; } foreach (var hand in hands) { // La main doit être trackée, active et la main 'primaire' (= première levée des deux) if (!hand.IsActive || !hand.IsTracked) { continue; } handFound = true; actualHandType = hand.HandType; // Si la main devient grip et c'était pas son ancien état if (hand.HandEventType == InteractionHandEventType.Grip && hand.HandEventType != actualHandState) { actualHandState = InteractionHandEventType.Grip; } // Si la main lâche le grip else if (hand.HandEventType == InteractionHandEventType.GripRelease && hand.HandEventType != actualHandState) { actualHandState = InteractionHandEventType.GripRelease; } } } }
public InteractionInfo GetInteractionInfoAtLocation( int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo(); interactionInfo.IsGripTarget = true; interactionInfo.IsPressTarget = true; interactionInfo.PressAttractionPointX = 0.5; interactionInfo.PressAttractionPointY = 0.5; interactionInfo.PressTargetControlId = 1; return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo info = new InteractionInfo(); info.IsGripTarget = false; info.IsPressTarget = false; info.PressTargetControlId = 2; info.PressAttractionPointX = x; info.PressAttractionPointY = y; return info; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo info = new InteractionInfo(); info.IsGripTarget = false; info.IsPressTarget = false; info.PressTargetControlId = 2; info.PressAttractionPointX = x; info.PressAttractionPointY = y; return(info); }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, PressAttractionPointX = 0.5, PressAttractionPointY = 0.5, PressTargetControlId = 0 }; return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { InteractionInfo interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, PressAttractionPointX = 0.5, PressAttractionPointY = 0.5, PressTargetControlId = 0 }; return(interactionInfo); }
private GestureSource ToGestureSource(InteractionHandType handType) { if (handType == InteractionHandType.Left) { return(GestureSource.Left); } if (handType == InteractionHandType.Left) { return(GestureSource.Left); } return(GestureSource.None); }
public InteractionInfo GetInteractionInfoAtLocation( int skeletonTrackingId, InteractionHandType handType, double x, double y) { var result = new InteractionInfo { IsGripTarget = true, IsPressTarget = false, }; return(result); }
private void movimiento(double x, double y, InteractionHandType interactionHandType) { double h = canvasContenedor.ActualHeight; double w = canvasContenedor.ActualWidth; alto.Text = "Alto : " + h; ancho.Text = "Ancho : " + w; double posicionY = y * w; double posicionX = x * h; double posicionYEstatica = 0.0; double posicionXEstatica = 0.0; if (posicionY < 0) { posicionY = 0; } if (posicionX < 0) { posicionX = 0; } if (posicionX > (h - 70)) { posicionXEstatica = h - 70; posicionX = h - 70; } if (posicionY > (w - 70)) { posicionYEstatica = h - 70; posicionY = w - 70; } Posicionalto.Text = "Alto : " + posicionYEstatica; Posicionancho.Text = "Ancho : " + posicionXEstatica; if (interactionHandType == InteractionHandType.Left) { Canvas.SetTop(recIzquierda, posicionY); Canvas.SetLeft(recIzquierda, posicionX); } else { Canvas.SetTop(recDerecha, posicionY); Canvas.SetLeft(recDerecha, posicionX); } }
/// <summary> /// Convert an InteractionHandType value to corresponding HandType value. /// </summary> /// <param name="interactionHandType"> /// InteractionHandType value to convert. /// </param> /// <returns> /// Corresponding HandType value. /// </returns> internal static HandType ConvertHandType(InteractionHandType interactionHandType) { switch (interactionHandType) { case InteractionHandType.Left: return(HandType.Left); case InteractionHandType.Right: return(HandType.Right); default: Debug.Assert(interactionHandType == InteractionHandType.None, "HandType and InteractionHandType are out of sync."); return(HandType.None); } }
/// <summary> /// Convert an InteractionHandType value to corresponding HandType value. /// </summary> /// <param name="interactionHandType"> /// InteractionHandType value to convert. /// </param> /// <returns> /// Corresponding HandType value. /// </returns> internal static HandType ConvertHandType(InteractionHandType interactionHandType) { switch (interactionHandType) { case InteractionHandType.Left: return HandType.Left; case InteractionHandType.Right: return HandType.Right; default: Debug.Assert(interactionHandType == InteractionHandType.None, "HandType and InteractionHandType are out of sync."); return HandType.None; } }
public InteractionInfo GetInteractionInfoAtLocation( int s, InteractionHandType h, double x, double y ) { var r = new InteractionInfo(); r.IsGripTarget = true; r.IsPressTarget = true; r.PressAttractionPointX = 0.5; r.PressAttractionPointY = 0.5; r.PressTargetControlId = 1; return(r); }
/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; if (this.interactionIsEnabled && (this.clientRpcChannel != null)) { var result = this.clientRpcChannel.CallFunction <InteractionStreamHitTestInfo>("getInteractionInfoAtLocation", skeletonTrackingId, handType.ToString(), x, y); if (result.Success) { interactionInfo.IsGripTarget = result.Result.isGripTarget; interactionInfo.IsPressTarget = result.Result.isPressTarget; var elementId = result.Result.pressTargetControlId; interactionInfo.PressTargetControlId = (elementId != null) ? elementId.GetHashCode() : 0; interactionInfo.PressAttractionPointX = result.Result.pressAttractionPointX; interactionInfo.PressAttractionPointY = result.Result.pressAttractionPointY; } } return(interactionInfo); }
public void keepScrolling(double speed, InteractionHandType handType, ScrollType type) { //determine hand movement direction switch (type) { case ScrollType.vertical: scrollDirection = speed > 0 ? HandMovedDirection.down : HandMovedDirection.up; break; case ScrollType.horizontal: scrollDirection = speed > 0 ? HandMovedDirection.right : HandMovedDirection.left; break; case ScrollType.none: return; default: break; } //make sure speed is in bounds speed = Math.Abs(speed); if (speed < minSpeed || speed > maxSpeed) { return; } //reset params and start timer this.handType = handType; clickNo = 1; totalClicks = (int)(speed * speedToClickConst); tau = minInterval / (Math.Log((double)totalClicks / (double)(totalClicks - 1))); timer.Interval = minInterval; status = ScrollStatus.scrolling; timer.Start(); }
public void startInertiaScroll(InteractionHandPointer hand) { currentHandType = hand.HandType; //start horizontal inertia scrolling if (hInertiaEnabled && scrollType == InertiaScroller.ScrollType.horizontal) { //with *1000 factor speed will be ~ 1<speed<8 double speed = (1000 * (hand.X - prevMoveLocation.X) / (DateTime.UtcNow.Subtract(lastHMoveTime).Milliseconds)); inertiaScroller.keepScrolling(speed, hand.HandType, scrollType); //Debug //Console.WriteLine("speed: {0} type: {1}", speed, scrollType); } //keep vertical inertia scrolling if (vInertiaEnabled && scrollType == InertiaScroller.ScrollType.vertical) { //with *1000 factor speed will be ~ 1<speed<8 double speed = (1000 * (hand.Y - prevMoveLocation.Y) / (DateTime.UtcNow.Subtract(lastVMoveTime).Milliseconds)); inertiaScroller.keepScrolling(speed, hand.HandType, scrollType); //Debug //Console.WriteLine("speed: {0} type: {1}", speed, scrollType); } }
public HandPressedEventArgs(InteractionHandType _handType) { handType = _handType; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, }; var hitTestPosition = InteractionZoneDefinition.InteractionZoneToElement(x, y, this.InteractionRootElement); Func<HandPointer, bool> isTargetCapturedElement = handPointer => (handPointer.TrackingId == skeletonTrackingId) && (handPointer.HandType == EnumHelper.ConvertHandType(handType)) && (handPointer.Captured != null); var targetHandPointer = this.publicHandPointers.FirstOrDefault(isTargetCapturedElement); var targetElement = targetHandPointer != null ? targetHandPointer.Captured : this.HitTest(hitTestPosition); if (targetElement != null) { // Walk up the tree and try to find a grip target and/or a press target for (DependencyObject search = targetElement; search != null && search != this.InteractionRootElement && (!interactionInfo.IsGripTarget || !interactionInfo.IsPressTarget); search = VisualTreeHelper.GetParent(search)) { var searchElement = search as FrameworkElement; if (searchElement == null) { // We need ActualWidth and Height which comes // with FrameworkElement continue; } if (!interactionInfo.IsPressTarget) { bool isPressTarget = KinectRegion.GetIsPressTarget(searchElement); if (isPressTarget) { // We found a press target. if (interactionInfo.PressTargetControlId == 0) { interactionInfo.PressTargetControlId = searchElement.GetHashCode(); } interactionInfo.IsPressTarget = true; // Apply the margin to the press target point Point pressTargetPoint = ApplyControlPressPointMargin(KinectRegion.GetPressTargetPoint(searchElement)); // Convert from interaction zone space into actual control coordinates var elementPressTargetPoint = InteractionZoneDefinition.InteractionZoneToElement( pressTargetPoint.X, pressTargetPoint.Y, searchElement); // Get it into the space of the KinectRegion var regionPressTargetPoint = searchElement.TranslatePoint(elementPressTargetPoint, this.InteractionRootElement); // Now put it into the interaction zone space but now relative to the KinectRegion var interactionPressTargetPoint = InteractionZoneDefinition.ElementToInteractionZone( regionPressTargetPoint.X, regionPressTargetPoint.Y, this.InteractionRootElement); interactionInfo.PressAttractionPointX = interactionPressTargetPoint.X; interactionInfo.PressAttractionPointY = interactionPressTargetPoint.Y; } } if (!interactionInfo.IsGripTarget) { bool isGripTarget = KinectRegion.GetIsGripTarget(searchElement); if (isGripTarget) { // We found a grip target. interactionInfo.IsGripTarget = true; } } } } return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { return new InteractionInfo(); }
public InteractionInfo GetInteractionInfoAtLocation( int skeletonTrackingId, InteractionHandType handType, double x, double y ) { return new InteractionInfo() { IsGripTarget = true, }; }
public HandGripReleaseEventArgs(InteractionHandType _handType) { handType = _handType; }
/// <summary> /// Gets interaction information available for a specified location in UI. /// </summary> /// <param name="skeletonTrackingId"> /// The skeleton tracking ID for which interaction information is being retrieved. /// </param> /// <param name="handType"> /// The hand type for which interaction information is being retrieved. /// </param> /// <param name="x"> /// X-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to left edge of interaction region and 1.0 corresponds to right edge /// of interaction region. /// </param> /// <param name="y"> /// Y-coordinate of UI location for which interaction information is being retrieved. /// 0.0 corresponds to top edge of interaction region and 1.0 corresponds to bottom edge /// of interaction region. /// </param> /// <returns> /// An <see cref="InteractionInfo"/> object instance. /// </returns> public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false }; if (this.interactionIsEnabled && (this.clientRpcChannel != null)) { var result = this.clientRpcChannel.CallFunction<InteractionStreamHitTestInfo>("getInteractionInfoAtLocation", skeletonTrackingId, handType.ToString(), x, y); if (result.Success) { interactionInfo.IsGripTarget = result.Result.isGripTarget; interactionInfo.IsPressTarget = result.Result.isPressTarget; var elementId = result.Result.pressTargetControlId; interactionInfo.PressTargetControlId = (elementId != null) ? elementId.GetHashCode() : 0; interactionInfo.PressAttractionPointX = result.Result.pressAttractionPointX; interactionInfo.PressAttractionPointY = result.Result.pressAttractionPointY; } } return interactionInfo; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { return(new InteractionInfo() { IsGripTarget = true, }); }
void inStream_InteractionFrameReady(object sender, InteractionFrameReadyEventArgs e) { // if wrong state //onRaisedVoiceCommand(new VoiceCommandEventArgs("I'm in state" + state + " and I got interaciton data")); if (state < 2 || state > 3) { return; } if (frameout < 4) { frameout++; return; } //onRaisedVoiceCommand(new VoiceCommandEventArgs("I'm in state" + state)); InteractionFrame intFrame = e.OpenInteractionFrame(); UserInfo[] userInfos = new UserInfo[6]; if (intFrame != null) { intFrame.CopyInteractionDataTo(userInfos); // copy userinfos to array frameout = 0; } else { return; } foreach (UserInfo userInfo in userInfos) { foreach (InteractionHandPointer handPointer in userInfo.HandPointers) { // if at state 2 and grip is detected if (handPointer.IsPrimaryForUser && handPointer.IsTracked && handPointer.HandEventType == InteractionHandEventType.Grip && state == 2) { skeletonID = userInfo.SkeletonTrackingId; if (this.command != "ZOOM") { initialValue = handPointer.RawY; } else { initialValue = handPointer.RawZ; } handType = handPointer.HandType; String message = "Gesture command " + command.ToString() + " began with an initial value of " + initialValue; //onRaisedGestureCommand(new GestureEventArgs(message, command, initialValue)); onRaisedVoiceCommand(new VoiceCommandEventArgs(message)); state = 3; // move onto next stage } // at state 3 grip has not released if (handPointer.IsPrimaryForUser && handPointer.IsTracked && userInfo.SkeletonTrackingId == skeletonID && handPointer.HandEventType == InteractionHandEventType.None && state == 3 && handPointer.HandType == handType) { if (this.command != "ZOOM") { currentValue = handPointer.RawY; } else { currentValue = handPointer.RawZ; } String message = "Gesture command " + command.ToString() + " with a value of " + currentValue; onRaisedGestureCommand(new GestureEventArgs(message, command, initialValue - currentValue)); } // grip released detected at state 3 if (handPointer.IsPrimaryForUser && handPointer.IsTracked && userInfo.SkeletonTrackingId == skeletonID && handPointer.HandEventType == InteractionHandEventType.GripRelease && state == 3 && handPointer.HandType == handType) { //currentValue = handPointer.RawY; String message = "Gesture command " + command.ToString() + " ended with a value of " + currentValue + " and initial value of " + initialValue + " and a difference of " + (currentValue - initialValue); onRaisedGestureCommand(new GestureEventArgs(message, command, initialValue - currentValue)); state = 1; // return to initial stage } } } }
public HandMovedEventArgs(HandMovedDirection dir, MovementType _movementType, InteractionHandType _handType) { direction = dir; movementType = _movementType; handType = _handType; }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { return(new InteractionInfo()); }
public InteractionInfo GetInteractionInfoAtLocation(int skeletonTrackingId, InteractionHandType handType, double x, double y) { var interactionInfo = new InteractionInfo { IsPressTarget = false, IsGripTarget = false, }; var hitTestPosition = InteractionZoneDefinition.InteractionZoneToElement(x, y, this.InteractionRootElement); Func <HandPointer, bool> isTargetCapturedElement = handPointer => (handPointer.TrackingId == skeletonTrackingId) && (handPointer.HandType == EnumHelper.ConvertHandType(handType)) && (handPointer.Captured != null); var targetHandPointer = this.publicHandPointers.FirstOrDefault(isTargetCapturedElement); var targetElement = targetHandPointer != null ? targetHandPointer.Captured : this.HitTest(hitTestPosition); if (targetElement != null) { // Walk up the tree and try to find a grip target and/or a press target for (DependencyObject search = targetElement; search != null && search != this.InteractionRootElement && (!interactionInfo.IsGripTarget || !interactionInfo.IsPressTarget); search = VisualTreeHelper.GetParent(search)) { var searchElement = search as FrameworkElement; if (searchElement == null) { // We need ActualWidth and Height which comes // with FrameworkElement continue; } if (!interactionInfo.IsPressTarget) { bool isPressTarget = KinectRegion.GetIsPressTarget(searchElement); if (isPressTarget) { // We found a press target. if (interactionInfo.PressTargetControlId == 0) { interactionInfo.PressTargetControlId = searchElement.GetHashCode(); } interactionInfo.IsPressTarget = true; // Apply the margin to the press target point Point pressTargetPoint = ApplyControlPressPointMargin(KinectRegion.GetPressTargetPoint(searchElement)); // Convert from interaction zone space into actual control coordinates var elementPressTargetPoint = InteractionZoneDefinition.InteractionZoneToElement( pressTargetPoint.X, pressTargetPoint.Y, searchElement); // Get it into the space of the KinectRegion var regionPressTargetPoint = searchElement.TranslatePoint(elementPressTargetPoint, this.InteractionRootElement); // Now put it into the interaction zone space but now relative to the KinectRegion var interactionPressTargetPoint = InteractionZoneDefinition.ElementToInteractionZone( regionPressTargetPoint.X, regionPressTargetPoint.Y, this.InteractionRootElement); interactionInfo.PressAttractionPointX = interactionPressTargetPoint.X; interactionInfo.PressAttractionPointY = interactionPressTargetPoint.Y; } } if (!interactionInfo.IsGripTarget) { bool isGripTarget = KinectRegion.GetIsGripTarget(searchElement); if (isGripTarget) { // We found a grip target. interactionInfo.IsGripTarget = true; } } } } return(interactionInfo); }