developers.de
daenet's .NET Community

Multi-Touch for Silverlight 3 and Windows 7

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

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

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH