Jun 30 2009

Multi Touch enabling your WPF application

Recently I had the possibility to work on some multi-touch stuffs using the .NET wrappers for the touch APIs included in Windows 7 RC.

Do you remember Simon? As described by Wikipedia:

Simon is an electronic game of rhythm and memory skill invented by Ralph H. Baer and Howard J. Morrison,[1] with the software programming being done by Lenny Cope and manufactured and distributed by Milton Bradley. Simon was launched in 1978 at Studio 54 in New York City and became an immediate success. It became a pop culture symbol of the 1980s.”

And… here we go, let’s connect to http://simon.codeplex.com and play with the Silverlight on-line version built by David J Kelley:

Simon

How to add basic multi touch gestures (rotation, scale and transform) to the WPF version? It’s quite impressive to look at the amount of code required using the Windows 7 Multitouch .NET Interop Sample Library: just insert some transforms in the User Control XAML

<Viewbox x:Name="_simon" RenderTransformOrigin="0.5, 0.5">
<uc:Simon/>
<Viewbox.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="_rotate" Angle="0"/>
<ScaleTransform x:Name="_scale" ScaleX="1" ScaleY="1"/>
<TranslateTransform x:Name="_translate" X="0" Y="0"/>
</TransformGroup>
</Viewbox.RenderTransform>
</Viewbox>

And then use this code to control the TransformGroup using the Multi touch engine:

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

namespace SimonWPF
{
public partial class MultiTouchWindow1 : Window
{
ManipulationProcessor _processor = new ManipulationProcessor(ProcessorManipulations.ALL);

public MultiTouchWindow1()
{
InitializeComponent();

Loaded += (s, e) => { Factory.EnableStylusEvents(this); };

StylusDown += (s, e) => { _processor.ProcessDown((uint)e.StylusDevice.Id,
e.GetPosition(_canvas).ToDrawingPointF()); };

StylusUp += (s, e) => { _processor.ProcessUp((uint)e.StylusDevice.Id,
e.GetPosition(_canvas).ToDrawingPointF()); };

StylusMove += (s, e) => { _processor.ProcessMove((uint)e.StylusDevice.Id,
e.GetPosition(_canvas).ToDrawingPointF()); };

_processor.ManipulationDelta += ProcessManipulationDelta;
_processor.PivotRadius = 2;
}

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

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

_scale.ScaleX *= e.ScaleDelta;
_scale.ScaleY *= e.ScaleDelta;
}
}
}

It’s also possible to verify if your hardware supports multi touch:

if (Windows7.Multitouch.TouchHandler.
DigitizerCapabilities.IsMultiTouchReady)
{
//MultiTouch is available
this.StartupUri = new Uri("MultiTouchWindow1.xaml", UriKind.Relative);
}
else this.StartupUri = new Uri("Window1.xaml", UriKind.Relative);

The complete code is available on CodePlex: http://simon.codeplex.com.

Enjoy Windows 7 Multi touch! And now… waiting for Silverlight 3 :)

The multi touch library is governed by this license.


Jun 30 2009

Targeting Mono in Visual Studio 2010

One of the cool new features available in Visual Studio 2010 Beta 1 is the possibility to use Multi Targeting in order to build solutions for Mono: read here the detailed instructions by Jonathan Pobst.


Jun 22 2009

Using Live Writer to insert Silverlight content in your WordPress Blog

Erno De Weerd has developed a Live Writer plugin which permits to insert Silverlight content in a WordPress Blog using the Tim Heuer’s Silverlight for WordPress plugin.

Thanks to Walt Ritscher for the segnalation.


Jun 20 2009

Silverlight based UI development demonstrated on Win CE

User Interface Technologies for Windows Embedded CE

Read this article for more information.


May 27 2009

Running Silverlight 3 apps on Windows Embedded Standard 2009 using Windows 7 RC and Virtual PC

Silverlight 3 on Windows Embedded Standard 2009

When I read this thread on the Silverlight forum, I wanted to test the possibility to run Rich Internet Applications built using Silverlight 3 on an embedded device powered by the last version of Windows Embedded, Windows Embedded Standard 2009 (WES).

To rapidly deploy the image, I decided to use Windows Virtual PC Beta and the .VHD file support available on Windows 7.

These are the steps:

1 – Install Windows 7 RC on the test PC

2 – Install Windows Virtual PC and Virtual Windows XP

3 - Install Windows Embedded Standard 2009 Studio (the trial is available here)

4 – Run the utility “tap.exe” in a command prompt of Virtual Windows XP in order to obtain a list of the devices

5 - Generate a WES 2009 image in the directory “c:\WES2009Img” using the WES utility “Target designer” by importing the file obtained in the preceding step. It’s important to enable the “Silverlight 1.0” component in order to install the files required for the Silverlight installation

6 – Create a new Virtual Machine to host the generated image

7 – Mount, format and make active the .vhd by using the “Disk Management” utility of Windows 7

8 – Copy the files and folders of the Windows Embedded image (contained in “c:\WES2009Img”) in the .vhd by assigning a drive letter to the virtual disk file

9 – Boot the Virtual Machine from Windows Virtual PC

10 – Install the Silverlight 3 plug-in and enjoy Rich Internet Applications on your Windows Embedded Standard virtual machine ;)


May 27 2009

Silverlight 3 Beta and Binary message encoding

Silverlight 3 Beta uses Binary message encoding as a default WCF binding option, this is also the methodology used in the “Silverlight-enabled WCF Service” item template of Visual Studio.

John Papa has posted a nice article explaining the advantages of this binding instead of the “usual” BasicHttpBinding used in Silverlight 2 (other details available here and here), what about the client side? How can I use this new Binding?

These are the steps required for explicitely specifying the new binding in the code:

  • add a “Service Reference” from Visual Studio;
  • initialize and call the service in this way

EndpointAddress address = new EndpointAddress("<Your Service Uri Here>");

CustomBinding binding = new CustomBinding(
                new BinaryMessageEncodingBindingElement(),
                new HttpTransportBindingElement());

YourServiceRef.ServiceClient svc = new YourServiceRef.ServiceClient(binding, address);

Download the Visual Studio 2008 solution (also tested on Visual Studio 2010 Beta 1:)


May 26 2009

VPlay from Microsoft Research

Click here for more details.


May 21 2009

A quick analyze of the .NET Fx v4.0 Beta1 using the NDepend tool

In this great article, Patrick Smacchia compares .NET Fx v4.0 beta1 assemblies with v3.5 SP1 ones using the incredible NDepend tool: a big part of the framework is still evolving and the framework is getting richer and bigger, should it grow indefinitely?


May 20 2009

Visual Studio 2010 Beta 1 public download

Check out here: http://msdn.microsoft.com/it-it/vstudio/dd582936(en-us).aspx 


May 20 2009

Media Center SDK for Windows 7 RC now available for public download

Just found the news on the Aaron Stebner’s blog, with some useful links: