From 4d7c0f75ab22650d90e9d9534485a20cd5effad9 Mon Sep 17 00:00:00 2001 From: yibo <361071264@qq.com> Date: Tue, 23 Apr 2019 11:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=A7=A6=E6=91=B8=E4=B8=8D?= =?UTF-8?q?=E7=81=B5=E6=95=8F=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- B3DealerClient/App.xaml.cs | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/B3DealerClient/App.xaml.cs b/B3DealerClient/App.xaml.cs index 326921b..81148a2 100644 --- a/B3DealerClient/App.xaml.cs +++ b/B3DealerClient/App.xaml.cs @@ -1,11 +1,14 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.Data; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Input; namespace B3DealerClient { @@ -57,6 +60,46 @@ namespace B3DealerClient if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder); } + DisableWPFTabletSupport(); + } + + public static void DisableWPFTabletSupport() + { + // Get a collection of the tablet devices for this window. + TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; + + if (devices.Count > 0) + { + // Get the Type of InputManager. + Type inputManagerType = typeof(System.Windows.Input.InputManager); + + // Call the StylusLogic method on the InputManager.Current instance. + object stylusLogic = inputManagerType.InvokeMember("StylusLogic", + BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic, + null, InputManager.Current, null); + + if (stylusLogic != null) + { + // Get the type of the device class. + Type devicesType = devices.GetType(); + + // Loop until there are no more devices to remove. + int count = devices.Count + 1; + + while (devices.Count > 0) + { + // Remove the first tablet device in the devices collection. + devicesType.InvokeMember("HandleTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, devices, new object[] { (uint)0 }); + + count--; + + if (devices.Count != count) + { + throw new Win32Exception("Unable to remove real-time stylus support."); + } + } + } + } } } }