确定Windows Phone 8上的触摸压力

时间:2013-09-20 05:27:51

标签: windows-phone-8

我无法找到确定手指在屏幕上的压力的方法。 获取StylusPoints并使用这些点的PressureFactor属性似乎最明显:

    private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        var point = e.StylusDevice.GetStylusPoints(Image).Last();
        Debug.WriteLine(point.PressureFactor);

但是PressureFactor始终为0.5,并且从http://msdn.microsoft.com/en-us/library/bb979901(v=vs.95).aspx开始,设备类型必须是“Stylus”才能生效。

我还查看http://code.msdn.microsoft.com/Multi-Touch-Drawing-744a0b48使用Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);来捕获触摸事件。然后事件处理程序可以访问TouchPoint但它们没有Pressure属性。

如何找到触摸压力?

1 个答案:

答案 0 :(得分:1)

只有手写笔支持触控,您可以在example code from the MSDN

中看到
 String queryPointer(PointerPoint ptrPt)
 {
     String details = "";

     switch (ptrPt.PointerDevice.PointerDeviceType)
     {
         case Windows.Devices.Input.PointerDeviceType.Mouse:
             details += "\nPointer type: mouse";
             break;
         case Windows.Devices.Input.PointerDeviceType.Pen:
             details += "\nPointer type: pen";
             if (ptrPt.IsInContact)
             {
                 details += "\nPressure: " + ptrPt.Properties.Pressure;
                 details += "\nrotation: " + ptrPt.Properties.Orientation;
                 details += "\nTilt X: " + ptrPt.Properties.XTilt;
                 details += "\nTilt Y: " + ptrPt.Properties.YTilt;
                 details += "\nBarrel button pressed: " + ptrPt.Properties.IsBarrelButtonPressed;
             }
             break;
         case Windows.Devices.Input.PointerDeviceType.Touch:
             details += "\nPointer type: touch";
             details += "\nrotation: " + ptrPt.Properties.Orientation;
             details += "\nTilt X: " + ptrPt.Properties.XTilt;
             details += "\nTilt Y: " + ptrPt.Properties.YTilt;
             break;
         default:
             details += "\nPointer type: n/a";
             break;
     }

....