Click here to Skip to main content
15,867,453 members
Articles / Desktop Programming / WPF

From Soup to Nuts with the Surface SDK 2.0

Rate me:
Please Sign up or sign in to vote.
4.86/5 (13 votes)
31 Jul 2011CPOL6 min read 35.4K   33   9
A look at the new Surface SDK 2.0 that was recently released by Microsoft
image001.png

Introduction

With the Microsoft® Surface® 2.0 SDK, you can easily create applications to take advantage of the next generation Surface computing device or any Windows touch-enables devices (defined by Microsoft).

Links worth checking out (thanks to Luis Cabrera):

Getting the SDK Installed

After downloading the Surface 2 SDK, double click the installer on the SDK to get the ball rolling.

Image 2

Image 3

Image 4

Getting the Runtime Installed

Once that is complete, then double click the installer for the Surface 2.0 Runtime.

Image 5

Image 6

Image 7

A Few Things to Note After Installing It

Hit your Start button and go to your programs and navigate to the Microsoft Surface 2.0 SDK. You will notice the normal “Getting Help” and “Release Notes”, but it also contains Surface Samples and Tools.

Image 8

Surface Samples

After clicking on that folder, you will see a Surface Code Samples.zip file.

Image 9

Go ahead and extract the zip file and you will notice the following sample project exists.

Image 10

Once loaded into Visual Studio 2010, you will see 14 projects exist inside of the solution.

Image 11

Go ahead and set one of them as your “Startup Project”.

Image 12

You can now use your mouse or a touch-enabled monitor to interact with the application. You also have the full source code, so you can manipulate the application all you want.

Image 13

They have several other great examples of what the Surface 2.0 SDK is capable of.

The Tools Folder

Inside the tools folder, you will find the following applications:

Image 14

Input Simulator - Simulate touch input and supported hardware parameters.

According to the docs (updated now for version 2.0):

Surface Simulator replicates the user interface and behavior of a Microsoft Surface unit that is in user mode. Surface Simulator has access points, Launcher, and the loading screen. When you start an application in Surface Simulator, the application displays like it is on a Microsoft Surface unit.

You can use Surface Simulator to evaluate how an application and its user interface respond to basic input. For example, if you simulate a painting application and if you touch multiple colors, one at a time, and then add the colors to a mixing bucket, you can test the logic of the application and how well it mixes the colors by using the touch-based interface.

Surface Simulator runs with the appearance and functionality of a Microsoft Surface unit in user mode (the way that it appears to users). You can switch applications by using Launcher and the access points that display on the Launcher screen and the applications.

Image 15

Input Visualizer - Display input data on top of a Microsoft Surface application.

According to the docs:

The Input Visualizer tool enables you to see the contact data that the Microsoft Surface Vision System returns in the context of your application. This tool runs on top of your application and displays information about the contacts that the input system detects.

Input Visualizer can help you test and debug the following scenarios:

  • Accidental input: Track the accidental activation of Microsoft Surface controls from palms, forearms, and other objects by seeing when these controls detect contacts.
  • Contact tracking: Determine what gestures are lost as contacts when users are dragging content in Microsoft Surface applications. You can use the fade away feature of Input Visualizer for this type of tracking.
  • Input hit-testing: Investigate where hit-testing occurs by freezing the user interface of Input Visualizer, lifting contacts, and seeing where their centers are reported.

Input Visualizer is installed with the Microsoft Surface SDK and runs only on Microsoft Surface units. If you are developing on a separate workstation, Surface Simulator provides contact visuals, reducing how much you need a visual representation of input.

Image 16

Surface Stress - Open a command prompt window to run stress tests against a Microsoft Surface application.

According to the docs:

The Surface Stress tool enables you to test the stability and robustness of your Microsoft Surface application by delivering multiple, simultaneous contacts to your application in a random way. Surface Stress generates all four types of contacts: fingers, blobs, byte tags, and identity tags.

Surface Stress is included with Microsoft Surface SDK 1.0 SP1. By default, the Surface Stress executable file (SurfaceStress.exe) is located in the C:\Program Files\Microsoft SDKs\Surface\v1.0\Tools\SurfaceStress folder, and a shortcut to Surface Stress appears in the Start menu under the Microsoft Surface SDK entry.

Image 17

Let’s create a new project.

Now that you have learned how to download and get started with it, it is time to actually create an application. Go ahead and fire up Visual Studio 2010 and begin a new project. Look for Surface then v2.0.

