重写设置窗口
This commit is contained in:
		
							
								
								
									
										1
									
								
								Data/20250313/20250313_0.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Data/20250313/20250313_0.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  |  | ||||||
							
								
								
									
										124
									
								
								MainWindow.xaml
									
									
									
									
									
								
							
							
						
						
									
										124
									
								
								MainWindow.xaml
									
									
									
									
									
								
							| @@ -6,6 +6,7 @@ | |||||||
|         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||||
|         xmlns:behaviors="clr-namespace:YwxApp.AiChat.Commands" |         xmlns:behaviors="clr-namespace:YwxApp.AiChat.Commands" | ||||||
|         xmlns:ViewModels="clr-namespace:YwxApp.AiChat.ViewModels" |         xmlns:ViewModels="clr-namespace:YwxApp.AiChat.ViewModels" | ||||||
|  |         xmlns:ValueConverter="clr-namespace:YwxApp.AiChat.ValueConverter" | ||||||
|         mc:Ignorable="d" |         mc:Ignorable="d" | ||||||
|         WindowStartupLocation="CenterScreen" |         WindowStartupLocation="CenterScreen" | ||||||
|         Title="ChatAI" Height="600" Width="800" MinHeight="600" MinWidth="800"> |         Title="ChatAI" Height="600" Width="800" MinHeight="600" MinWidth="800"> | ||||||
| @@ -14,6 +15,7 @@ | |||||||
|     </Window.DataContext> |     </Window.DataContext> | ||||||
|     <Window.Resources> |     <Window.Resources> | ||||||
|         <ResourceDictionary> |         <ResourceDictionary> | ||||||
|  |             <ValueConverter:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/> | ||||||
|             <ResourceDictionary.MergedDictionaries> |             <ResourceDictionary.MergedDictionaries> | ||||||
|                 <ResourceDictionary Source="Views/Style/ButtonStyle.xaml"/> |                 <ResourceDictionary Source="Views/Style/ButtonStyle.xaml"/> | ||||||
|             </ResourceDictionary.MergedDictionaries> |             </ResourceDictionary.MergedDictionaries> | ||||||
| @@ -22,67 +24,65 @@ | |||||||
|     <i:Interaction.Behaviors> |     <i:Interaction.Behaviors> | ||||||
|         <behaviors:ClosingWindowBehavior Command="{Binding  ClosingWindowCommand}" /> |         <behaviors:ClosingWindowBehavior Command="{Binding  ClosingWindowCommand}" /> | ||||||
|     </i:Interaction.Behaviors>  |     </i:Interaction.Behaviors>  | ||||||
|     <Grid> |  | ||||||
|         <Grid.ColumnDefinitions> |         <Grid > | ||||||
|             <ColumnDefinition Width="120"/> |             <Grid.ColumnDefinitions> | ||||||
|             <ColumnDefinition Width="*"/> |                 <ColumnDefinition Width="120"/> | ||||||
|             <ColumnDefinition Width="20"/> |                 <ColumnDefinition Width="*"/> | ||||||
|         </Grid.ColumnDefinitions> |                 <ColumnDefinition Width="20"/> | ||||||
|         <Grid.RowDefinitions> |             </Grid.ColumnDefinitions> | ||||||
|             <RowDefinition Height="10"/> |             <Grid.RowDefinitions> | ||||||
|             <RowDefinition Height="*"/> |                 <RowDefinition Height="10"/> | ||||||
|             <RowDefinition Height="25"/> |                 <RowDefinition Height="*"/> | ||||||
|         </Grid.RowDefinitions> |                 <RowDefinition Height="25"/> | ||||||
|         <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"> |             </Grid.RowDefinitions> | ||||||
|             <Rectangle > |             <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"> | ||||||
|                 <Rectangle.Fill> |                 <Rectangle > | ||||||
|                     <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> |                     <Rectangle.Fill> | ||||||
|                         <GradientStop Color="#916CE5" Offset="0.5" /> |                         <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> | ||||||
|                         <GradientStop Color="#FFFFFF" Offset="1.5" /> |                             <GradientStop Color="#916CE5" Offset="0.5" /> | ||||||
|                     </LinearGradientBrush> |                             <GradientStop Color="#FFFFFF" Offset="1.5" /> | ||||||
|                 </Rectangle.Fill> |                         </LinearGradientBrush> | ||||||
|             </Rectangle> |                     </Rectangle.Fill> | ||||||
|  |                 </Rectangle> | ||||||
|  |             </Grid> | ||||||
|  |             <Grid Grid.Row="1"  Grid.Column="0"  > | ||||||
|  |                 <Rectangle  Grid.Row="1" Grid.Column="0"> | ||||||
|  |                     <Rectangle.Fill> | ||||||
|  |                         <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> | ||||||
|  |                             <GradientStop Color="#9ABAFF" Offset="0.8" /> | ||||||
|  |                             <GradientStop Color="#9ABFAF" Offset="0.3" /> | ||||||
|  |                         </LinearGradientBrush> | ||||||
|  |                     </Rectangle.Fill> | ||||||
|  |                 </Rectangle> | ||||||
|  |                 <StackPanel Margin="0 0 0 0"  Grid.Row="1" Grid.Column="0" >  | ||||||
|  |                     <Button Command="{Binding SwitchToViewCommand}" CommandParameter="ChatMdView" Style="{StaticResource IconButtonStyle}"> | ||||||
|  |                         <StackPanel Orientation="Horizontal"> | ||||||
|  |                             <Image Source="/Resources/chat64.png" Margin="5"/> | ||||||
|  |                             <TextBlock Text="会话" VerticalAlignment="Center"/> | ||||||
|  |                         </StackPanel> | ||||||
|  |                     </Button> | ||||||
|  |                 </StackPanel> | ||||||
|  |             </Grid> | ||||||
|  |             <Grid Grid.Row="1" Grid.Column="1" Margin="0"> | ||||||
|  |                 <ContentControl Content="{Binding CurrentView}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/> | ||||||
|  |             </Grid> | ||||||
|  |             <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"> | ||||||
|  |                 <Rectangle> | ||||||
|  |                     <Rectangle.Fill> | ||||||
|  |                         <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> | ||||||
|  |                             <GradientStop Color="#FAAFA9"  Offset="0.1" /> | ||||||
|  |                             <GradientStop Color="#A4D3A2" Offset="0.9" /> | ||||||
|  |                         </LinearGradientBrush> | ||||||
|  |                     </Rectangle.Fill> | ||||||
|  |                 </Rectangle > | ||||||
|  |                 <WrapPanel  Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Center" HorizontalAlignment="Right"> | ||||||
|  |                     <Label Content="{Binding CurrentModel}" Width="auto"  FontSize="12" Margin="5 0 5 0"/> | ||||||
|  |                     <Label Content="{Binding CurrentTime}" Background="#00F0BD" Width="auto"  FontSize="12" Margin="5 0 5 0"/> | ||||||
|  |                 <Button Content="设置" Command="{Binding OpenSettingWindowCommand}"/> | ||||||
|  |                 </WrapPanel> | ||||||
|  |             </Grid> | ||||||
|         </Grid> |         </Grid> | ||||||
|         <Grid Grid.Row="1"  Grid.Column="0"  > |   | ||||||
|             <Rectangle  Grid.Row="1" Grid.Column="0"> |           | ||||||
|                 <Rectangle.Fill> |  | ||||||
|                     <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> |  | ||||||
|                         <GradientStop Color="#9ABAFF" Offset="0.8" /> |  | ||||||
|                         <GradientStop Color="#9ABFAF" Offset="0.3" /> |  | ||||||
|                     </LinearGradientBrush> |  | ||||||
|                 </Rectangle.Fill> |  | ||||||
|             </Rectangle> |  | ||||||
|             <StackPanel Margin="0 0 0 0"  Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center"> |  | ||||||
|                 <Button Command="{Binding SwitchToViewCommand}" CommandParameter="SettingView" Style="{StaticResource IconButtonStyle}"> |  | ||||||
|                     <StackPanel Orientation="Horizontal"> |  | ||||||
|                         <Image Source="/Resources/setting64.png" Margin="5" /> |  | ||||||
|                         <TextBlock Text="设置" VerticalAlignment="Center"/> |  | ||||||
|                     </StackPanel> |  | ||||||
|                 </Button> |  | ||||||
|                 <Button Command="{Binding SwitchToViewCommand}" CommandParameter="ChatMdView" Style="{StaticResource IconButtonStyle}"> |  | ||||||
|                     <StackPanel Orientation="Horizontal"> |  | ||||||
|                         <Image Source="/Resources/chat64.png" Margin="5"/> |  | ||||||
|                         <TextBlock Text="会话" VerticalAlignment="Center"/> |  | ||||||
|                     </StackPanel> |  | ||||||
|                 </Button> |  | ||||||
|             </StackPanel> |  | ||||||
|         </Grid> |  | ||||||
|         <Grid Grid.Row="1" Grid.Column="1" Margin="5">  |  | ||||||
|             <ContentControl Content="{Binding CurrentView}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/> |  | ||||||
|         </Grid>  |  | ||||||
|         <Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"> |  | ||||||
|             <Rectangle> |  | ||||||
|                 <Rectangle.Fill> |  | ||||||
|                     <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> |  | ||||||
|                         <GradientStop Color="#FAAFA9"  Offset="0.1" /> |  | ||||||
|                         <GradientStop Color="#A4D3A2" Offset="0.9" /> |  | ||||||
|                     </LinearGradientBrush> |  | ||||||
|                 </Rectangle.Fill> |  | ||||||
|             </Rectangle > |  | ||||||
|             <WrapPanel  Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Center" HorizontalAlignment="Right"> |  | ||||||
|                 <Label Content="{Binding CurrentModel}" Width="auto"  FontSize="12" Margin="5 0 5 0"/> |  | ||||||
|                 <Label Content="{Binding CurrentTime}" Background="#00F0BD" Width="auto"  FontSize="12" Margin="5 0 5 0"/> |  | ||||||
|             </WrapPanel> |  | ||||||
|         </Grid> |  | ||||||
|     </Grid> |  | ||||||
| </Window> | </Window> | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| using System.Windows; | using System.Windows; | ||||||
|  | using YwxApp.AiChat.ViewModels; | ||||||
|  |  | ||||||
| namespace YwxApp.AiChat; | namespace YwxApp.AiChat; | ||||||
|  |  | ||||||
| @@ -7,11 +8,15 @@ namespace YwxApp.AiChat; | |||||||
| /// </summary> | /// </summary> | ||||||
| public partial class MainWindow : Window | public partial class MainWindow : Window | ||||||
| { | { | ||||||
|  |     MainViewModel viewModel; | ||||||
|     public MainWindow() |     public MainWindow() | ||||||
|     { |     { | ||||||
|         InitializeComponent(); |         InitializeComponent(); | ||||||
|  |         this.viewModel = this.DataContext as MainViewModel; | ||||||
|         //OllamaService ollamaService = new(); |         //OllamaService ollamaService = new(); | ||||||
|         //ollamaService.Configure("http://192.168.1.3:11434", "deepseek-r1:1.5b"); |         //ollamaService.Configure("http://192.168.1.3:11434", "deepseek-r1:1.5b"); | ||||||
|         //this.DataContext = new ChatViewModel(new OllamaService()); |         //this.DataContext = new ChatViewModel(new OllamaService()); | ||||||
|     } |     } | ||||||
|  |       | ||||||
|  |   | ||||||
| } | } | ||||||
							
								
								
									
										20
									
								
								ValueConverter/BoolToVisibilityConverter.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								ValueConverter/BoolToVisibilityConverter.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | using System.Globalization; | ||||||
