添加Windows 8触控支持,以现有的WinForms应用程序 [英] Adding Windows 8 touch support to existing WinForms application

查看:305
本文介绍了添加Windows 8触控支持,以现有的WinForms应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的Windows窗体面向.NET Framework 4的桌面应用程序,并希望8触控的支持,加上Windows来了。

I have an existing Windows Forms desktop application targeting .NET Framework 4 and would like to add Windows 8 touch support to it.

目前该程序正常工作在Windows 8中,我有可能只是调整一些元素,使之更人性化的触摸设备。然而,添加手势,如捏到变焦的数据网格,并为其他元素刷卡的支持将很长的路要走,以使应用程序在触摸只有环境更加现代化。

Currently the program works fine in Windows 8, and I can potentially just resize some of the elements to make it more user-friendly on touch devices. However, adding gestures such as pinch-to-zoom on datagrids, and swipe support for other elements would go a long way to making the application more modern in a touch-only environment.

我投资在Visual Studio 2012,这将让我针对.NET 4.5和新的Windows 8功能,但没有人知道任何资源,这将帮助我更新我的应用程序?我特别关注以下内容:

I'm investing in Visual Studio 2012, which will let me target .NET 4.5 and the new Windows 8 features, but does anyone know of any resources which would help me with updating my application? I'm specifically concerned about the following:

  • 无力对我的非触摸开发机直接测试应用程序的触摸功能。微软的模拟器似乎只支持地铁的应用程序。我听说平板电脑应用程序,如集成Splashtop可以帮助(我有一个Android平板电脑),但还没有看到任何具体针对此特定情形
  • 无论举手投足甚至支持的WinForms应用程序。难道我不得不整个UI升级为WPF得到这个工作? (如果我没走这条路,我相信我也可以针对Windows 7的多点触摸的支持WPF 4)
  • 检测设备的触摸支持,在运行时和缩放/更改UI适当,类似于微软的Windows RT的Office应用程序的触摸模式设置。我不希望到餐桌的项目只是为了添加新功能
  • 在触摸交互的自动化测试

这是不是一个详尽的清单以任何方式,但我真的AP preciate任何意见,从那些过去谁可能已经接近了类似的升级。

This isn't an exhaustive list by any means, but I'd really appreciate any advice from those who may have approached a similar upgrade in the past.

推荐答案

检测设备的触摸支持,在运行时是有问题的,因为用户可以在触摸设备随时随地连接。如果检测到触摸设备连接后,调整的形式和设备的连接不稳定,你最终可能会与不断调整自身的一种形式。更好的为所有输入中的一个稳定的接口(例如,使用一个小菜单栏的色带代替)。如果你真的想检测触摸的设备,你可以调用GetSystemMetrics SM_DIGITIZER。

Detecting the device's touch support at run-time is problematic since the user can connect a touch device anytime. If you resize the form after detecting touch device connection and the device's connection is not stable you may end up with a form that keep resizing itself. Better have one steady interface for all inputs (e.g. using ribbon instead of a small menu bar). If you really want to detect touch devices, you can call GetSystemMetrics with SM_DIGITIZER.

手势不支持Windows窗体(功能冻结在2005年)。但表单控件仍然可以使用触摸输入,因为默认的触摸处理转化触摸鼠标点击。如果你想拥有自己的触摸处理程序,因为触摸输入发送的Windows消息的形式,则可以覆盖你的窗体或控件的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.wndproc(v=vs.110).aspx">WndProc函数来处理手势消息。对于样品code检查 Windows触控样品

Gestures are not supported in Windows Forms (feature frozen in 2005). However form controls can still use touch input since the default touch handler translate touches to mouse clicks. If you want to have your own touch handler, since touch inputs are sent in the form of windows Messages, you can override your form or control's WndProc function to handle the gesture messages. For sample code check Windows Touch Samples.

有关编写测试code你的触摸功能,你可以调用InjectTouchInput模拟触摸输入。一个完整的样品可以在输入中找到:触摸进样

For writing test code for your touch capability, you can call InjectTouchInput to simulate touch input. A complete sample can be found at Input: Touch injection sample.

这篇关于添加Windows 8触控支持,以现有的WinForms应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