Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF Surface tagged objects recognization in grid

$
0
0

I have a WPF Surface 2.0 project which recognizes when either a finger, blob or tagged object is placed on the screen and display on the screen what it is in a label.

What I'm trying to achieve is that I have in the center of the screen a 200x200 white grid named TagGrid. I then want when a tagged object is placed inside the grid it recognizes this and then outputs to the label for example "Tagged object placed in grid" but only if tagged object is placed inside the grid boundaries and no where else. 

Or if this is not possible, then how would i be able to set boundaries on where i want a tagged object to placed. I tried looking at bounding boxes couldn't seem to get anything go..

But with regards to the grid, i think inside the event handler of c# code there needs to be another if statement but i'm unsure how to use the correct syntax.

Full XAML

<s:SurfaceWindow x:Class="SurfaceRecognition.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="SurfaceRecognition"><Grid x:Name="MainGrid"
      Background="{StaticResource WindowBackground2}"><Label x:Name="InfoLabel"
           Foreground="Red"
           Margin="150,150,0,0" /><s:TagVisualizer x:Name="TagVisualizer1"><Grid Name="TagGrid"
              Height=" 200"
              Width="200"
              Background="White" /><s:TagVisualizer.Definitions> <s:TagVisualizationDefinition
                Value="1"
                Source="SimpleVisualization.xaml"
                LostTagTimeout="2000" 
                OrientationOffsetFromTag="0"
                PhysicalCenterOffsetFromTag="0,-1.5"
                UsesTagOrientation="True" 
                TagRemovedBehavior="Fade"
                /><s:TagVisualizationDefinition
                Series="0x17E235BFBCF17A07"
                Source="SimpleVisualization.xaml"
                LostTagTimeout="2000" 
                OrientationOffsetFromTag="0"
                PhysicalCenterOffsetFromTag="0,-1.5"
                UsesTagOrientation="True" 
                TagRemovedBehavior="Fade" /></s:TagVisualizer.Definitions></s:TagVisualizer></Grid></s:SurfaceWindow>

The event method in C#

voidSurfaceWindow1_TouchDown(object sender,TouchEventArgs e){TouchDevice c = e.TouchDevice;string type =" ";if(c.GetIsTagRecognized()==true){
            type ="Tag has been placed";
            type +=(" Series: "+ c.GetTagData().Series.ToString("X",CultureInfo.InvariantCulture));
            type +=(" Value: "+ c.GetTagData().Value.ToString("X",CultureInfo.InvariantCulture));if(c.GetTagData().Series==1&& c.GetTagData().Value==1){
        type =("This tagged object has a tag series of 1 & and a tag value of 1");}}elseif(c.GetIsFingerRecognized()){
            type ="Finger is pressed";}InfoLabel.Content= type;}

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>