优化界面布局和功能增强

在 `AiMessageControll.xaml` 中添加了 `hc:Divider` 控件,调整输入区域布局为 `DockPanel`,并简化发送消息界面。
在 `ImportExcelPage.xaml` 中新增 `DataGridContextMenu` 数据模板,优化 `DataGrid` 的右键菜单功能,并调整 `VirtualizingPanel` 属性。
使用 `hc:Card` 替代 `GridSplitter`,重新组织参数配置布局。
在 `ImportExcelPage.xaml.cs` 中添加按钮事件处理程序以切换配置面板显示状态。
在 `ImportViewModel.cs` 中新增 `_showConfig` 属性以控制配置信息的显示状态。
This commit is contained in:
lihanbo 2025-03-05 09:00:44 +08:00
parent 1f9dd20c87
commit 73ad1cd308
4 changed files with 143 additions and 99 deletions

View File

@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:ExcelHelper.Views.Components" xmlns:local="clr-namespace:ExcelHelper.Views.Components"
xmlns:local1="clr-namespace:ExcelHelper.Converter" xmlns:local1="clr-namespace:ExcelHelper.Converter"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -99,6 +100,12 @@
Foreground="#99000000" Foreground="#99000000"
Text="{Binding Timestamp, StringFormat='{}{0:HH:mm}'}" /> Text="{Binding Timestamp, StringFormat='{}{0:HH:mm}'}" />
</StackPanel> </StackPanel>
<hc:Divider
Height="10"
Margin="0,3"
LineStroke="#000"
LineStrokeThickness="2"
Visibility="{Binding IsUser, Converter={StaticResource Boolean2VisibilityReConverter}}" />
</StackPanel> </StackPanel>
</Border> </Border>
</DataTemplate> </DataTemplate>
@ -107,46 +114,53 @@
</ScrollViewer> </ScrollViewer>
<!-- 输入区 --> <!-- 输入区 -->
<Grid Grid.Row="1" Margin="5"> <Border
<Grid.ColumnDefinitions> Grid.Row="1"
<ColumnDefinition Width="*" /> Margin="8"
<ColumnDefinition Width="Auto" /> Padding="5"
</Grid.ColumnDefinitions> Background="Transparent"
BorderBrush="#000"
<Border BorderThickness="2"
Grid.Column="0" CornerRadius="3">
BorderBrush="#CCCCCC"
BorderThickness="1"
CornerRadius="5">
<StackPanel Grid.Row="1" Background="White">
<TextBox <TextBox
x:Name="MessageInput" x:Name="MessageInput"
MinHeight="40" MinHeight="40"
MaxHeight="120" MaxHeight="120"
Padding="8" Padding="8"
AcceptsReturn="True" AcceptsReturn="True"
Background="Transparent"
BorderThickness="0" BorderThickness="0"
IsEnabled="{Binding IsWaiting, Converter={StaticResource InverseBoolConverter}, UpdateSourceTrigger=PropertyChanged, ElementName=userControl}" IsEnabled="{Binding IsWaiting, Converter={StaticResource InverseBoolConverter}, UpdateSourceTrigger=PropertyChanged, ElementName=userControl}"
KeyDown="MessageInput_KeyDown" KeyDown="MessageInput_KeyDown"
Text="{Binding CurrentMessage, UpdateSourceTrigger=PropertyChanged, ElementName=userControl}" Text="{Binding CurrentMessage, UpdateSourceTrigger=PropertyChanged, ElementName=userControl}"
TextWrapping="Wrap" TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" /> VerticalScrollBarVisibility="Auto" />
</Border> <DockPanel>
<hc:ComboBox Height="30" SelectedIndex="1">
<ComboBoxItem Content="DeepSeek-V3" />
<ComboBoxItem Content="DeepSeek-V3" />
<ComboBoxItem Content="DeepSeek-V3" />
</hc:ComboBox>
<Button
Height="30"
Margin="5"
Padding="15,0"
HorizontalAlignment="Right"
Background="#000"
BorderBrush="Transparent"
BorderThickness="0"
Click="SendButton_Click"
Content="发送 ✈"
Foreground="White"
IsEnabled="{Binding IsWaiting, Converter={StaticResource InverseBoolConverter}, UpdateSourceTrigger=PropertyChanged, ElementName=userControl}" />
<Button </DockPanel>
Grid.Column="1"
Height="40"
Margin="5,0,0,0"
Padding="15,0"
Background="#000"
BorderBrush="Transparent"
BorderThickness="0"
Click="SendButton_Click"
Content="发送"
Foreground="White"
IsEnabled="{Binding IsWaiting, Converter={StaticResource InverseBoolConverter}, UpdateSourceTrigger=PropertyChanged, ElementName=userControl}" />
</Grid>
</StackPanel>
</Border>
<!-- 等待指示器 --> <!-- 等待指示器 -->
<Border <Border
Grid.Row="1" Grid.Row="1"

