标签:GetProperty 触摸 var BindingFlags device WPF 精度
title | author | date | CreateTime | categories |
---|---|---|---|---|
WPF 获得触摸精度和触摸点 | lindexi | 2018-05-04 21:11:51 +0800 | 2018-5-4 21:8:4 +0800 | 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)); } }
如果发现设备触摸失效,可以使用这个项目
标签:GetProperty,触摸,var,BindingFlags,device,WPF,精度 来源: https://blog.51cto.com/u_11283245/2952802
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。