当标记对象位于三星 SUR40 表上时,无法识别手指和斑点触摸输入



所以,基本上我过滤触摸输入,只识别每个屏幕的手指和标签触摸,除了训练屏幕,我识别手指、标签和斑点触摸。我通过覆盖MainWindow中的OnPreviewTouchDown(TouchEventArgs e)方法来做到这一点,该方法是一个SurfaceWindow。有关重写方法,请参阅下面的代码。

    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 代码,它是设置为 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>

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

最有可能的问题在于输入是对您的标签可视化进行命中测试(您没有向我们展示代码)。 请记住,"透明"命中测试的(使用 Background=null 或 IsHitTestVisible=false 使某些内容不命中测试)

您可以通过运行输入可视化工具来确认这不是硬件/平台问题。

最新更新