151 lines
7.8 KiB
XML
151 lines
7.8 KiB
XML
<Window x:Class="BaiduSearchApp.MainWindow"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:local="clr-namespace:BaiduSearchApp"
|
|
xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
|
mc:Ignorable="d"
|
|
Title="百度智能搜索"
|
|
Height="800"
|
|
Width="1000"
|
|
WindowStartupLocation="CenterScreen">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- 搜索区域 -->
|
|
<Border Grid.Row="0" Margin="10" Background="#F0F0F0" CornerRadius="5">
|
|
<Grid>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<Grid Grid.Row="0" Margin="5">
|
|
<TextBox x:Name="txtApiKey" Margin="0" Padding="10"
|
|
FontSize="14" VerticalAlignment="Center"
|
|
TextChanged="TxtApiKey_TextChanged"/>
|
|
<TextBlock Text="请输入百度千帆API Key" FontSize="14"
|
|
Margin="15,0,0,0" VerticalAlignment="Center"
|
|
Foreground="#999999" IsHitTestVisible="False"
|
|
x:Name="txtApiKeyPlaceholder"/>
|
|
</Grid>
|
|
|
|
<Grid Grid.Row="1" Margin="5">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<Grid Grid.Column="0">
|
|
<TextBox x:Name="txtSearchQuery" Padding="10"
|
|
FontSize="16" VerticalAlignment="Center"
|
|
KeyDown="TxtSearchQuery_KeyDown"
|
|
TextChanged="TxtSearchQuery_TextChanged"/>
|
|
<TextBlock Text="请输入搜索内容" FontSize="16"
|
|
Margin="15,0,0,0" VerticalAlignment="Center"
|
|
Foreground="#999999" IsHitTestVisible="False"
|
|
x:Name="txtSearchQueryPlaceholder"/>
|
|
</Grid>
|
|
|
|
<Button x:Name="btnSearch" Grid.Column="1" Margin="5,0,0,0"
|
|
Content="搜索" FontSize="16" Padding="20,10"
|
|
Click="BtnSearch_Click" Background="#2577FF" Foreground="White"/>
|
|
</Grid>
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- 主内容区域 - 分为左右两栏 -->
|
|
<Grid Grid.Row="1" Margin="10">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="5"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- 左侧搜索结果区域 -->
|
|
<Grid Grid.Column="0">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<TextBlock Grid.Row="0" x:Name="txtStatus" Margin="5"
|
|
FontSize="14" Foreground="#666"/>
|
|
|
|
<ListView Grid.Row="1" x:Name="lvSearchResults" Margin="5" MouseDoubleClick="LvSearchResults_MouseDoubleClick">
|
|
<ListView.ItemTemplate>
|
|
<DataTemplate>
|
|
<Border BorderBrush="#E0E0E0" BorderThickness="0,0,0,1" Padding="5">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<TextBlock Grid.Row="0" Text="{Binding Title}"
|
|
FontSize="16" FontWeight="Bold"
|
|
Foreground="#1A0DAB" Margin="0,5,0,0"/>
|
|
|
|
<TextBlock Grid.Row="1" Text="{Binding Url}"
|
|
FontSize="12" Foreground="#006621"
|
|
Margin="0,2,0,0"/>
|
|
|
|
<TextBlock Grid.Row="2" Text="{Binding Date}"
|
|
FontSize="12" Foreground="#666"
|
|
Margin="0,2,0,0"/>
|
|
|
|
<TextBlock Grid.Row="3" Text="{Binding Content}"
|
|
FontSize="14" Foreground="#333"
|
|
Margin="0,5,0,10"
|
|
TextWrapping="Wrap"/>
|
|
</Grid>
|
|
</Border>
|
|
</DataTemplate>
|
|
</ListView.ItemTemplate>
|
|
</ListView>
|
|
|
|
<!-- 翻页控件 -->
|
|
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="5">
|
|
<Button x:Name="btnPrevPage" Content="上一页" Margin="5" Click="BtnPrevPage_Click" IsEnabled="False"/>
|
|
<TextBlock x:Name="txtPageInfo" Margin="5" VerticalAlignment="Center" FontSize="14"/>
|
|
<Button x:Name="btnNextPage" Content="下一页" Margin="5" Click="BtnNextPage_Click" IsEnabled="False"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
|
|
<!-- 分割线 -->
|
|
<GridSplitter Grid.Column="1" Background="#E0E0E0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
|
|
|
|
<!-- 右侧内置浏览器区域 -->
|
|
<Grid Grid.Column="2">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- 浏览器地址栏 -->
|
|
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5">
|
|
<Button x:Name="btnBack" Content="←" Margin="5" Click="BtnBack_Click" IsEnabled="False"/>
|
|
<Button x:Name="btnForward" Content="→" Margin="5" Click="BtnForward_Click" IsEnabled="False"/>
|
|
<Button x:Name="btnRefresh" Content="刷新" Margin="5" Click="BtnRefresh_Click"/>
|
|
<TextBox x:Name="txtBrowserUrl" Margin="5" VerticalAlignment="Center" FontSize="14" IsReadOnly="True"/>
|
|
<Button x:Name="btnGo" Content="前往" Margin="5" Click="BtnGo_Click"/>
|
|
<Button x:Name="btnCloseBrowser" Content="关闭" Margin="5" Click="BtnCloseBrowser_Click"/>
|
|
</StackPanel>
|
|
|
|
<!-- WebView2 控件 -->
|
|
<wv2:WebView2 x:Name="webView" Grid.Row="1" Margin="5" />
|
|
</Grid>
|
|
</Grid>
|
|
</Grid>
|
|
</Window> |