diff --git a/Data/20250313/20250313_0.txt b/Data/20250313/20250313_0.txt
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/Data/20250313/20250313_0.txt
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/MainWindow.xaml b/MainWindow.xaml
index d40905d..c11dce4 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -6,6 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:behaviors="clr-namespace:YwxApp.AiChat.Commands"
xmlns:ViewModels="clr-namespace:YwxApp.AiChat.ViewModels"
+ xmlns:ValueConverter="clr-namespace:YwxApp.AiChat.ValueConverter"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="ChatAI" Height="600" Width="800" MinHeight="600" MinWidth="800">
@@ -14,75 +15,74 @@
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index f6e2224..e9f19ad 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
using System.Windows;
+using YwxApp.AiChat.ViewModels;
namespace YwxApp.AiChat;
@@ -7,11 +8,15 @@ namespace YwxApp.AiChat;
///
public partial class MainWindow : Window
{
+ MainViewModel viewModel;
public MainWindow()
{
InitializeComponent();
+ this.viewModel = this.DataContext as MainViewModel;
//OllamaService ollamaService = new();
//ollamaService.Configure("http://192.168.1.3:11434", "deepseek-r1:1.5b");
//this.DataContext = new ChatViewModel(new OllamaService());
}
+
+
}
\ No newline at end of file
diff --git a/ValueConverter/BoolToVisibilityConverter.cs b/ValueConverter/BoolToVisibilityConverter.cs
new file mode 100644
index 0000000..1cd5c3e
--- /dev/null
+++ b/ValueConverter/BoolToVisibilityConverter.cs
@@ -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;
+ }
+ }
+
+}
diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs
index c0e8b5a..765ef4e 100644
--- a/ViewModels/MainViewModel.cs
+++ b/ViewModels/MainViewModel.cs
@@ -7,8 +7,7 @@ using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using YwxApp.AiChat.Commands;
-using YwxApp.AiChat.Views;
-
+using YwxApp.AiChat.Views;
namespace YwxApp.AiChat.ViewModels
{
public class MainViewModel : INotifyPropertyChanged
@@ -24,6 +23,18 @@ namespace YwxApp.AiChat.ViewModels
#endregion
#region Property
+
+ private Visibility _isMenuOpen = Visibility.Visible;
+ public Visibility IsMenuOpen
+ {
+ get => _isMenuOpen;
+ set
+ {
+ _isMenuOpen = value;
+ OnPropertyChanged();
+ }
+ }
+
public object CurrentView
{
get => _currentView;
@@ -69,6 +80,7 @@ namespace YwxApp.AiChat.ViewModels
#region Command
public ICommand SwitchToViewCommand { get; }
public ICommand ClosingWindowCommand { get; }
+ public ICommand OpenSettingWindowCommand { get; }
#endregion
@@ -83,10 +95,10 @@ namespace YwxApp.AiChat.ViewModels
//bind command method
SwitchToViewCommand = new ObjectPassingCommand(OnSwitchToView);
ClosingWindowCommand = new EventsCommand(OnClosingWindow);
-
+ OpenSettingWindowCommand = new ObjectPassingCommand(OnOpenSettingWindowCommand);
//create view
_viewList = new ObservableCollection();
- ViewList.Add(new SettingView(_ollamaObject));
+
ViewList.Add(new ChatMdView(_ollamaObject));
//Set the default display of subview 1.
@@ -95,6 +107,8 @@ namespace YwxApp.AiChat.ViewModels
CurrentView = ViewList[0];
}
+
+
#region The window close event
///
///trigger close event
@@ -137,9 +151,17 @@ namespace YwxApp.AiChat.ViewModels
#region Command method
#region View switch
+
+ private void OnOpenSettingWindowCommand(object obj)
+ {
+ var setting = new SettingView(_ollamaObject);
+ setting.ShowDialog();
+ }
//set the view
public void OnSwitchToView(object operationItem)
{
+
+
var viewObj = ViewList.FirstOrDefault(viewObj => viewObj.GetType().Name.Equals(operationItem));
if (viewObj == null)
{
@@ -148,10 +170,7 @@ namespace YwxApp.AiChat.ViewModels
{
case "ChatMdView":
newViewObj = new ChatMdView(_ollamaObject);
- break;
- case "SettingView":
- newViewObj = new SettingView(_ollamaObject);
- break;
+ break;
default:
break;
}
@@ -173,6 +192,19 @@ namespace YwxApp.AiChat.ViewModels
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
+
+ protected bool SetProperty(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
}
diff --git a/Views/ChatMdView.xaml b/Views/ChatMdView.xaml
index 9fd4702..1e18c47 100644
--- a/Views/ChatMdView.xaml
+++ b/Views/ChatMdView.xaml
@@ -18,8 +18,7 @@
-
-
+
@@ -37,6 +36,10 @@
+
+
+
+
+
-
+
diff --git a/Views/SettingView.xaml b/Views/SettingView.xaml
index 543e81d..913a5bf 100644
--- a/Views/SettingView.xaml
+++ b/Views/SettingView.xaml
@@ -1,10 +1,12 @@
-
-
+
+
@@ -14,7 +16,7 @@
-
+
@@ -29,8 +31,8 @@
-
+ MinWidth="180" VerticalAlignment="Center" VerticalContentAlignment="Center" />
+
@@ -47,11 +49,11 @@
+ MinWidth="180" VerticalAlignment="Center" VerticalContentAlignment="Center" />
+
+
-
-
-
\ No newline at end of file
+
diff --git a/Views/SettingView.xaml.cs b/Views/SettingView.xaml.cs
index 606c06b..ac1d115 100644
--- a/Views/SettingView.xaml.cs
+++ b/Views/SettingView.xaml.cs
@@ -1,13 +1,12 @@
-using System.Windows.Controls;
+using System.Windows;
using YwxApp.AiChat.ViewModels;
-namespace YwxApp.AiChat.Views
+namespace YwxApp.AiChat
{
///
/// SettingView.xaml 的交互逻辑
///
-
- public partial class SettingView : UserControl
+ public partial class SettingView : Window
{
SettingViewModel _viewModel;
public SettingView(ShareOllamaObject ollama)