- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果多个屏幕连接到一台计算机,我想在触摸屏上显示一个应用程序。通过遍历 System.Windows.Forms.Screen.AllScreens
,我可以获得 WorkingArea 以便移动窗口。但是,Screen
不提供 IsTouchscreen
方法。
另一方面,通过遍历所有 System.Windows.Input.Tablet.TabletDevices
,我无法找到相应的 Screen
,因为 Screen.DeviceName
与 TabletDevice.Name
不匹配。
那么有没有办法以某种方式将 Screen
与 TabletDevice
匹配,或者我可以使用其他解决方法?
最佳答案
此信息可用,WPF 使用的低级 COM 接口(interface)记录在 this MSDN article 中.然而,免责声明是适当的,Microsoft 不喜欢您使用它们。接口(interface)文档警告“开发人员不应使用此接口(interface)”,否则没有任何明显的理由说明这是个好建议。如果 Microsoft 真的想阻止我们使用它,那么不记录它们会简单得多。
ITablet2::GetMatchingScreenRect() 函数发生了一些奇怪的事情,您正在寻找的那个函数缺少它的文档。这本身就是 WPF 未公开此信息的可能原因。所以谨慎是必要的,您确实需要在要使用它的硬件上对其进行彻底测试。我没有任何要验证的。
我写了一些使用这些接口(interface)的代码。向您的项目添加一个新类并粘贴如下所示的代码。您需要添加对 System.Drawing 的引用。
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Text;
public enum TouchDeviceKind { Mouse, Pen, Touch }
public class TouchTabletCollection {
public TouchTabletCollection() {
Guid CLSID_TabletManager = new Guid("A5B020FD-E04B-4e67-B65A-E7DEED25B2CF");
var manager = (ITabletManager)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_TabletManager));
int count = 0;
manager.GetTabletCount(out count);
Count = count;
tablets = new List<TouchTablet>(count);
for (int index = 0; index < count; index++) {
tablets.Add(new TouchTablet(manager, index));
}
}
public int Count { get; private set; }
public TouchTablet this[int index] {
get { return tablets[index]; }
}
private List<TouchTablet> tablets;
}
public class TouchTablet {
internal TouchTablet(ITabletManager mgr, int index) {
ITablet itf;
mgr.GetTablet(index, out itf);
device1 = itf;
device2 = (ITablet2)itf;
device3 = (ITablet3)itf;
}
public bool IsMultiTouch {
get {
bool multi;
device3.IsMultiTouch(out multi);
return multi;
}
}
public TouchDeviceKind Kind {
get {
TouchDeviceKind kind;
device2.GetDeviceKind(out kind);
return kind;
}
}
public string Name {
get {
IntPtr pname;
device1.GetName(out pname);
return Marshal.PtrToStringUni(pname);
}
}
public Rectangle InputRectangle {
get {
RECT rc;
device1.GetMaxInputRect(out rc);
return Rectangle.FromLTRB(rc.Left, rc.Top, rc.Right, rc.Bottom);
}
}
public Rectangle ScreenRectangle {
get {
RECT rc;
device2.GetMatchingScreenRect(out rc);
return Rectangle.FromLTRB(rc.Left, rc.Top, rc.Right, rc.Bottom);
}
}
private ITablet device1;
private ITablet2 device2;
private ITablet3 device3;
}
// COM declarations
[ComImport, Guid("764DE8AA-1867-47C1-8F6A-122445ABD89A")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITabletManager {
void GetDefaultTablet(out ITablet table);
void GetTabletCount(out int count);
void GetTablet(int index, out ITablet tablet);
// rest omitted...
}
[ComImport, Guid("1CB2EFC3-ABC7-4172-8FCB-3BC9CB93E29F")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITablet {
void Dummy1();
void Dummy2();
void GetName(out IntPtr pname);
void GetMaxInputRect(out RECT inputRect);
void GetHardwareCaps(out uint caps);
// rest omitted
}
[ComImport, Guid("C247F616-BBEB-406A-AED3-F75E656599AE")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITablet2 {
void GetDeviceKind(out TouchDeviceKind kind);
void GetMatchingScreenRect(out RECT rect);
}
[ComImport, Guid("AC0E3951-0A2F-448E-88D0-49DA0C453460")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface ITablet3 {
void IsMultiTouch(out bool multi);
void GetMaximumCursors(out int cursors);
}
internal struct RECT { public int Left, Top, Right, Bottom; }
使用它的示例程序:
using System;
class Program {
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();
}
}
请注意,需要 Windows 7 或更高版本。我的触摸无知笔记本电脑上的输出:
Found tablet 1 named \\.\DISPLAY1
Type = Mouse, Multi-touch supported = False
Input rectangle = {X=0,Y=0,Width=1440,Height=900}
Screen rectangle = {X=0,Y=0,Width=1440,Height=900}
关于c# - 如何区分触摸屏和普通触摸屏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29215016/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 5 年前。
DBMS 供应商使用 SQL 方言特性来区分他们的产品,同时声称支持 SQL 标准。 'Nuff 说。 您编写的任何 SQL 示例是否无法转换为 SQL:2008 标准 SQL? 具体来说,我说的是
多年来,我一直在考虑这个问题,但从未成功实现过。我说的是一个快速、高效的 C 函数,它在输入中接受一个整数值(例如 16 位),并在输出中给出完全不同的相同位大小的数字,但“考虑到”所有数字已经给出了
当标准 iPhone UI 控件变得过于平淡,并且您希望简单的记分应用程序通过颜色、动画、非标准 GUI 字体和背景壁纸等流行时。 ,为这样的事情集成游戏引擎有意义吗? 我对 Unity3D 和 To
这是我的第一个问题,所以如果我没有正确地标记标签,我很抱歉。我尝试过...这是我的问题:我希望有人能告诉我如何为普通的表格 View 创建 2 行节标题。我遇到的问题是:1)我找不到可以模仿默认 1
所以我一直在开发一个仅使用普通 JavaScript 的“非常简单”的计算器。但我不知道为什么它现在起作用了。 这是我的 JavaScript 和 HTML 代码: (function() { "
我正在尝试编写一个函数来满足以下要求: 给定一个对象和一个键,“getElementsThatEqual10AtProperty”返回一个数组,其中包含位于给定键处等于 10 的数组的所有元素。 注释
[最终编辑:我觉得有必要做出回应,因为我从这篇文章中学到了很多东西(主要是通过你们,我花了更多的时间来理解CSS..但最后,我真的不知道如何为了使这项工作有效..除了真正破坏html的基本结构..我不
我希望能够将一个函数附加到一个元素上,该函数只有在该元素上单击指定时间后才会运行。 有几个( 1 、 2 、 3 )与在 javascript 中处理鼠标保持相关的问题;但这些问题要么使用 jQuer
我想将泛型函数保存为变量: (defvar *gf* (make-instance 'standard-generic-function) 但是在添加方法时,我必须自己定义call-next-meth
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我有一个普通的 tableView——一个部分——当我滚动时,行出现在标题后面。像这样: 有没有简单的方法来防止这种情况?我认为它与 contentInset 有关,但这也会移动标题,这不是我想要的。
你好,我有一个ajax表单,它返回一个控制“发送”动画的脚本。然而,当淡入开始时,它会停止在 0.1 不透明度。我不确定脚本中有什么问题。任何帮助将不胜感激。 quote_form = documen
这是演示我的问题的代码笔:http://codepen.io/PiotrBerebecki/pen/yaWQwZ 目标是当用户点击时有滚动动画 顶部导航链接,以及 Back to Top 按钮在右下角
在我重新发明轮子之前,纯Java中有类似主题的并发队列吗?我有以下要求: 多个读者/消费者 多名作家/制片人 每条消息都必须由每个(活跃的)消费者消费 在每个消费者阅读一条消息后,它应该变成垃圾(即不
这个问题与 Do MySQL tables need an ID? 有一个无意义的auto_incremental ID作为一个表的PRIMARY KEY,那么我创建其他KEY时,我是否应该在KEY中
我有一个普通 UITableView 并且我想隐藏分隔符。为了隐藏它,我尝试使用以下属性: 我也在 viewDidLoad 中设置了它。 self.tableView.separatorStyle =
var vettore = document.getElementById(id_form).elements; for (var i = 0; i '+vettore_nomi_file[i]; 最
我已经构建了一个非常简单的轮播,但有一个问题。在我的轮播中,我有三张幻灯片,一个上一个按钮和一个下一个按钮。我想要的是当我单击下一个按钮并在最后一张幻灯片上转到第一张幻灯片时。此外,当我单击上一个按钮
我是 javascript 的新手,所以我需要一些帮助。 我正在尝试制作一个简单的插件(当然只是为了学习,以便更好地理解事物),但我遇到了一些麻烦,我将不胜感激。 我的插件是基本的,我正在尝试为 sc
我是一名优秀的程序员,十分优秀!