Click here to Skip to main content
13,594,066 members
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 26 Aug 2009
Licenced CPOL

Windows 7 Multitouch Application Development (Part - I)

, 26 Aug 2009
Rate this:
Please Sign up or sign in to vote.
In this post, I will discuss about developing a simple multitouch application using .NET 3.5 SP1.

Microsoft is going to launch the new Windows 7 operating system in October 2009. Currently the RC version is available online. As you know, Windows 7 came up with lots of goodies including better resource management, better performance, jumplist management, multitouch functionality & many more. Here I will discuss about developing a simple multitouch application using .NET 3.5 SP1.

Before doing anything, you have to download the Windows 7 Multitouch API. You can download it from here. Extract the downloaded zip file to your local hard drive. Be sure that you are using Windows 7 & you have a multitouch enabled screen to test it out.

Create a WPF application using Visual Studio 2008. This will automatically add an XAML file named Window1.xaml for you. Now add an image to your solution directory & insert it in the XAML. Now your Window1.xaml will look something like this:

<Image Source="images/Hydrangeas.jpg"/>

Add RenderTransform to the image so that we can scale or rotate the image properly. This will produce XAML similar to this:

<Image Source="images/Hydrangeas.jpg" RenderTransformOrigin="0.5,0.5" Width="400">
<ScaleTransform x:Name="trScale" ScaleX="1" ScaleY="1"/>
<RotateTransform x:Name="trRotate" Angle="0"/>
<TranslateTransform x:Name="trTranslate" X="0" Y="0"/>
<SkewTransform AngleX="0" AngleY="0"/>

Use proper names when you are adding different types of transform to the transform group. It will be easier for you to handle it from the code behind file. Run your application. This will open up your Window with an image inside it. If you want to drag or rotate the image, this will not work because we haven’t integrated the functionality yet.

Add two project references, i.e. “Windows7.Multitouch” & “Windows7.Multitouch.WPF” from the extracted zip folder to your solution. These are the managed API codes for multitouch application development.

Go to your Window1.xaml.cs and be sure that the following namespaces are already included. You may have to add some of them.

using System;
using System.Windows;
using Windows7.Multitouch;
using Windows7.Multitouch.Manipulation;
using Windows7.Multitouch.WPF;

Create two private members inside your partial class:

// object of a .Net Wrapper class for processing multitouch manipulation
private ManipulationProcessor manipulationProcessor = 
		new ManipulationProcessor(ProcessorManipulations.ALL);

// boolean value to check whether you have a multitouch enabled screen
private static bool IsMultitouchEnabled = 

Now inside the Window Loaded event, write the following lines of code:

// check to see whether multitouch is enabled
if (IsMultitouchEnabled)
     // enables stylus events for processor manipulation

     // add the stylus events
     StylusDown += (s, e) => 
		((uint)e.StylusDevice.Id,      e.GetPosition(this).ToDrawingPointF()); 
     StylusUp += (s, e) => 
		((uint)e.StylusDevice.Id, e.GetPosition(this).ToDrawingPointF()); 
     StylusMove += (s, e) => 
		((uint)e.StylusDevice.Id, e.GetPosition(this).ToDrawingPointF()); 

     // register the ManipulationDelta event with the manipulation processor
     manipulationProcessor.ManipulationDelta += ProcessManipulationDelta;

     // set the rotation angle for single finger manipulation
     manipulationProcessor.PivotRadius = 2;

Write your logic inside the manipulation event handler implementation block. Here I will do rotation, scaling & positioning of the image. Here is my code:

private void ProcessManipulationDelta(object sender, ManipulationDeltaEventArgs e)
     trTranslate.X += e.TranslationDelta.Width;
     trTranslate.Y += e.TranslationDelta.Height;

     trRotate.Angle += e.RotationDelta * 180 / Math.PI;

     trScale.ScaleX *= e.ScaleDelta;
     trScale.ScaleY *= e.ScaleDelta;

From the ManipulationDeltaEventArgs, you can get various values and depending upon them, you can implement your functionality in this block. TranslateTransform will position the image, RotateTransform will do the rotation and the ScaleTransform will resize the image. Run your project to test your first multitouch application.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kunal Chowdhury «IN»
Software Developer (Senior)
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik Developer Expert, Nokia Developer Champion, Windows 10 Champion, Microsoft Rockstar, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.

Book authored:

Connect with me on:

My CodeProject Awards/Prizes:

You may also be interested in...


Comments and Discussions

GeneralMultitouch application Pin
bhanuprakash00721-Sep-10 22:52
memberbhanuprakash00721-Sep-10 22:52 
QuestionMulitple Images on a background image Pin
bhanuprakash00717-Sep-10 1:56
memberbhanuprakash00717-Sep-10 1:56 
QuestionAPI For WIndows7 Pin
bhanuprakash00714-Sep-10 4:34
memberbhanuprakash00714-Sep-10 4:34 
AnswerRe: API For WIndows7 Pin
KunalChowdhury14-Sep-10 4:42
mentorKunalChowdhury14-Sep-10 4:42 
GeneralMultiple Images.. Pin
chengteck907-Sep-09 5:30
memberchengteck907-Sep-09 5:30 
GeneralRe: Multiple Images.. Pin
KunalChowdhury7-Sep-09 6:29
memberKunalChowdhury7-Sep-09 6:29 
GeneralRe: Multiple Images.. Pin
chengteck907-Sep-09 14:52
memberchengteck907-Sep-09 14:52 
GeneralRe: Multiple Images.. Pin
chengteck907-Sep-09 15:43
memberchengteck907-Sep-09 15:43 
JokeRe: Multiple Images.. Pin
KunalChowdhury7-Sep-09 18:17
memberKunalChowdhury7-Sep-09 18:17 
GeneralRe: Multiple Images.. Pin
chengteck907-Sep-09 20:09
memberchengteck907-Sep-09 20:09 
No problem.. Smile | :)
I will be looking forward to your coming guide.. Wink | ;)
AnswerRe: Multiple Images.. Pin
KunalChowdhury8-Sep-09 19:59
memberKunalChowdhury8-Sep-09 19:59 
GeneralRe: Multiple Images.. Pin
chengteck908-Sep-09 20:01
memberchengteck908-Sep-09 20:01 
GeneralRe: Multiple Images.. Pin
chengteck908-Sep-09 21:19
memberchengteck908-Sep-09 21:19 
AnswerRe: Multiple Images.. Pin
KunalChowdhury8-Sep-09 22:16
memberKunalChowdhury8-Sep-09 22:16 
GeneralRe: Multiple Images.. Pin
chengteck908-Sep-09 22:35
memberchengteck908-Sep-09 22:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.180618.1 | Last Updated 26 Aug 2009
Article Copyright 2009 by Kunal Chowdhury «IN»
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid