1

私は Kinect SDK 1.7 を使用して WPF アプリケーションを作成しています。ユーザーがボタンの上に手を置いた回数を数える必要があります (押すのではなく、置くだけです)。XAML でボタンを押すことを担当するイベントのみを見つけました

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

ボタンの上に手を配置する原因となっているイベントが見つかりません (このイベントが存在する場合)。たぶん、どのイベントがそれを行うのか、ある程度わかっていますか?または、この問題を別の方法で解決するにはどうすればよいですか?

4

2 に答える 2

2

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ユーザーがハンド カーソルを領域内外に移動した回数をカウントできます。

于 2013-04-08T16:30:14.437 に答える
0

これらがカスタム コントロールかどうかはわかりませんが、ほとんどのコントロールにはマウス入力イベントが付属しているか、それを拡張できるはずです。

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

そして、マウスオーバーごとにメソッドに変数をインクリメントさせるだけです。

于 2013-04-06T09:59:38.673 に答える