From 999ed5c45975fd3c7e8685856b142345fffaf466 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BO4HSG\\ksat" Date: Sat, 14 Jan 2023 17:30:16 +0800 Subject: [PATCH] chore: add setting view --- STranslate/STranslate.csproj | 8 +++++++ STranslate/View/MainWindow.xaml | 3 --- STranslate/View/MainWindow.xaml.cs | 16 ++++++++++++++ STranslate/View/SettingsWindow.xaml | 29 ++++++++++++++++++++++++++ STranslate/View/SettingsWindow.xaml.cs | 27 ++++++++++++++++++++++++ STranslate/ViewModel/SettingsVM.cs | 27 ++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 STranslate/View/SettingsWindow.xaml create mode 100644 STranslate/View/SettingsWindow.xaml.cs create mode 100644 STranslate/ViewModel/SettingsVM.cs diff --git a/STranslate/STranslate.csproj b/STranslate/STranslate.csproj index c3dde3d..8485ea9 100644 --- a/STranslate/STranslate.csproj +++ b/STranslate/STranslate.csproj @@ -106,9 +106,13 @@ + ScreenShotWindow.xaml + + SettingsWindow.xaml + MSBuild:Compile Designer @@ -157,6 +161,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + diff --git a/STranslate/View/MainWindow.xaml b/STranslate/View/MainWindow.xaml index 1684d89..f7cea73 100644 --- a/STranslate/View/MainWindow.xaml +++ b/STranslate/View/MainWindow.xaml @@ -3,10 +3,7 @@ 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" - xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" - xmlns:vm="clr-namespace:STranslate.ViewModel" - xmlns:local="clr-namespace:STranslate.View" mc:Ignorable="d" x:Name="Mwin" Background="Transparent" diff --git a/STranslate/View/MainWindow.xaml.cs b/STranslate/View/MainWindow.xaml.cs index 3fbd424..a1d403f 100644 --- a/STranslate/View/MainWindow.xaml.cs +++ b/STranslate/View/MainWindow.xaml.cs @@ -101,6 +101,9 @@ namespace STranslate.View var autoStartBtn = new MenuItem("开机自启"); autoStartBtn.Click += AutoStart_Click; + var preferenceBtn = new MenuItem("首选项"); + preferenceBtn.Click += Preference_Click; + autoStartBtn.Checked = StartupHelper.IsStartup(); var exitBtn = new MenuItem("退出"); @@ -113,11 +116,24 @@ namespace STranslate.View openMainWinBtn, checkUpdateBtn, autoStartBtn, + preferenceBtn, exitBtn, }; NotifyIcon.ContextMenu = new ContextMenu(items); } + /// + /// 设置 + /// + /// + /// + private void Preference_Click(object sender, EventArgs e) + { + var setting = new SettingsWindow(); + setting.Show(); + setting.Activate(); + } + /// /// 同步Github版本命名 /// diff --git a/STranslate/View/SettingsWindow.xaml b/STranslate/View/SettingsWindow.xaml new file mode 100644 index 0000000..8366213 --- /dev/null +++ b/STranslate/View/SettingsWindow.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + diff --git a/STranslate/View/SettingsWindow.xaml.cs b/STranslate/View/SettingsWindow.xaml.cs new file mode 100644 index 0000000..0d5da45 --- /dev/null +++ b/STranslate/View/SettingsWindow.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace STranslate.View +{ + /// + /// SettingsWindow.xaml 的交互逻辑 + /// + public partial class SettingsWindow : Window + { + public SettingsWindow() + { + InitializeComponent(); + } + } +} diff --git a/STranslate/ViewModel/SettingsVM.cs b/STranslate/ViewModel/SettingsVM.cs new file mode 100644 index 0000000..4ae8a41 --- /dev/null +++ b/STranslate/ViewModel/SettingsVM.cs @@ -0,0 +1,27 @@ +using STranslate.Helper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace STranslate.ViewModel +{ + public class SettingsVM : BaseVM + { + public SettingsVM() + { + LoadedCmd = new RelayCommand((_) => true, (_) => + { + Console.WriteLine("123"); + }); + ClosedCmd = new RelayCommand((_) => true, (_) => + { + Console.WriteLine("123"); + }); + } + public ICommand LoadedCmd { get; private set; } + public ICommand ClosedCmd { get; private set; } + } +}