原文:WPF 获得触摸精度和触摸点

本文主要告诉大家如何获得所有的触摸设备的触摸精度和触摸点数。


需要通过反射的方法才可以拿到触摸的精度。

使用 Tablet.TabletDevices 可以获得所有的触摸设备,获得触摸点数可以通过下面代码

foreach (TabletDevice device in Tablet.TabletDevices)
{
Console.WriteLine("触摸点数" + device.StylusDevices.Count);//触摸点数
}

触摸精度就需要使用反射

        var builder = new StringBuilder();
foreach (TabletDevice device in Tablet.TabletDevices)
{
var deviceProperty = typeof(TabletDevice).GetProperty("TabletDeviceImpl",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);
var deviceImpl = deviceProperty is null ? device : deviceProperty.GetValue(device);
var info = deviceImpl.GetType().GetProperty("TabletSize",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty); var tabletSize = (Size) info.GetValue(deviceImpl, null);
if (device.Type == TabletDeviceType.Touch)
{
builder.Append(string.Format("{1}:{2} 点触摸,精度 {3}{0}", Environment.NewLine,
device.Name, device.StylusDevices.Count, tabletSize));
}
else
{
builder.Append(string.Format("{1}:{2} 个触笔设备,精度 {3}{0}", Environment.NewLine,
device.Name, device.StylusDevices.Count, tabletSize));
}
}

如果发现设备触摸失效,可以使用这个项目

ManipulationDemo


本文会经常更新,请阅读原文:
https://lindexi.gitee.io/lindexi/post/WPF-%E8%8E%B7%E5%BE%97%E8%A7%A6%E6%91%B8%E7%B2%BE%E5%BA%A6%E5%92%8C%E8%A7%A6%E6%91%B8%E7%82%B9.html
,以避免陈旧错误知识的误导,同时有更好的阅读体验。


本作品采用
知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议
进行许可。欢迎转载、使用、重新发布,但务必保留文章署名林德熙(包含链接:
https://lindexi.gitee.io
),不得用于商业目的,基于本文修改后的作品务必以相同的许可发布。如有任何疑问,请
与我联系
。

WPF 获得触摸精度和触摸点的更多相关文章

  1. 2018-5-4-WPF-获得触摸精度和触摸点

    title author date CreateTime categories WPF 获得触摸精度和触摸点 lindexi 2018-05-04 21:11:51 +0800 2018-5-4 21 ...

  2. 2019-11-29-WPF-从触摸消息转触摸事件

    原文:2019-11-29-WPF-从触摸消息转触摸事件 title author date CreateTime categories WPF 从触摸消息转触摸事件 lindexi 2019-11- ...

  3. 2019-5-13-WPF-从触摸消息转触摸事件

    title author date CreateTime categories WPF 从触摸消息转触摸事件 lindexi 2019-05-13 09:43:48 +0800 2019-05-12 ...

  4. WPF DispatcherTimer(定时器应用) 无人触摸60s自动关闭窗口

    原文:WPF DispatcherTimer(定时器应用) 无人触摸60s自动关闭窗口 如果无人触摸:60s自动关闭窗口 xmal:部分 <s:SurfaceWindow x:Class=&qu ...

  5. 通过 AppSwitch 禁用 WPF 内置的触摸让 WPF 程序可以处理 Windows 触摸消息

    原文:通过 AppSwitch 禁用 WPF 内置的触摸让 WPF 程序可以处理 Windows 触摸消息 WPF 框架自己实现了一套触摸机制,但同一窗口只能支持一套触摸机制,于是这会禁用系统的触摸消 ...

  6. 2019-11-29-WPF-测试触摸设备发送触摸按下和抬起不成对

    原文:2019-11-29-WPF-测试触摸设备发送触摸按下和抬起不成对 title author date CreateTime categories WPF 测试触摸设备发送触摸按下和抬起不成对 ...

  7. 2019-7-15-WPF-测试触摸设备发送触摸按下和抬起不成对

    title author date CreateTime categories WPF 测试触摸设备发送触摸按下和抬起不成对 lindexi 2019-7-15 9:3:51 +0800 2019-0 ...

  8. cocos2dX 事件之触摸事件和触摸事件集合

    今天, 我们来学习cocos2dX里面的触摸事件与触摸事件合集, 如今的手机游戏交互基本上都是通过触摸交互的, 所以大家明确这节的重要性了吧, 本节篇幅比較大, 所以我就不扯闲话了 先来看看经常使用函 ...

  9. 当你触摸并按住触摸目标时候,禁止系统默认菜单-webkit-touch-call

    当你触摸并按住触摸目标时候,禁止或显示系统默认菜单. -webkit-touch-callout 是一个 不规范的属性(unsupported WebKit property),它没有出现在 CSS ...

随机推荐

  1. jquery 获取上一个兄弟元素和下一个兄弟元素

    jQuery.prev(),返回上一个兄弟节点,不是所有的兄弟节点 jQuery.prevAll(),返回所有之前的兄弟节点 jQuery.next(),返回下一个兄弟节点,不是所有的兄弟节点 jQu ...

  2. ExtJs4学习(七)MVC中的Store

    Ext.data.Store是extjs中用来进行数据交换和数据交互的标准中间件,不管是Grid还是ComboBox,都是通过它 实现数据读取.类型转换.排序分页和搜索等操作的. Ext.define ...

  3. 介绍linux设备驱动编程

    目前,Linux软件工程师大致可分为两个层次: (1)Linux应用软件工程师(Application Software Engineer):       主要利用C库函数和Linux API进行应用 ...

  4. mybatis+springmvc缓存设置

    开始接触mybatis,本以为缓存设置好麻烦,在网上找了好多相关的资料,说得也都好复杂,经过自己亲自实践,其实很简单的. 首先引入需要的jar包,参照pom.xml配置: <!-- 缓存设置 s ...

  5. 判断是iphone或是ipad 和 系统版本

    //判断是iphone或是ipad等 NSLog(@"Device -- %@",[UIDevice currentDevice].model); //系统版本 NSLog(@&q ...

  6. [Nuxt] Navigate with nuxt-link and Customize isClient Behavior in Nuxt and Vue.js

    Because Nuxt renders pages on the server, you should use the nuxt-link components to navigate betwee ...

  7. [TypeScript] Union Types and Type Aliases in TypeScript

    Sometimes we want our function arguments to be able to accept more than 1 type; e.g. a string or an ...

  8. [RxJS] Reusable multicasting with Subject factories

    The way we use publish() (or multicast with an RxJS Subject) makes the shared Observable not reusabl ...

  9. yield return

    一次被yield return坑的历程.   事情的经过是这样的: 我用C#写了一个很简单的一个通过迭代生成序列的函数. public static IEnumerable<T> Iter ...

  10. Linux 常用性能工具

    Linux 常用性能工具简介. 一.wget 文件下载 使用wget下载单个文件:wget URL 下载并以不同的文件名保存:wget -O wordpress.zip URL wget限速下载:wg ...