Get Started with TouchToolkit with One Install:

If you already have Visual Studio 2010 installed (and Silverlight SDK if you like to use Silverlight), you only need to download and install the TouchToolkit Templates for Visual Studio. The latest release is available here. That's all, you are now ready to start developing multi-touch applications using TouchToolkit.

Start Developing applications:

After installing the templates, run Visual Studio 2010 and open the new projects dialog box. You should see three new templates under Visual C# category: TouchToolkit Silverlight Application, TouchToolkit WPF Application for Windows 7 and TouchToolkit Microsoft Surface Application.

Lets select TouchToolkit WPF Application for Windows 7 and press OK. The template will create a WPF project, copy necessary files with some example code. Press F5 and the IDE will run the example code right a way that demonstrate drag, resize & rotate feature. You can see TouchToolkit in action, in the following video: .

For Silverlight projects, you also have to add a web site to show the Silverlight applicaiton. This post shows how you can link a Silverlight project with a website/web application.

How It Works:

Initialize the Framework:
Since the framework can support various types of devices (i.e. Windows 7, Silverlight Touch API, Microsoft Surface, Smart TableTop), we need to inform the framework about the touch input source. In this example, we are using Silverlight.

public MainPage()
{
     InitializeComponent();
     this.Loaded += MainPage_Loaded;
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
     // Initialize Gesture Framework
     TouchInputProvider inputProvider = new SilverlightTouchInputProvider();
     GestureFramework.Initialize(inputProvider, LayoutRoot, Assembly.GetExecutingAssembly());

     ...
     ...
}

Note: When you use any of the project templates, you don't have to write the above code. The template will do it for you.
Note: You can use the toolkit for any device as long as you have the right input provider. You can also create our own providers to support new devices.

Subscribe to Gesture Events:
Registering for any gesture is pretty straightforward. You need to provide the scope (in this case, the img object), the name of the gesture and a callback method reference.

// Subscribe to gesture events for image
GestureFramework.EventManager.AddEvent(img, "zoom", ZoomCallback);

private void ZoomCallback(UIElement sender, List<IReturnType> values)
{
      var dis = values.Get<DistanceChanged>();
      if (dis != null)
            Resize(sender as Image, dis.Delta);
     ...
     ...
}


Let the Framework Manage Generic Feedback:
We can use the framework to handle things that are common to many actions. For example, visual feedback for touch or gesture.

Add Touch Feedback:
In this example, we are adding a touch effect that renders bubbles on the touch path. We can also develop our own effects by implementing the ITouchFeedback interface.
touch path.png
//Add touch feedback
GestureFramework.AddTouchFeedback(typeof(BubblesPath));


Add Gesture Feedback:
Just like the touch feedback, we can also create visual feedback for gestures. Following example shows how we can setup the framework to render visual effects when a particular gesture is detected.
highlight-area.png
//Add gesture feedback
GestureFramework.AddGesturFeedback("lasso", typeof(HighlightSelectedArea));


Simulate Touch Interactions
Use recorded data to test touch interactions on regular developer machine and simulate multi-user scenarios. This tool is also useful for debugging applications using Visual Studio.
simulate-multi-user.png

Write Automated Tests
The GestureTestFramework provides the necessary infrastructure use the recorded data to write automated tests. For example, the following code segments shows a test code using Visual Studio Unit Test framework to test the zoom gesture.
automated-test.png

Last edited Jul 7, 2011 at 4:43 AM by shahed, version 29

Comments

No comments yet.