Thursday, May 7, 2009

Identifying Finger Tag and Blob in Surface using Contacts class

If you are not much familiar with Microsoft surface just have a look here in my another blog and get start in Surface development from here.

There is an attached event called ContactDown in the class Contacts.We can subscribe to that in any visuals and process according to that.

<s:SurfaceWindow x:Class="SurfaceApplication.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">
<Grid>
<TextBlock>Place contact here</TextBlock>
<Rectangle Grid.Row="1" Fill="#0fff0000"
Width="100" Height="100" s:Contacts.ContactDown="Rectangle_ContactDown" />
</Grid>
</s:SurfaceWindow>











Code behind





private void Rectangle_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
{
if (e.Contact.IsTagRecognized)
{
switch(e.Contact.Tag.Type)
{
case Microsoft.Surface.Presentation.TagType.Byte:
MessageBox.Show(string.Format("Byte tag identified value={0}", e.Contact.Tag.Byte.Value));
break;
case Microsoft.Surface.Presentation.TagType.Identity:
MessageBox.Show(string.Format("Identity tag identified value={0}", e.Contact.Tag.Identity.Value));
break;
}
return ;
}
if (e.Contact.IsFingerRecognized)
{
MessageBox.Show("Finger contact identified");
}
else
{
MessageBox.Show("Blob identified");
}
}









This code just shows a message box. Processing the contacts such as showing something upon placing a contact and all will be discussed later in the post ‘Using TagVisualizer and TagVisualization’.

1 comment:

  1. I think that using Contacts class in order to Identifying Finger Tag and Blob in Surface is such a great idea! It is as brilliant as
    viagra online

    ReplyDelete