Visar inlägg med etikett SDK. Visa alla inlägg
Visar inlägg med etikett SDK. Visa alla inlägg

onsdag 4 februari 2009

Touchability by Contact Events

An event describes an action which occurs in a specific behavior. To add ‘touchability’ to your Surface controls, contact events has to be registered for them. There are a couple of ways to add such contact handlers. The following examples show how to register a handler for capturing a press-and-hold event:

XAML:
<s:SurfaceSlider x:Name="MySurfaceSlider" ContactHoldGesture="MySurfaceSlider_ContactHoldGesture" />

C#, first option:
MySurfaceSlider.ContactHoldGesture += new ContactEventHandler(MySurfaceSlider_ContactHoldGesture);

C#, second option:
Contacts.AddContactHoldGestureHandler(MySurfaceSlider, MySurfaceSlider_ContactHoldGesture);

The implementation of the contact event handler:
private void MySurfaceSlider_ContactHoldGesture(object sender, ContactEventArgs e)
{ /* TODO: Handle Contact Hold Gesture event */ }

There are several events that are possible to capture. The following section lists the contact events that are supported in the Surface SDK (version 1.0):
  • ContactDown, which triggers when a contact is placed on a Surface control.
  • ContactUp, which triggers when a contact is removed from a Surface control.
  • ContactHoldGesture, which triggers when a Surface control is subject of a press-and-hold action. Note: Is only raised when the contact is of type Finger.
  • ContactTapGesture, which triggers when a Surface control is being tapped on.
  • ContactChanged, which triggers when a contact that is in touch with a Surface control changes its attributes, i.e. position.
  • ContactEnter, which triggers when a contact enters a control’s boundaries, i.e. if a finger (that is already in touch with the Surface) is moved onto a control.
  • ContactLeave, which triggers when contacts leaves a control’s boundaries.
I feel the ScatterViewItems’ ContactUp and ContactDown events needs a bit of extra information. ContactUp/Down are handled internally, which prevents you from raising any of the events. If you forget about this while working with ScatterViewItem this might be somewhat confusing. Another topic to keep in mind is the ScatterViewItems’ property ‘StaysActive’. If the property is set to ‘true’ this may affect the ScatterViewItem when a contact is released from it by the control not being deactivated.

Lastly I’ve posted a C# example of how to check what kind of contact is triggering a contact event.


måndag 26 januari 2009

Surface SDK's WPF layer

To quickly get around with developing for Microsoft Surface, and understanding how cool multi-touch applications are, the WPF layer is a good starting point. The WPF layer API of the Surface SDK extends Windows Presentation Foundation to be used in touch-enabled user interfaces. WPF layer controls are standard WPF controls, but Microsoft Surface enabled.

The WPF layer is actually really easy to get started with. XAML is used to declaratively define the user interface. Also, many of the controls one is familiar with from WPF also exist for Microsoft Surface, only now prefixed by ‘Surface’. The XAML examples below show two versions of a window with the same functionality, one traditional WPF and the other is Surface.

Standard WPF:


Surface SDK:


Note: Normally ‘Click’ is not a contact event, but for SurfaceButton it is. This is worth keeping in mind for later when you start using ContactDown for other controls.

As you can see there is not much that differs the two windows. This makes it very easy to transition to Microsoft Surface development and rapidly create touch-enabled applications. Use these mnemonic rules to get started:
  • A Surface control is usually named the same thing as you’re used to from WPF, but prefixed with ‘Surface’.
  • To add a handler for use interactions, the mouse events are now called contact events.

fredag 23 januari 2009

Contact: The act or state of touching

While being in contact with the Surface you handle more information than when just placing your finger on a traditional touch-enabled screen. A Contact in ‘Microsoft Surface language’ is the kind of object that touches your Surface screen. The Surface SDK gives you the possibility to recognize different kinds of objects. The ones you can use are Finger, Tagged object or Blob.
  • Finger is self-explanatory; your finger in touch with the touch-enabled screen.
  • Tagged object are objects with an identity tag placed on them. This makes it possible to interpret exactly which object is being placed on the surface table.
  • Blob is an arbitrary object placed on the screen. You might have seen the demo with a wine glass with a surrounding aura – voila a blob.
Ok, so what to do with contacts. The touch-enabled controls for Surface can handle events from user interactions – that is different states of the contacts on the screen. These interactions are called gestures or manipulations.