You will notice that you have 2 templates to start with:

  • Surface Application (WPF)
  • Surface Application (XNA Game Studio 4.0)
Image 18

We are only going to focus on the Surface Application (WPF).

Go ahead and give your application a name and hit OK.

Image 19

At first glance, you will realize this is just a WPF application. The folder structure looks just like what we would expect for a WPF application except that you have a “Resources” folder, a .xml document and MainPage.xaml is now called SurfaceWindow1.xaml.

Image 20

Let’s go ahead and take a look at the Toolbox. What we are most interested in is the “Surface Controls”. As you can see from this long list, there is a lot of Surface specific controls at our disposal right off the bat.

Let’s go ahead and use the “SurfaceInkCanvas”. So drag and drop it onto the SurfaceWindow1.xaml file.

Make sure your XAML looks very similar to the following:

XML
<s:SurfaceWindow x:Class="MichaelSurfaceApplication.SurfaceWindow1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    Title="MichaelSurfaceApplication">
  <Grid>
        <s:SurfaceInkCanvas Name="SampleInkCanvas" 
	HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <s:SurfaceInkCanvas.DefaultDrawingAttributes>
                <DrawingAttributes Color="#FF808080"/>
            </s:SurfaceInkCanvas.DefaultDrawingAttributes>
        </s:SurfaceInkCanvas>
    </Grid>
</s:SurfaceWindow>

Now go ahead and run your application and you should get the following screen. Go ahead and draw something on the screen and then close the window.

Image 21

Congratulations! You just created your first Surface 2.0 application while actually writing no code. While you are probably testing it on your laptop or desktop, this application would actually run on a Surface 2 Unit! Very cool stuff indeed.

Conclusion

The Surface is very cool technology and I am planning on investing a lot of time into it and other things such as Kinect. Microsoft really got it right with the Surface 2.0 SDK. I think that this is possibly the best SDK release Microsoft has ever been a part of. The documentation is excellent, the samples are a plenty and it’s just plain easy to build your first application. Now if only I had an actual Surface 2 table in my house to play with, then I would be really happy.

License

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


Written By
Software Developer (Senior) Telerik
United States United States
Michael Crump is a Silverlight MVP and MCPD that has been involved with computers in one way or another for as long as he can remember, but started professionally in 2002. After spending years working as a systems administrator/tech support analyst, Michael branched out and started developing internal utilities that automated repetitive tasks and freed up full-time employees. From there, he was offered a job working at McKesson corporation and has been working with some form of .NET and VB/C# since 2003.

He has worked at Fortune 500 companies where he gained experience in embedded systems design and software development to systems administration and database programming, and everything in between.

His primary focus right now is developing healthcare software solutions using Microsoft .NET technologies. He prefers building infrastructure components, reusable shared libraries and helping companies define, develop and automate process standards and guidelines.

You can read his blog at: MichaelCrump.net or follow him on Twitter at @mbcrump.

Comments and Discussions

 
QuestionWhat's different between win8 with vs2012 and Surface SDK? Pin
HSUPOWEI1-Jul-13 15:53
HSUPOWEI1-Jul-13 15:53 
GeneralMy vote of 5 Pin
AmitGajjar5-Nov-12 20:44
professionalAmitGajjar5-Nov-12 20:44 
GeneralMy vote of 5 Pin
GPUToaster™1-Aug-11 22:45
GPUToaster™1-Aug-11 22:45 
GeneralMy vote of 4 Pin
Reiss31-Jul-11 21:58
professionalReiss31-Jul-11 21:58 
Really good article, would have voted you a 5, but the article title let you down, sorry but I can't stand buzzword bingo phrases.
GeneralMy vote of 5 Pin
Hsing_Yeh31-Jul-11 21:46
Hsing_Yeh31-Jul-11 21:46 
QuestionNow you got me excited Pin
Mike Hankey31-Jul-11 18:21
mveMike Hankey31-Jul-11 18:21 
GeneralMy vote of 5 Pin
Kunal Chowdhury «IN»31-Jul-11 17:47
professionalKunal Chowdhury «IN»31-Jul-11 17:47 
GeneralThank you! Pin
Ravi Bhavnani31-Jul-11 16:50
professionalRavi Bhavnani31-Jul-11 16:50 
GeneralRe: Thank you! Pin
mbcrump31-Jul-11 16:58
mentormbcrump31-Jul-11 16:58 

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.