by October 3, 2008 0 comments



The interaction between computers and humans has reached new proportions, as
is evident from the new forms of interaction that are emerging. Apart from
standard input devices (like keyboards and mouse) an emerging technique to input
information is via touchscreens. These can be further divided into two
types: single touch and multi-touch. In a single touch device, information can
be fed using a single instance of touch while multi touch allows for more than
one touch simultaneously; this means one can use more than one finger to feed
information or more than one user can input information. A multi-touch device
has a touch screen and software that recognizes multiple simultaneous touches.
As an example, just look at the ‘iPhone, ‘ where Multi-touch is garnering a lot
of attention. The future of this technology looks bright as more and more work
is being done in this area. Microsoft is soon going to include Multi-touch
functionality in its next version of Windows, ‘Windows 7.’ As the cost
associated with multi-touch devices is decreasing, the need to develop
applications that harness multi-touch functionality is also increasing. In this
article, we shall develop a sample program that shows how easily one can develop
a multi-touch application that can run on Windows Vista or XP.

Direct Hit!
Applies To:
Adv .NET developers
USP: Multi-touch functionality on Windows Vista
or even XP
Primary Link: www.codeplex.com
Keywords: Multi-touch Vista

Implementing Multi-touch
To build this application we used Visual Studio 2008 with C# as the
programming language and the .NET framework 3.5. We started with creating a ‘WPF
Application,’ named as ‘FirstMultitouch’. The next step is to add reference to
this application. This can be done by right clicking on ‘References’ and then
clicking on ‘Add reference’. We have to add ‘Multitouch.Framework.WPF.dll’ to
this project. This required file can be downloaded from http://tinyurl.com/
6enfy6 . One can find this file at ‘MultiTouchVista\Framework’. After adding the
reference, open ‘Window1.axml’ file now and add the following code to the file:

<mt:Window x:Class="FirstMultitouch.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mt="http://schemas.multitouch.com/Multitouch/2008/04"
Title="Window1" Height="300" Width="300">
<Grid>
<mt:TouchablePanel>
<TextBlock Text="PCQLabs" FontSize="72" FontWeight="Bold" Foreground="Yellow"
Background="Red" Height />
</mt:TouchablePanel>
</Grid>
</mt:Window>

Open ‘Window1.cs’ file and change it to the following:
namespace sandeep
{
public partial class Window1 : Multitouch.Framework.WPF.Controls.Window
{
public Window1()
{
InitializeComponent();
}
}
}

To show output we need ‘Multotouch.Console.Service.exe’ running in the
background. This service is located at ‘MultiTouchVista\Service’. Once all this
has been done just run your application. It will show a ‘PCQuest’ logo that can
be touched and moved around (red dot will act as touch point that can be used
with mouse). Now let’s move towards a more complex and visually appealing
application. In this application, we shall be moving five photographs (.JPEG)
using multi-touch technique. The first step is to keep five photographs in
‘MyPicture’ folder inside ‘MyDocuments’. Then create a ‘WPF Application’ in
Visual studio 2008 and name it ‘SecondMultitouch,’ and then again add reference
‘Multitouch.Framework.WPF.dll’. Now open ‘Window1.axml’ file and replace the
code with:

<mt:Window x:Class="SecondMultitouch.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mt="http://schemas.multitouch.com/Multitouch/2008/04"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Window1" Height="300" Width="300">
<Grid>
<ItemsControl ItemsSource="{Binding Photos}">
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type sys:String}">
<Image Source="{Binding}"/>
</DataTemplate>
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<mt:TouchablePanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</mt:Window>

Save this file and then move to ‘Window1.cs’ file and change it to the
following:

using System.Collections.ObjectModel;
using System.IO;
namespace SecondMultitouch
{
public partial class Window1 : Multitouch.Framework.WPF.Controls.Window
{
public Window1()
{
DataContext = this;
Photos = new ObservableCollection<string>();
InitializeComponent();
}
public ObservableCollection<string> Photos
{
get {return (ObservableCollection<string>)GetValue(PhotosProperty); }
set { SetValue(PhotosProperty, value); }
}

public static readonly DependencyProperty
PhotosProperty =
DependencyProperty.Register("Photos",typeof(ObservableCollection<string>),
typeof(Window));
protected override void OnInitialized(EventArgs e)

{
base.OnInitialized(e);
foreach (string file in
Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
"*.jpg").Take(5))
{
Photos.Add(file);
}
}

Now we are ready with the application. Just run ‘Windows.Service. Console.exe’
in the back ground and then run ‘SecondMultitouch’ application. One can easily
rotate, zoom and move pictures. This application gives a feel of a multi-touch
device where the ‘touching’ part is done through mouse. Multi-touch is clearly
futuristic and a very appealing technology that makes computing really
interesting and in a way ‘sensitive.’

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

<