|  | using System.Windows; | ||||||
|  | using System.Windows.Data; | ||||||
|  |  | ||||||
|  | namespace YwxApp.AiChat.ValueConverter | ||||||
|  | { | ||||||
|  |     public class BoolToVisibilityConverter : IValueConverter | ||||||
|  |     { | ||||||
|  |         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||||||
|  |         { | ||||||
|  |             return (bool)value ? Visibility.Visible : Visibility.Collapsed; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||||||
|  |         { | ||||||
|  |             return (Visibility)value == Visibility.Visible; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -8,7 +8,6 @@ using System.Windows.Input; | |||||||
| using System.Windows.Threading; | using System.Windows.Threading; | ||||||
| using YwxApp.AiChat.Commands; | using YwxApp.AiChat.Commands; | ||||||
| using YwxApp.AiChat.Views;  | using YwxApp.AiChat.Views;  | ||||||
|  |  | ||||||
| namespace YwxApp.AiChat.ViewModels | namespace YwxApp.AiChat.ViewModels | ||||||
| {  | {  | ||||||
|     public class MainViewModel : INotifyPropertyChanged |     public class MainViewModel : INotifyPropertyChanged | ||||||
| @@ -24,6 +23,18 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|         #endregion |         #endregion | ||||||
|  |  | ||||||
|         #region Property |         #region Property | ||||||
|  |           | ||||||
|  |         private Visibility _isMenuOpen = Visibility.Visible; | ||||||
|  |         public Visibility IsMenuOpen | ||||||
|  |         { | ||||||
|  |             get => _isMenuOpen; | ||||||
|  |             set | ||||||
|  |             { | ||||||
|  |                 _isMenuOpen = value; | ||||||
|  |                 OnPropertyChanged(); | ||||||
|  |             } | ||||||
|  |         }  | ||||||
|  |  | ||||||
|         public object CurrentView |         public object CurrentView | ||||||
|         { |         { | ||||||
|             get => _currentView; |             get => _currentView; | ||||||
| @@ -69,6 +80,7 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|         #region Command |         #region Command | ||||||
|         public ICommand SwitchToViewCommand { get; } |         public ICommand SwitchToViewCommand { get; } | ||||||
|         public ICommand ClosingWindowCommand { get; } |         public ICommand ClosingWindowCommand { get; } | ||||||
|  |         public ICommand OpenSettingWindowCommand { get; } | ||||||
|  |  | ||||||
|         #endregion |         #endregion | ||||||
|  |  | ||||||
| @@ -83,10 +95,10 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|             //bind command method |             //bind command method | ||||||
|             SwitchToViewCommand = new ObjectPassingCommand(OnSwitchToView); |             SwitchToViewCommand = new ObjectPassingCommand(OnSwitchToView); | ||||||
|             ClosingWindowCommand = new EventsCommand<CancelEventArgs>(OnClosingWindow); |             ClosingWindowCommand = new EventsCommand<CancelEventArgs>(OnClosingWindow); | ||||||
|  |             OpenSettingWindowCommand = new ObjectPassingCommand(OnOpenSettingWindowCommand); | ||||||
|             //create view |             //create view | ||||||
|             _viewList = new ObservableCollection<UserControl>(); |             _viewList = new ObservableCollection<UserControl>(); | ||||||
|             ViewList.Add(new SettingView(_ollamaObject)); |            | ||||||
|             ViewList.Add(new ChatMdView(_ollamaObject)); |             ViewList.Add(new ChatMdView(_ollamaObject)); | ||||||
|  |  | ||||||
|             //Set the default display of subview 1. |             //Set the default display of subview 1. | ||||||
| @@ -95,6 +107,8 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|             CurrentView = ViewList[0]; |             CurrentView = ViewList[0]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |       | ||||||
|  |  | ||||||
|         #region The window close event  |         #region The window close event  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         ///trigger close event |         ///trigger close event | ||||||
| @@ -137,9 +151,17 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|         #region Command method |         #region Command method | ||||||
|  |  | ||||||
|         #region View switch |         #region View switch | ||||||
|  |  | ||||||
|  |         private void OnOpenSettingWindowCommand(object obj) | ||||||
|  |         { | ||||||
|  |             var setting = new SettingView(_ollamaObject); | ||||||
|  |             setting.ShowDialog(); | ||||||
|  |         } | ||||||
|         //set the view |         //set the view | ||||||
|         public void OnSwitchToView(object operationItem) |         public void OnSwitchToView(object operationItem) | ||||||
|         { |         { | ||||||
|  |             | ||||||
|  |  | ||||||
|             var viewObj = ViewList.FirstOrDefault(viewObj => viewObj.GetType().Name.Equals(operationItem)); |             var viewObj = ViewList.FirstOrDefault(viewObj => viewObj.GetType().Name.Equals(operationItem)); | ||||||
|             if (viewObj == null) |             if (viewObj == null) | ||||||
|             { |             { | ||||||
| @@ -149,9 +171,6 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|                     case "ChatMdView": |                     case "ChatMdView": | ||||||
|                         newViewObj = new ChatMdView(_ollamaObject); |                         newViewObj = new ChatMdView(_ollamaObject); | ||||||
|                         break;  |                         break;  | ||||||
|                     case "SettingView": |  | ||||||
|                         newViewObj = new SettingView(_ollamaObject); |  | ||||||
|                         break; |  | ||||||
|                     default: |                     default: | ||||||
|                         break; |                         break; | ||||||
|                 } |                 } | ||||||
| @@ -173,6 +192,19 @@ namespace YwxApp.AiChat.ViewModels | |||||||
|         { |         { | ||||||
|             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         protected bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string propertyName = null) | ||||||
|  |         { | ||||||
|  |             if (!Equals(field, newValue)) | ||||||
|  |             { | ||||||
|  |                 field = newValue; | ||||||
|  |                 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||||||
|  |                 return true; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             return false; | ||||||
|  |         } | ||||||
|  |           | ||||||
|         #endregion |         #endregion | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ | |||||||
|         <Grid.RowDefinitions> |         <Grid.RowDefinitions> | ||||||
|             <RowDefinition Height="*" /> |             <RowDefinition Height="*" /> | ||||||
|             <RowDefinition Height="120" />  |             <RowDefinition Height="120" />  | ||||||
|             <RowDefinition Height="50" /> |  | ||||||
|         </Grid.RowDefinitions> |         </Grid.RowDefinitions> | ||||||
|  |  | ||||||
|         <!--First line: Display output text to "Markdown" container--> |         <!--First line: Display output text to "Markdown" container--> | ||||||
| @@ -37,6 +36,10 @@ | |||||||
|         </Grid>  |         </Grid>  | ||||||
|         <!-- the second line  --> |         <!-- the second line  --> | ||||||
|         <Grid Grid.Row="1"> |         <Grid Grid.Row="1"> | ||||||
|  |             <Grid.ColumnDefinitions> | ||||||
|  |                 <ColumnDefinition Width="*" /> | ||||||
|  |                 <ColumnDefinition Width="50" /> | ||||||
|  |             </Grid.ColumnDefinitions> | ||||||
|             <TextBox x:Name="InputBox" |             <TextBox x:Name="InputBox" | ||||||
|              Text="{Binding InputText , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  |              Text="{Binding InputText , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  | ||||||
|              Grid.Row="1"  Margin="5" AcceptsReturn="True"  |              Grid.Row="1"  Margin="5" AcceptsReturn="True"  | ||||||
| @@ -46,10 +49,13 @@ | |||||||
|                     <KeyBinding Command="{Binding SubmitQuestionCommand}" Key="Enter"/> |                     <KeyBinding Command="{Binding SubmitQuestionCommand}" Key="Enter"/> | ||||||
|                 </TextBox.InputBindings> |                 </TextBox.InputBindings> | ||||||
|             </TextBox> |             </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> |         </Grid> | ||||||
|  |  | ||||||
|         <!-- The third line: submit button  --> |         <!-- The third line: submit button  --> | ||||||
|         <Grid Grid.Row="2"> |         <!--<Grid Grid.Row="2"> | ||||||
|             <WrapPanel Grid.Row="2"  HorizontalAlignment="Right"> |             <WrapPanel Grid.Row="2"  HorizontalAlignment="Right"> | ||||||
|  |  | ||||||
|                 <Button x:Name="BtnNewChat" Content="新建会话"  |                 <Button x:Name="BtnNewChat" Content="新建会话"  | ||||||
| @@ -65,7 +71,7 @@ | |||||||
|                     Width="100"  |                     Width="100"  | ||||||
|                     Height="30"/> |                     Height="30"/> | ||||||
|             </WrapPanel> |             </WrapPanel> | ||||||
|         </Grid> |         </Grid>--> | ||||||
|  |  | ||||||
|     </Grid> |     </Grid> | ||||||
| </UserControl>  | </UserControl>  | ||||||
|   | |||||||
| @@ -1,10 +1,12 @@ | |||||||
| <UserControl x:Class="YwxApp.AiChat.Views.SettingView" | <Window x:Class="YwxApp.AiChat.SettingView" | ||||||
|              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |         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: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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||||
|              mc:Ignorable="d" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |         xmlns:local="clr-namespace:YwxApp.AiChat" | ||||||
|     <UserControl.Resources> |         mc:Ignorable="d" WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow" | ||||||
|  |         Title="AiChatSetting" Height="360" Width="360"> | ||||||
|  |     <Window.Resources> | ||||||
|         <ResourceDictionary> |         <ResourceDictionary> | ||||||
|             <!--Resource dictionary : add the control style--> |             <!--Resource dictionary : add the control style--> | ||||||
|             <ResourceDictionary.MergedDictionaries> |             <ResourceDictionary.MergedDictionaries> | ||||||
| @@ -14,7 +16,7 @@ | |||||||
|                 <ResourceDictionary Source="Style/ComboBoxStyle.xaml"/> |                 <ResourceDictionary Source="Style/ComboBoxStyle.xaml"/> | ||||||
|             </ResourceDictionary.MergedDictionaries> |             </ResourceDictionary.MergedDictionaries> | ||||||
|         </ResourceDictionary> |         </ResourceDictionary> | ||||||
|     </UserControl.Resources> |     </Window.Resources> | ||||||
|     <Grid Background="#FFFFFF"  HorizontalAlignment="Stretch"> |     <Grid Background="#FFFFFF"  HorizontalAlignment="Stretch"> | ||||||
|         <Grid.ColumnDefinitions> |         <Grid.ColumnDefinitions> | ||||||
|             <ColumnDefinition Width="*" /> |             <ColumnDefinition Width="*" /> | ||||||
| @@ -29,7 +31,7 @@ | |||||||
|             <WrapPanel Margin="5,0,0,0"  VerticalAlignment="Center" HorizontalAlignment="Left"  > |             <WrapPanel Margin="5,0,0,0"  VerticalAlignment="Center" HorizontalAlignment="Left"  > | ||||||
|                 <Label Content="Ollama路径:" Margin="5" HorizontalAlignment="Left"  VerticalAlignment="Center" /> |                 <Label Content="Ollama路径:" Margin="5" HorizontalAlignment="Left"  VerticalAlignment="Center" /> | ||||||
|                 <TextBox x:Name="Tbx_OllamaAppPath"  FontSize="12"  Text="{Binding OllamaAppPath}" Style="{StaticResource SearchBoxStyle}" Margin="5" |                 <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}"  /> |                 <Label Name="Label_State" Style="{StaticResource RoundLabelStyle}"  /> | ||||||
|                 <Button Content="打开"   Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding StartOllamaServerCommand}"/> |                 <Button Content="打开"   Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding StartOllamaServerCommand}"/> | ||||||
| @@ -47,11 +49,11 @@ | |||||||
|         <WrapPanel Grid.Row="2" Margin="5,0,0,0"  VerticalAlignment="Center" HorizontalAlignment="Left" Grid.ColumnSpan="2"> |         <WrapPanel Grid.Row="2" Margin="5,0,0,0"  VerticalAlignment="Center" HorizontalAlignment="Left" Grid.ColumnSpan="2"> | ||||||
|             <Label Content="模型:" VerticalAlignment="Center" Margin="5" /> |             <Label Content="模型:" VerticalAlignment="Center" Margin="5" /> | ||||||
|             <ComboBox x:Name="Cbx_ModelList" Style="{StaticResource RoundComboBoxStyle}" ItemsSource="{Binding ModelList}"  SelectedItem="{Binding SelectedModel}"  |             <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}"/> |             <Button Content="刷新" Margin="5" Grid.Row="1"  Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding ModelListUpdateCommand}"/> | ||||||
|         </WrapPanel> |         </WrapPanel> | ||||||
|  |  | ||||||
|         <TextBox  x:Name="ModelDesciption" Grid.Row="3" IsReadOnly="True"  TextWrapping="WrapWithOverflow" Text="{Binding ModelInformation,Mode=OneWay}" Grid.ColumnSpan="2"/> |         <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> |     </Grid> | ||||||
|  | </Window> | ||||||
|  |  | ||||||
| </UserControl> |  | ||||||
|   | |||||||
| @@ -1,13 +1,12 @@ | |||||||
| using System.Windows.Controls; | using System.Windows; | ||||||
| using YwxApp.AiChat.ViewModels; | using YwxApp.AiChat.ViewModels; | ||||||
|  |  | ||||||
| namespace YwxApp.AiChat.Views | namespace YwxApp.AiChat | ||||||
| { | { | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// SettingView.xaml 的交互逻辑 |     /// SettingView.xaml 的交互逻辑 | ||||||
|     /// </summary> |     /// </summary> | ||||||
|  |     public partial class SettingView : Window | ||||||
|     public partial class SettingView : UserControl |  | ||||||
|     { |     { | ||||||
|         SettingViewModel _viewModel; |         SettingViewModel _viewModel; | ||||||
|         public SettingView(ShareOllamaObject ollama) |         public SettingView(ShareOllamaObject ollama) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user