标记对象位于Samsung SUR40表上时无法识别手指和Blob触摸输入

时间:2013-09-19 15:28:39

标签: c# wpf pixelsense

所以,基本上我过滤触摸输入只能识别每个屏幕上的手指和标记触摸,除了我识别手指,标记和Blob触摸的训练屏幕。我通过覆盖MainWindow中的一个SurfaceWindow中的OnPreviewTouchDown(TouchEventArgs e)方法来实现这一点。请参阅下面的代码以了解覆盖方法。

    protected override void OnPreviewTouchDown(TouchEventArgs e)
    {

        bool isFinger = e.TouchDevice.GetIsFingerRecognized();
        bool isTag = e.TouchDevice.GetIsTagRecognized();
        //Allows all touches on Train Screen. Only fingers and tags everywhere else
        if (e.Source.ToString() != "dtt_app.TrainScreen")
        {
            if (isFinger == false && isTag == false)
            {
                e.Handled = true;
                return;
            }
        }
       base.OnPreviewTouchDown(e);
    }

这就是我的令牌可视化代码的样子

        for (int i = 1; i < 10; i++)
        {
            TagVisualizationDefinition TokenTagDef =
                    new TagVisualizationDefinition();
            // The tag value that this definition will respond to.
            TokenTagDef.Value = i;
            // The .xaml file for the UI
            TokenTagDef.Source =
                new Uri("TokenVisualization.xaml", UriKind.Relative);
            // The maximum number for this tag value.
            TokenTagDef.MaxCount = 100;
            // Orientation offset (default).
            TokenTagDef.OrientationOffsetFromTag = 0.0;
            // Physical offset (horizontal inches, vertical inches).
            TokenTagDef.PhysicalCenterOffsetFromTag = new Vector(0.0, 0.0);
            // Tag removal behavior (default).
            TokenTagDef.TagRemovedBehavior = TagRemovedBehavior.Fade;
            // Orient UI to tag? (default).
            TokenTagDef.UsesTagOrientation = true;

            // Add the definition to the collection.
            MyTagVisualizer.Definitions.Add(TokenTagDef);

        }

这是TrainScreen的XAML代码,它是一个UserControl,设置为MainWindow的内容

<UserControl x:Class="dtt_app.TrainScreen"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:s="http://schemas.microsoft.com/surface/2008"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <s:TagVisualizer
            Name="MyTagVisualizer" 
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            Background="Transparent" 
            Height="Auto" Width="Auto"
            VisualizationAdded="OnVisualizationAdded">

        <Canvas Name="canvas" Width="{Binding ElementName=topWindow, Path=ActualWidth}" Height="{Binding ElementName=topWindow, Path=ActualHeight}">
        <Label Width ="500" Canvas.Top="100" Content="Label" Name="Instruction" FontSize="30" HorizontalContentAlignment="Center"/>
        <Popup Name="Positive" Width="240" Height="200" Placement="MousePoint" AllowsTransparency="True" IsEnabled="True" IsOpen="False">
            <Image Source="images/SmileyFace.png">
            </Image>
        </Popup>
        <Popup Name="Negative" Width="240" Height="200" Placement="MousePoint" IsEnabled="True" AllowsTransparency="True" IsOpen="False">
            <Image Source="images/SadFace.png">
            </Image>
        </Popup>
    </Canvas>
    </s:TagVisualizer>
    </Grid>
</UserControl>

我不知道为什么只要标记对象在桌面上就无法识别任何触摸输入。任何有关这方面的帮助将不胜感激。请。我已经用尽了所有可能性,而且我真的需要弄清楚这一点,因为时间已经不多了。提前谢谢。

1 个答案:

答案 0 :(得分:0)

最有可能的问题是输入是针对您的标签化的测试(您没有向我们展示代码)。请记住,“透明”点击测试(使用Background = null或IsHitTestVisible = false来制作未经测试的内容)

通过运行输入展示台工具,您可以确认它不是硬件/平台问题。