我有一个登录应用程序,其中有一个滑动系统,只有拥有触摸屏的人才能使用。他们可以通过滑动自己的个人图案滑动码进行登录。
在C#或WPF中是否可以检查用户是否拥有触摸屏?即使此时他没有使用触摸功能?
在C#或WPF中是否可以检查用户是否拥有触摸屏?即使此时他没有使用触摸功能?
通过使用PresentationCore
命名空间中的System.Windows.Input
,在C#代码中查找触摸屏是否存在(不检查它是单点触摸设备还是多点触摸设备)。
public bool HasTouchInput()
{
foreach (TabletDevice tabletDevice in Tablet.TabletDevices)
{
//Only detect if it is a touch Screen not how many touches (i.e. Single touch or Multi-touch)
if(tabletDevice.Type == TabletDeviceType.Touch)
return true;
}
return false;
}
我认为在托管代码中没有可用的东西,但您可以在Win32_DesktopMonitor
上使用P/Invoke。有关更多信息,请参见msdn。
我发现这篇博客文章可能会有所帮助,尽管它是关于Windows CE的:http://blog.nerdbank.net/2006/10/platform-detection-iii-how-to-detect.html