KinectTileButton 支持手形光标的跟随事件,可以订阅并根据您的需要进行操作:
public static readonly RoutedEvent HandPointerMoveEvent = EventManager.RegisterRoutedEvent(
"HandPointerMove", RoutingStrategy.Bubble, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerEnterEvent = EventManager.RegisterRoutedEvent(
"HandPointerEnter", RoutingStrategy.Direct, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerLeaveEvent = EventManager.RegisterRoutedEvent(
"HandPointerLeave", RoutingStrategy.Direct, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerPressEvent = EventManager.RegisterRoutedEvent(
"HandPointerPress", RoutingStrategy.Bubble, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerPressReleaseEvent = EventManager.RegisterRoutedEvent(
"HandPointerPressRelease", RoutingStrategy.Bubble, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerGripEvent = EventManager.RegisterRoutedEvent(
"HandPointerGrip", RoutingStrategy.Bubble, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerGripReleaseEvent = EventManager.RegisterRoutedEvent(
"HandPointerGripRelease", RoutingStrategy.Bubble, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerGotCaptureEvent = EventManager.RegisterRoutedEvent(
"HandPointerGotCapture", RoutingStrategy.Direct, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerLostCaptureEvent = EventManager.RegisterRoutedEvent(
"HandPointerLostCapture", RoutingStrategy.Direct, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent QueryInteractionStatusEvent = EventManager.RegisterRoutedEvent(
"QueryInteractionStatus", RoutingStrategy.Bubble, typeof(EventHandler<QueryInteractionStatusEventArgs>), typeof(KinectRegion));
InitializeKinectButtonBase 函数设置按钮的默认行为:
private void InitializeKinectButtonBase()
{
KinectRegion.AddHandPointerPressHandler(this, this.OnHandPointerPress);
KinectRegion.AddHandPointerGotCaptureHandler(this, this.OnHandPointerCaptured);
KinectRegion.AddHandPointerPressReleaseHandler(this, this.OnHandPointerPressRelease);
KinectRegion.AddHandPointerLostCaptureHandler(this, this.OnHandPointerLostCapture);
KinectRegion.AddHandPointerEnterHandler(this, this.OnHandPointerEnter);
KinectRegion.AddHandPointerLeaveHandler(this, this.OnHandPointerLeave);
KinectRegion.SetIsPressTarget(this, true);
}
您可以在 UI 中实际定义按钮的任何位置执行相同操作。挂钩 HandPointerEnter 和 HandPointerLeave 处理程序,然后您可以计算用户将手形光标移入和移出该区域的次数。