重写设置窗口

This commit is contained in:
yangwx
2025-03-13 01:06:32 +08:00
parent ca08aa615c
commit 296d450496
8 changed files with 160 additions and 95 deletions

View File

@@ -18,8 +18,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="120" />
<RowDefinition Height="50" />
<RowDefinition Height="120" />
</Grid.RowDefinitions>
<!--First line: Display output text to "Markdown" container-->
@@ -37,6 +36,10 @@
</Grid>
<!-- the second line -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<TextBox x:Name="InputBox"
Text="{Binding InputText , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1" Margin="5" AcceptsReturn="True"
@@ -46,10 +49,13 @@
<KeyBinding Command="{Binding SubmitQuestionCommand}" Key="Enter"/>
</TextBox.InputBindings>
</TextBox>
<Button x:Name="BtnSubmit" Content="提交" FontSize="18" Margin="5"
Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1"
Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding SubmitQuestionCommand}" />
</Grid>
<!-- The third line submit button -->
<Grid Grid.Row="2">
<!--<Grid Grid.Row="2">
<WrapPanel Grid.Row="2" HorizontalAlignment="Right">
<Button x:Name="BtnNewChat" Content="新建会话"
@@ -65,7 +71,7 @@
Width="100"
Height="30"/>
</WrapPanel>
</Grid>
</Grid>-->
</Grid>
</UserControl>

View File

@@ -1,10 +1,12 @@
<UserControl x:Class="YwxApp.AiChat.Views.SettingView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<UserControl.Resources>
<Window x:Class="YwxApp.AiChat.SettingView"
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:YwxApp.AiChat"
mc:Ignorable="d" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow"
Title="AiChatSetting" Height="360" Width="360">
<Window.Resources>
<ResourceDictionary>
<!--Resource dictionary : add the control style-->
<ResourceDictionary.MergedDictionaries>
@@ -14,7 +16,7 @@
<ResourceDictionary Source="Style/ComboBoxStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
</Window.Resources>
<Grid Background="#FFFFFF" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
@@ -29,8 +31,8 @@
<WrapPanel Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" >
<Label Content="Ollama路径:" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBox x:Name="Tbx_OllamaAppPath" FontSize="12" Text="{Binding OllamaAppPath}" Style="{StaticResource SearchBoxStyle}" Margin="5"
MinWidth="180" VerticalAlignment="Center" VerticalContentAlignment="Center" />
MinWidth="180" VerticalAlignment="Center" VerticalContentAlignment="Center" />
<Label Name="Label_State" Style="{StaticResource RoundLabelStyle}" />
<Button Content="打开" Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding StartOllamaServerCommand}"/>
</WrapPanel>
@@ -47,11 +49,11 @@
<WrapPanel Grid.Row="2" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.ColumnSpan="2">
<Label Content="模型:" VerticalAlignment="Center" Margin="5" />
<ComboBox x:Name="Cbx_ModelList" Style="{StaticResource RoundComboBoxStyle}" ItemsSource="{Binding ModelList}" SelectedItem="{Binding SelectedModel}"
MinWidth="180" VerticalAlignment="Center" VerticalContentAlignment="Center" />
MinWidth="180" VerticalAlignment="Center" VerticalContentAlignment="Center" />
<Button Content="刷新" Margin="5" Grid.Row="1" Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding ModelListUpdateCommand}"/>
</WrapPanel>
<TextBox x:Name="ModelDesciption" Grid.Row="3" IsReadOnly="True" TextWrapping="WrapWithOverflow" Text="{Binding ModelInformation,Mode=OneWay}" Grid.ColumnSpan="2"/>
<ListBox x:Name="ModelList" Grid.Row="3" ItemsSource="{Binding ModelList}" SelectedItem="{Binding SelectedModel}"/>
</Grid>
</UserControl>
</Window>

View File

@@ -1,13 +1,12 @@
using System.Windows.Controls;
using System.Windows;
using YwxApp.AiChat.ViewModels;
namespace YwxApp.AiChat.Views
namespace YwxApp.AiChat
{
/// <summary>
/// SettingView.xaml 的交互逻辑
/// </summary>
public partial class SettingView : UserControl
public partial class SettingView : Window
{
SettingViewModel _viewModel;
public SettingView(ShareOllamaObject ollama)