Gestures are user activity which doesn’t work differently on whatever element is affected. A tapping or pressing action is a tap or push whether it’s a button or custom user control. Manipulations on the other hand are interactions that depend on what control is being touched and how. A manipulation user action has a context. That means that for one control a twirling motion means to rotate the control, but for another the same user interaction means to twist the control’s content.

Using the WPF layer of the Surface SDK the Surface controls are enabled to capture the following events:
  • ContactDown
  • ContactUp
  • ContactTapGesture
  • ContactHoldGesture
  • ContactEnter
  • ContactLeave
  • ContactChanged
More about the mentioned contact events when we come back to the WPF layer in a coming blog posts.

lördag 17 januari 2009

Surface simulator


When developing applications for the Microsoft Surface you have a Surface Simulator that gets installed when you install the SDK. This can be used to simulate user input and contact with objects that are placed on the Surface-unit.

So far I have only tried the sample applications that are installed with the SDK and done some simple applications that don’t use any object recognition. But the simulator seems to work fine so far.

There are differens buttons button in the simulator that is used to simulate a finger or an object place on the Surface. To simulate the use of two fingers you can hold the left mouse button and then click on the right mouse button to place the finger. It is also possible to plug in two usb-mice to simulate two fingers or two objects.

Today I noticed a really cool feature. If you use a finger or object representation in the simulator and then scroll on the scroll wheel on the mouse the finger or object is rotated. This will come really handy when you use the simulator to display some sort of graphics around a placed object.

Just remember to start the simulator before starting the application from Visual Studio. Otherwise you will not get access to these features and your application will start in some other mode that I so far don’t know what it’s used for.

onsdag 14 januari 2009

Answer from the Surface team

I also got an answer from Robert Levy on the Surface team. He said that they don´t have a workaround for this right now but are looking closely at allowing installation of the SDK on Win7 for our next release. There was no word about when this releas is expected.

Surface on Windows 7 - Now it works!

I had actually given up all hopes to be able to install the Surface SDK on Windows 7. Yesterday I tried to consult two of the sharpest wiz-kids at Connecta and made some progress but after a while it was a dead end. I actually had thrown in the towel and decided to go for a dual boot. So I started the disk manager and shrunk the disk to create a new partition with 20 GB to host Windows Vista. Installed Vista on the new partition and then it was too late in the evening to continue.

And then, this night, at 00:25 there was a reply from Kurt Brockett at Blendables.com on a post that I made to their forum!

As I already had assumed the only problem with the failed installation is the OS-check at the beginning. A colleague of mine tried to install the SDK on Windows XP and found out that there is a property missing on advapi32.dll that is one of the core dll’s in Windows. This property is of course present in the Vista version and I assume that it’s also there in the Windows 7 version. So if there was only a way to get around the OS-check…

What Kurt told me in the post was that there is a way to edit msi-packages with a simple vb-script!

So to be able to install the Surface SDK on Windows 7 just download the script and place it in the same directory as SurfaceSDKWE.msi. Then drag the msi-file and drop it on the removechk.vbs. This will remove the OS-check and the installation of the SDK will work perfectly!

Now I have started the Surface Simulator and tried the samples and everything works great on Windows 7! Love it!

The thread on Blendables.
Link to the vbs-file to remove the check.

måndag 12 januari 2009

Surface on Windows 7

Today I decided to install Windows 7 on my developer machine. First I tried an upgrade but it was unsuccessful since I only had the Enterprise version of Vista and beta 1 of Windows 7 is Ultimate. So instead I tried a clean install and that was really smooth. I started the installation directly from a mounted image in Vista and it was finished after 30 or maybe 45 minutes. No drivers or other installations messing things up. The only thing that didn’t work – so far – was Daemon Tools. Instead I downloaded PowerISO and that worked perfectly. So far I haven’t had any limitations with the unregistered version.

F-Secure Antivirus, Office 2007 and Visual Studio 2008 was also easy but when it came to the Surface SDK I got some problems. The XNA Redistributable was no problem but right at the beginning of the installation of Microsoft Surface SDK 1.0, Workstation Edition I get an error telling me that I’ve got the wrong Service Pack version for Vista installed. The software requirements say that I have to use Vista Business, Enterprise or Ultimate with Service Pack 1. So I’m stuck!

I have sent an email to one of the guys on the Surface Team at Microsoft and a post in the NUI Groups forum hoping for the best.