【问题标题】:Hand over button event in Kinect SDK 1.7Kinect SDK 1.7 中的移交按钮事件
【发布时间】:2013-04-05 17:44:01
【问题描述】:

我正在使用 Kinect SDK 1.7 创建一个 WPF 应用程序,我需要计算用户放置按钮的次数(不是按下,只是放置)。我发现只有一个事件负责在 XAML 中按下按钮

<k:KinectTileButton Label="Click" Click="PushButtonEvent"></k:KinectTileButton>

我找不到负责将手放在按钮上的事件(如果存在此事件)。也许你已经知道哪个事件会做到这一点?或者如何以其他方式解决此问题?

【问题讨论】:

  • 这个问题太模糊了,你需要提供更多关于你正在尝试做什么以及你正在使用什么环境的信息。这是用于 Xbox 还是用于 Windows 的 Kinect?你已经尝试过什么?

标签: wpf xaml kinect kinect-sdk


【解决方案1】:

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 中实际定义按钮的任何位置执行相同操作。挂钩 HandPointerEnterHandPointerLeave 处理程序,然后您可以计算用户将手形光标移入和移出该区域的次数。

【讨论】:

    【解决方案2】:

    不确定这些是否是自定义控件,但我非常肯定大多数控件应该带有鼠标输入事件或能够扩展它。

    <Button Tag="Test" MouseEnter="enterMethod">
    

    只需让您的方法为每次鼠标悬停增加一个变量。

    【讨论】:

      猜你喜欢
      • 2013-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-30
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 2023-03-03
      相关资源
      最近更新 更多