For all friends of multi-touch capabilities Silverlight 3 has a build in support for multi-touch.
However, to support it, your app has to be running on Windows 7. For this reason it will be quite difficult provide interoperable SL-applications for different platforms.
On the other side, If I design Windows 7 application, in most cases, I would probably think to build it on WPF rather than on SIlverlight. If I need support for multiple platforms then my application cannot rely on features of Windows 7 only.
So, whatever the future brings on the table, following code demonstrate how you can provide support for multi-touch within Silverligth 3.
Note, that you have to have devices which support this technology if you want to be able to set the breakpoint inside of handler. If you don’t have them, the code will compile and run.
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightApplication2 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported); } void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPointCollection points = e.GetTouchPoints(null); TouchPoint point = e.GetPrimaryTouchPoint(null); if (point != null) { if (point.Action == TouchAction.Down) e.SuspendMousePromotionUntilTouchUp(); Point p = point.Position; switch (point.Action) { case TouchAction.Move: break; case TouchAction.Down: break; case TouchAction.Up: break; } } } } } |
Posted
Jul 26 2009, 08:08 PM
by
Damir Dobric