Click here to Skip to main content
Click here to Skip to main content

Tagged Objects in Microsoft Surface – TagVisualizer,TagVisualization,TagVisualizationDefinition

, 17 Mar 2010
Rate this:
Please Sign up or sign in to vote.
Article about Tag driven application or Tagged Objects in Surface SDK.

Microsoft introduced a new concept called Tag driven application or Tagged Objects in Surface SDK through which the surface can identify Objects placed over the surface table.Object is printed with some tags that surface engine can read.Tags are either Byte Tags or Identity Tags.

How we can achieve this using Surface SDK?Let’s have a look at that.
I tried a sample by using Tagged Objects in Surface SDK.

Tag Visualization is possible by using these three classes,

  • TagVisualizer – is what actually responding to the Tagged Object and showing up the TagVisualization when placing a tag.
  • TagVisualization - is what we are showing in the surface when a tag is placed in the surface.
  • TagVisualizationDefinition – is using for defining the tag value to which the TagVisualizer will respond and also source, physical location,orientation and other properties of the visualization.

So Let’s try a sample.

  • Create a Surface project from the Visual Studio 2008 Template.
  • In the SurfaceWindow1 add a TagVisualizer.
<s:TagVisualizer Name="TagVisualizer">
....
</s:TagVisualizer> 
  • Add a TagVisualization to the project.Add New Item>TagVisualization.I created TagVisualization SampleTagVisualization,
<s:TagVisualization x:Class="MySurfaceApplication.SampleTagVisualization"          
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"
Loaded="SampleTagVisualization_Loaded">
<Grid Height="400"
 Width="600"
 Background="White">
<TextBlock Text="Some Tagged Object UI here."
          VerticalAlignment="Center"
          HorizontalAlignment="Center"
          Foreground="Red" />
</Grid>
</s:TagVisualization>
  • Add TagVisualizationDefinition to SurfaceWindow1 for TagVisualizer.We can add this either by XAML or from code behind,

Either From XAML,

<s:TagVisualizer Name="TagVisualizer">
<s:TagVisualizer.Definitions>
<s:ByteTagVisualizationDefinition Value="192"
Source="SampleTagVisualization.xaml"
UsesTagOrientation="True"
TagRemovedBehavior="Fade"
PhysicalCenterOffsetFromTag="7.5,4.5"/>
</s:TagVisualizer.Definitions>
</s:TagVisualizer>
or From code behind,(add it in the constructor)
ByteTagVisualizationDefinition tagVisualizationDefinition = new 
ByteTagVisualizationDefinition();
tagVisualizationDefinition.Value = 192;
tagVisualizationDefinition.Source = new Uri("SampleTagVisualization.xaml",
UriKind.Relative);
tagVisualizationDefinition.UsesTagOrientation = true;
tagVisualizationDefinition.TagRemovedBehavior = TagRemovedBehavior.Fade;
tagVisualizationDefinition.PhysicalCenterOffsetFromTag = new 
Vector(7.5, 4.5);
TagVisualizer.Definitions.Add(tagVisualizationDefinition);
Build and Run the application in Surface Simulator.Tag Value is here 192.So give Tag Value as C0 (Hexadecimal). 

License

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

About the Author

Arun Jacob
Software Developer Tata Consultancy Services
India India
I have been working in different .NET Technologies like ASP.NET,WPF,Silverlight for the last few years.I am enjoying my life as a Programmer and spending time with my Family,Friends & Camera.
 
My Technical Blog


My Photo Blog


Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 18 Mar 2010
Article Copyright 2009 by Arun Jacob
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid