Windows 8学习笔记(七)--Input输入设备

Windows.Device.Input接口提供了识别可用的输入设备并获得这些设备的信息

KeyboardCapabilities

用于判断当前是否连接了键盘设备

其属性KeyboardPresent进行判断,当为0时表示未连接,不为0时表示已连接

Windows.Devices.Input.KeyboardCapabilities KeyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
string status = string.Format("There is {0} keyboard present\n", KeyboardCapabilities.KeyboardPresent != 0 ? "a" : "no");
  

MouseCapabilities

用于判断当前是否连接了鼠标设备

其属性比KeyboardCapabilities多了些,如下:

HorizontalWheelPresent 该值表明是否有带水平滚轮的鼠标连接

MousePresent 表明是否有鼠标连接

NumberOfButtons 该值表明当前连接的鼠标中按钮的数量,若有多个鼠标连接,则返回鼠标按钮个数最多的数量

SwapButtons 该值表明当前连接的鼠标设备中是否具有左右交换按钮的

VerticalWheelPresent 该值表明当前连接的鼠标设备中是否有垂直的滚轮

Windows.Devices.Input.MouseCapabilities MouseCapabilities = new Windows.Devices.Input.MouseCapabilities();
 
 String info = string.Format("There is {0} mouse present\n", MouseCapabilities.MousePresent != 0 ? "a" : "no");
 info += string.Format("There is {0} vertical mouse wheel present\n", MouseCapabilities.VerticalWheelPresent != 0 ? "a" : "no");
 info += string.Format("There is {0} horizontal mouse wheel present\n", MouseCapabilities.HorizontalWheelPresent != 0 ? "a" : "no");
 info += string.Format("The user has {0}opted to swap the mouse buttons\n", MouseCapabilities.SwapButtons != 0 ? "" : "not ");
 info += string.Format("The mouse has {0} button(s)\n", MouseCapabilities.NumberOfButtons);
  

TouchCapabilities

获得连接的触摸数字化仪的功能

Contats 表明支持所有数字化仪的最小联系人数量

TouchPresent 表明当前终端是否有数据化仪

Windows.Devices.Input.TouchCapabilities TouchCapabilities = new Windows.Devices.Input.TouchCapabilities();
 
 String info = string.Format("There is {0} digitizer present\n", TouchCapabilities.TouchPresent != 0 ? "a" : "no");
info += string.Format("The digitizer supports {0} contacts\n", TouchCapabilities.Contacts);
  

PointerDevice

识别连接的指针设备及它们的功能

var PointerDeviceList = Windows.Devices.Input.PointerDevice.GetPointerDevices();
            string device="";
            foreach (Windows.Devices.Input.PointerDevice PointerDevice in PointerDeviceList)
            {
                 if (PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Mouse)
                {
                    device ="mouse";
                }
                else if (PointerDevice.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Pen)
                {
                    device= "pen";
                }
                else
                {
                    device= "touch";
                }
            }
 
今天就看了一点输入设备的功能用法,研究SMS收发信息的功能时,却被刚开始的 SmsDevice.GetDefaultAsync()获取信息设备给绊住了,报的错误是”服务尚未启动。 (异常来自 HRESULT:0x80070426) ”,不知道是不是要先开启什么,望知者还能提醒一番^_^

 

 

Trackback:

http://www.cnblogs.com/jing870812/archive/2012/04/11/2443124.html

posted @ 2012-07-03 16:27  my favorite  阅读(268)  评论(0编辑  收藏  举报