处理2,3,4,5个手指螺纹,DoubleTap和放大器;在WinRT的应用程序持手势放大器、螺纹、手势、应用程序

2023-09-03 16:01:31 作者:知足 Contentつ

我可以轻松地处理1手指螺纹 DoubleTap 控股手势是这样的:

I can easily handle 1 finger Tapped, DoubleTap and Holding gestures like this:

public MainPage()
{
    this.InitializeComponent();
    this.Tapped += mc_Tapped;
    this.DoubleTapped += mc_DoubleTapped;
    this.Holding += mc_Holding;
}
public void mc_Tapped(object sender, TappedRoutedEventArgs e)
{
    //Tap
}
public void mc_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
{
    //DoubleTap
}
public void mc_Holding(object sender, HoldingRoutedEventArgs e)
{
    //Hold
}

但事件没有一个属性来获取手指的数量,他们甚至不被解雇时1个多点触控触摸在屏幕上present。我也想处理2,3,4,5个手指螺纹 DoubleTap 控股手势。谁能告诉我该怎么做?

But the events don't have a property to get the number of fingers and they don't even get fired when more than 1 touch contact is present on the screen. I also want to handle 2, 3, 4, 5 fingers Tapped, DoubleTap and Holding gestures. Can anyone tell me how to do that?

推荐答案

您将不得不与那些对指针事件通过PointerRoutedEventArgs工作(即pressed,输入,发布等等),并做了艰辛的道路

You'll have to work with the PointerRoutedEventArgs that are passed on Pointer events (ie. Pressed, entered, released and such) and do it the hard way

每个时间指针进入控制被分配一个唯一的指针ID.I将创建一个字典和每个指针添加到词典,因为它是pssed在控制$ P $(显然当它们退出删除)。那么在您现有的挖掘,双窃听和这样的处理只是检查有多少指针是在你的字典并调用相应的处理程序

Each time pointer enters the control is assigned a unique pointer ID.I would create a Dictionary and add each pointer to that dictionary as it is pressed on the control (and obviously remove them when they exit). Then in your existing tapped, double tapped and such handlers just check how many pointers are in your dictionary and call the appropriate handlers