原文: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. MySQL和Python交互

    与Python交互 python3模块名:pymysql conda install pymysql conda install sqlalchemy python2模块名:MySQLdb impor ...

  2. Java Timer TimerTask Example(java Timer的例子)

    Java java.util.Timer is a utility class that can be used to schedule a thread to be executed at cert ...

  3. Oracle 排序问题(null带来的)

    null 导致排序有问题, 对于数字的,一定要用nvl来解决.

  4. Spring Boot Freemarker特别篇之contextPath【从零开始学Spring Boot】(转)

    需求缘起:有人在群里@我:请教群主大神一个问题,spring boot  + freemarker 怎么获取contextPath 头疼死我了,网上没一个靠谱的 .我就看看之前博客中的 [Spring ...

  5. Iaas、Paas和Saas的区别

    Iaas: Infrastructure-as-a-service(基础设施即服务),Iaas上购买的一般是主机,用户不光要开发程序,还要考虑搭建系统,维护运行环境,以及怎么容灾,怎么做到高可用,怎么 ...

  6. 修复STS4 server中没有Tomcat的问题(必看,官方推荐,包教包会,国内首发)

    版权声明:原创.欢迎转载,转载请注明来源,谢谢. https://blog.csdn.net/qq_41910280/article/details/83279129 修复STS4 server中没有 ...

  7. 对象模型图(OMD)阅读指南

    樱木 原文 对象模型图(OMD)阅读指南(转载) 补充几个名词概念: UML:Unified Modeling Language 统一建模语言,是用来对软件密集系统进行可视化建模的一种语言.UML为面 ...

  8. linux的任务计划 定时任务 计划任务

    例如要定时访问一个指定的url 先看看系统有没有crontab

  9. RAC sysdate

    rac的sysdate可能不一致,这个需要注意.

  10. 雷观(十):管理自己的任务列表(TodoList)很重要

    由幼年,到青年,再到成年,你会发现自己有越来越多的事情要做.参加工作后,很可能要在多个战线上同时忙碌. 最常见的有,工作(可能会加班加点).爱情(不少人忙着恋爱,需要花费很多心思).个人娱乐(玩游戏看 ...