View File

@ -46,6 +46,11 @@
</Grid> </Grid>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="DataGridContextMenu">
<Menu>
<MenuItem Header="问这一行数据" />
</Menu>
</DataTemplate>
</Page.Resources> </Page.Resources>
<Grid <Grid
AllowDrop="True" AllowDrop="True"
@ -82,22 +87,25 @@
Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}" /> Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}" />
<hc:TabControl <hc:TabControl
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2"
Margin="5,5,7,5" Margin="5,5,7,5"
ShowCloseButton="False" ShowCloseButton="False"
ShowContextMenu="False"> ShowContextMenu="False">
<hc:TabItem Header="预览"> <hc:TabItem Header="预览">
<DataGrid <DataGrid
x:Name="ExcelDataPreviewGrid" x:Name="ExcelDataPreviewGrid"
hc:DataGridAttach.CanUnselectAllWithBlankArea="True"
hc:DataGridAttach.ShowRowNumber="True"
hc:DataGridAttach.ShowSelectAllButton="True"
AutoGenerateColumns="False" AutoGenerateColumns="False"
ContextMenu="{StaticResource DataGridContextMenu}"
EnableColumnVirtualization="True" EnableColumnVirtualization="True"
EnableRowVirtualization="True" EnableRowVirtualization="True"
IsReadOnly="True" IsReadOnly="True"
ItemsSource="{Binding ExcelData, IsAsync=True}" ItemsSource="{Binding ExcelData, IsAsync=True}"
RowHeight="NaN" RowHeight="NaN"
ScrollViewer.CanContentScroll="True" ScrollViewer.CanContentScroll="True"
VirtualizingPanel.IsContainerVirtualizable="True" VirtualizingPanel.ScrollUnit="Pixel" />
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling" />
</hc:TabItem> </hc:TabItem>
<hc:TabItem Header="Columns2Prompt"> <hc:TabItem Header="Columns2Prompt">
@ -126,92 +134,102 @@
</Grid> </Grid>
</hc:TabItem> </hc:TabItem>
</hc:TabControl> </hc:TabControl>
<GridSplitter
Grid.Column="0"
Width="2"
Margin="0,5" />
<hc:Card <hc:Card
x:Name="ConfigCard"
Grid.Column="1" Grid.Column="1"
Width="Auto" Width="Auto"
Height="Auto"
Margin="5" Margin="5"
HorizontalAlignment="Stretch"> HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Opacity="0.95">
<hc:Card.Header> <hc:Card.Header>
<hc:SimpleStackPanel <DockPanel Margin="5">
Margin="5"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock <TextBlock
Margin="5,0" Margin="5,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="参数配置" /> Text="参数配置" />
<Button <Button
HorizontalAlignment="Right"
Click="Button_Click_1"
Content="▼"
DockPanel.Dock="Left" />
</DockPanel>
</hc:Card.Header>
<hc:TransitioningContentControl TransitionMode="Bottom2Top" Visibility="{Binding ShowConfig, Converter={StaticResource BooleanToVisibilityConverter}}">
<hc:SimpleStackPanel SnapsToDevicePixels="True">
<hc:SimpleStackPanel.Resources>
<Style TargetType="{x:Type hc:SimpleStackPanel}">
<Setter Property="Margin" Value="5,5" />
</Style>
</hc:SimpleStackPanel.Resources>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="指定的Sheet" />
<hc:ComboBox
MinWidth="60"
MaxWidth="180"
Margin="0"
ItemsSource="{Binding Sheets}"
SelectedValue="{Binding SelectedSheetName}" />
<Button
Margin="0"
VerticalAlignment="Center"
Command="{Binding ReadSheetsCommand}"
Content="刷新" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Height="Auto" Orientation="Horizontal">
<Label Content="起始位置:" />
<hc:TextBox MinWidth="40" Text="{Binding StartCell}" />
<CheckBox Content="包含列头" IsChecked="{Binding UseHeaderRow}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="结束位置:" />
<hc:TextBox MinWidth="40" Text="{Binding EndCell}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label>
<CheckBox Content="合并的单元格进行填充" IsChecked="{Binding FillMergedCells}" />
</Label>
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="最大读取行数:" />
<hc:NumericUpDown
MinWidth="40"
Maximum="300"
Minimum="0"
Value="{Binding MaxRow}" />
<TextBlock
Margin="5,0"
VerticalAlignment="Center"
Text="预览时最大读取300行" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Width="Auto" Orientation="Horizontal">
<Label Content="当前文件路径:" />
<!--<hc:TextBox MinWidth="200" />-->
<hc:ComboBox
MaxWidth="200"
ItemsSource="{Binding ExcelFiles}"
SelectedValue="{Binding CurrentFilePath}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel
IsEnabled="False"
Orientation="Horizontal"
ToolTip="暂不支持加密的Excel">
<Label Content="Excel密码" />
<PasswordBox MinWidth="60" utils:PasswordBoxHelper.Password="{Binding ExcelPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="?" ToolTip="未加密留空多个Excel如果不同密码请分批次导入" />
</hc:SimpleStackPanel>
<Button
HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
Command="{Binding ReLoadExcelCommand}" Command="{Binding ReLoadExcelCommand}"
Content="重新读取Excel" Content="重新读取Excel"
Style="{StaticResource ButtonPrimary}" /> Style="{StaticResource ButtonPrimary}" />
</hc:SimpleStackPanel> </hc:SimpleStackPanel>
</hc:Card.Header> </hc:TransitioningContentControl>
<hc:SimpleStackPanel SnapsToDevicePixels="True">
<hc:SimpleStackPanel.Resources>
<Style TargetType="{x:Type hc:SimpleStackPanel}">
<Setter Property="Margin" Value="5,5" />
</Style>
</hc:SimpleStackPanel.Resources>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="指定的Sheet" />
<hc:ComboBox
MinWidth="60"
MaxWidth="180"
Margin="0"
ItemsSource="{Binding Sheets}"
SelectedValue="{Binding SelectedSheetName}" />
<Button
Margin="0"
VerticalAlignment="Center"
Command="{Binding ReadSheetsCommand}"
Content="刷新" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Height="Auto" Orientation="Horizontal">
<Label Content="起始位置:" />
<hc:TextBox MinWidth="40" Text="{Binding StartCell}" />
<CheckBox Content="包含列头" IsChecked="{Binding UseHeaderRow}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="结束位置:" />
<hc:TextBox MinWidth="40" Text="{Binding EndCell}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label>
<CheckBox Content="合并的单元格进行填充" IsChecked="{Binding FillMergedCells}" />
</Label>
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="最大读取行数:" />
<hc:NumericUpDown
MinWidth="40"
Maximum="300"
Minimum="0"
Value="{Binding MaxRow}" />
<TextBlock
Margin="5,0"
VerticalAlignment="Center"
Text="预览时最大读取300行" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Width="Auto" Orientation="Horizontal">
<Label Content="当前文件路径:" />
<!--<hc:TextBox MinWidth="200" />-->
<hc:ComboBox
MaxWidth="200"
ItemsSource="{Binding ExcelFiles}"
SelectedValue="{Binding CurrentFilePath}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel IsEnabled="False" Orientation="Horizontal">
<Label Content="Excel密码" />
<PasswordBox MinWidth="60" utils:PasswordBoxHelper.Password="{Binding ExcelPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="?" ToolTip="未加密留空多个Excel如果不同密码请分批次导入" />
</hc:SimpleStackPanel>
</hc:SimpleStackPanel>
</hc:Card> </hc:Card>
<hc:Card Grid.Column="2"> <hc:Card Grid.Column="2">
<!-- Fix: Added Mode=OneWay --> <!-- Fix: Added Mode=OneWay -->

View File

@ -117,4 +117,9 @@ public partial class ImportExcelPage : Page, IView, IRecipient<UpdateDataGridCol
// 标记事件已处理,防止冒泡 // 标记事件已处理,防止冒泡
e.Handled = true; e.Handled = true;
} }
private void Button_Click_1(object sender, System.Windows.RoutedEventArgs e)
{
ViewModel.ShowConfig = !ViewModel.ShowConfig;
}
} }

View File

@ -443,6 +443,13 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
[ObservableProperty] [ObservableProperty]
private string _dbType; private string _dbType;
/// <summary>
/// 是否显示配置信息
/// </summary>
[ObservableProperty]
private bool _showConfig = false;
/// <summary> /// <summary>
/// 加密连接 /// 加密连接
/// </summary> /// </summary>