Kinect 2.0和WebBrowser(WPF):使用Kinect 2.0与网页交互

时间:2017-01-12 02:32:07

标签: c# wpf visual-studio awesomium kinect-v2

我正在开发一个使用Kinect v2.0进行动作控制的WPF应用程序,例如抓取和滑动以及点击。在这个应用程序中,我有一些元素:

  • UserControl,其中包含Awesomium WebControl
  • 一个窗口,其中包含一个创建上述UserControl并将其放在窗口上的按钮。

我的问题是:虽然我可以使用Kinect点击按钮,但我无法使用它与Awesomium WebControl中加载的网页进行交互。也就是说,我无法点击WebControl内的任何内容,也无法滚动网页。

如何使用Kinect与WebControl进行交互?

修改:哎呀,抱歉,忘记发布我的代码(第一次询问,而且在这里很晚,我已经死了)。这是:

单击按钮时:

private void ButtonClick(object sender, RoutedEventArgs e)
    {
        Button senderButton = (Button)e.Source;
        string name = senderButton.Name;
        name = name.Remove(0, 1); //just getting some values
        int i = int.Parse(name); //same as above
        string url = newsUrl[i];
        var aux = (WebContentBrowser)Activator.CreateInstance(typeof(WebContentBrowser));
        Uri webUrl = new Uri(url);
        aux.webBrowser.Source = webUrl;
        this.navigationRegion.Content = aux;
        this.menuButton.Visibility = System.Windows.Visibility.Visible;
        kinectRegion.Focus();
        this.kinectRegion.InputPointerManager.CompleteGestures();           
        //Window windowWeb = new WindowWeb(url);
        //windowWeb.Show();
    }

问题中提到的Windows的XAML:

<Window x:Class="MuralDigitalKinectWPF.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:k="http://schemas.microsoft.com/kinect/2014"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:MuralDigitalKinectWPF"
    mc:Ignorable="d"
    Title="Mural Digital" Height="720" Width="1366" WindowStartupLocation="CenterScreen" WindowState="Maximized" >
<Window.Background>
    <SolidColorBrush Color="DimGray"/>
</Window.Background>

<k:KinectRegion x:Name="kinectRegion">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Margin="10 0 10 20">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Button x:Name="menuButton" Background="DimGray" Height="68" Width="68" Margin="0,0,0,0" Padding="0 0 0 0" Visibility="Hidden" Click="menuButton_Click">
                <Image Height="64" Width="64" Visibility="Visible" Source="Images/back-navigational-arrow-button-pointing-to-left.png" Margin="0 0 0 0"></Image>
            </Button>
            <k:KinectUserViewer Grid.Column="1" HorizontalAlignment="Center" Height="100" VerticalAlignment="Top"></k:KinectUserViewer>
            <TextBlock Grid.Column="1" Foreground="White" HorizontalAlignment="Right" Margin="0 0 -1 0" VerticalAlignment="Bottom" FontSize="24">Mural Digital</TextBlock>
        </Grid>

        <ContentControl Grid.Row="1" x:Name="navigationRegion">
            <Grid x:Name="kinectRegionGrid" Margin="05 05 05 05">
                <ScrollViewer Grid.Row="0"
                              HorizontalScrollBarVisibility="Auto"
                              VerticalScrollBarVisibility="Disabled"
                              k:KinectRegion.IsScrollInertiaEnabled="True">
                    <ItemsControl Grid.Row="0" Name="itemsControl">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="0 0 0 0" Button.Click ="ButtonClick" ></WrapPanel>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>

                </ScrollViewer>
            </Grid>
        </ContentControl>

    </Grid>

</k:KinectRegion>

UserControl的XAML:

<UserControl xmlns:awe="http://schemas.awesomium.com/winfx"  x:Class="MuralDigitalKinectWPF.WebContentBrowser"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:k ="http://schemas.microsoft.com/kinect/2014"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:MuralDigitalKinectWPF"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">
<Grid x:Name="kinectRegionGrid">
    <awe:WebControl x:Name="webBrowser" />            
</Grid>

0 个答案:

没有答案