我正在开发一个 WPF 应用程序,它使用 Kinect v2.0 进行运动控制,如抓取和滑动和单击。在这个应用程序中,我有一些元素:
- 一个 UserControl,其中包含一个 Awesomium WebControl
- 一个 Window,其中包含一个按钮,该按钮创建上述 UserControl 并将其放在 Window 上。
我的问题是:虽然我可以使用 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>