private void OnTick(object sender, EventArgs e) { try { var value = typeof(InputManager).Assembly .TypeOf("StylusLogic") .Get <bool>("IsStylusAndTouchSupportEnabled"); IsStylusAndTouchSupportEnabledRun.Text = value.ToString(); } catch (Exception ex) { IsStylusAndTouchSupportEnabledRun.Text = ex.ToString(); } try { var collection = new TouchTabletCollection(); PimcManagerTabletCountRun.Text = collection.Count.ToString(); TabletDeviceCollectionRun.Text = string.Join($",{Environment.NewLine}", collection.Select(x => $"{x.Name}({(x.IsMultiTouch ? "Multi-" : "")}{x.Kind})")); } catch (Exception ex) { PimcManagerTabletCountRun.Text = ex.ToString(); } try { 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)); } } PhysicalSizeRun.Text = builder.ToString(); } catch (Exception ex) { PhysicalSizeRun.Text = ex.ToString(); } }
static void Main(string[] args) { var tablets = new TouchTabletCollection(); for (int ix = 0; ix < tablets.Count; ++ix) { Console.WriteLine("Found tablet {0} named {1}", ix + 1, tablets[ix].Name); Console.WriteLine(" Type = {0}, Multi-touch supported = {1}", tablets[ix].Kind, tablets[ix].IsMultiTouch); Console.WriteLine(" Input rectangle = {0}", tablets[ix].InputRectangle); Console.WriteLine(" Screen rectangle = {0}", tablets[ix].ScreenRectangle); } Console.ReadLine(); }