From 3483bf88c205dde85a90dfc866202e685de4ef53 Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 13 Dec 2021 13:03:50 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E5=85=A8=E5=85=B3=E9=97=AD=E8=BF=9B=E7=A8=8B=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainWindow.xaml | 2 +- MainWindow.xaml.cs | 4 ++++ Thread/MouseHookThread.cs | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/MainWindow.xaml b/MainWindow.xaml index affd2ab..b0077bc 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -124,7 +124,7 @@ - + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index aac0568..ab49a8a 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -426,6 +426,7 @@ namespace GeekDesk /// private void ExitApp(object sender, RoutedEventArgs e) { + MouseHookThread.Dispose(); Application.Current.Shutdown(); } @@ -506,10 +507,13 @@ namespace GeekDesk /// private void ReStartApp(object sender, RoutedEventArgs e) { + MouseHookThread.Dispose(); + Process p = new Process(); p.StartInfo.FileName = Constants.APP_DIR + Constants.MY_NAME + ".exe"; p.StartInfo.WorkingDirectory = Constants.APP_DIR; p.Start(); + Application.Current.Shutdown(); } diff --git a/Thread/MouseHookThread.cs b/Thread/MouseHookThread.cs index 8bb3a37..33be9de 100644 --- a/Thread/MouseHookThread.cs +++ b/Thread/MouseHookThread.cs @@ -15,19 +15,28 @@ namespace GeekDesk.Thread public class MouseHookThread { private static AppConfig appConfig = MainWindow.appData.AppConfig; - public static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents(); - + private static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents(); + private static Dispatcher dispatcher; + + public static void MiddleHook() { //使用dispatcher来单独监听UI线程 防止程序卡顿 - Dispatcher dispatcher = DispatcherBuild.Build(); + dispatcher = DispatcherBuild.Build(); dispatcher.Invoke((Action)(() => { m_GlobalHook.MouseDownExt += M_GlobalHook_MouseDownExt; })); } + public static void Dispose() + { + m_GlobalHook.MouseDownExt -= M_GlobalHook_MouseDownExt; + m_GlobalHook.Dispose(); + dispatcher.InvokeShutdown(); + } + /// /// 鼠标中键呼出 /// From e6a95c4668ac436a08c8d544bc1d5d7dc9cd954e Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 20 Dec 2021 09:39:27 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Esc=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 2 +- Constant/Constants.cs | 2 +- .../PannelCard/LeftCardControl.xaml.cs | 9 ++-- Control/Windows/ConfigWindow.xaml | 2 + Control/Windows/ConfigWindow.xaml.cs | 12 ++++- Control/Windows/IconfontWindow.xaml | 44 +++++++++--------- Control/Windows/IconfontWindow.xaml.cs | 13 +++++- Control/Windows/ToDoInfoWindow.xaml | 5 ++- Control/Windows/ToDoInfoWindow.xaml.cs | 13 +++++- Control/Windows/ToDoWindow.xaml | 2 + Control/Windows/ToDoWindow.xaml.cs | 12 ++++- Control/Windows/UpdateWindow.xaml | 5 ++- Control/Windows/UpdateWindow.xaml.cs | 12 ++++- GeekDesk.csproj | 1 + Interface/WindowCommon.cs | 15 +++++++ MainWindow.xaml | 7 ++- MainWindow.xaml.cs | 45 +++++-------------- Properties/AssemblyInfo.cs | 4 +- Update.json | 6 +-- 19 files changed, 136 insertions(+), 75 deletions(-) create mode 100644 Interface/WindowCommon.cs diff --git a/App.config b/App.config index 544efdc..8705f81 100644 --- a/App.config +++ b/App.config @@ -28,7 +28,7 @@ - + diff --git a/Constant/Constants.cs b/Constant/Constants.cs index eae0885..1cda463 100644 --- a/Constant/Constants.cs +++ b/Constant/Constants.cs @@ -11,7 +11,7 @@ namespace GeekDesk.Constant public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim(); // 是否为开发模式 - public static bool DEV = false; + public static bool DEV = true; public static string MY_NAME = DEV ? "GeekDesk-D" : "GeekDesk"; diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs index ec537e4..dbe4646 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs @@ -28,11 +28,11 @@ namespace GeekDesk.Control.UserControls.PannelCard if (appData.AppConfig.SelectedMenuIndex >= appData.MenuList.Count || appData.AppConfig.SelectedMenuIndex == -1) { appData.AppConfig.SelectedMenuIcons = appData.MenuList[0].IconList; - } else + } + else { appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList; } - } DelegateCommand _swap; @@ -207,8 +207,9 @@ namespace GeekDesk.Control.UserControls.PannelCard //设置对应菜单的图标列表 if (MenuListBox.SelectedIndex == -1) { - appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count-1].IconList; - } else + appData.AppConfig.SelectedMenuIcons = appData.MenuList[appData.MenuList.Count - 1].IconList; + } + else { appData.AppConfig.SelectedMenuIcons = appData.MenuList[MenuListBox.SelectedIndex].IconList; } diff --git a/Control/Windows/ConfigWindow.xaml b/Control/Windows/ConfigWindow.xaml index 73cd8ad..dc063f5 100644 --- a/Control/Windows/ConfigWindow.xaml +++ b/Control/Windows/ConfigWindow.xaml @@ -15,6 +15,8 @@ AllowsTransparency="True" Background="#00FFFFFF" ShowInTaskbar="False" BorderThickness="0" + Focusable="True" + KeyDown="OnKeyDown" > diff --git a/Control/Windows/ConfigWindow.xaml.cs b/Control/Windows/ConfigWindow.xaml.cs index 915754e..6d334d9 100644 --- a/Control/Windows/ConfigWindow.xaml.cs +++ b/Control/Windows/ConfigWindow.xaml.cs @@ -2,6 +2,7 @@ using GeekDesk.Constant; using GeekDesk.Control.UserControls; using GeekDesk.Control.UserControls.Config; +using GeekDesk.Interface; using GeekDesk.Util; using GeekDesk.ViewModel; using HandyControl.Controls; @@ -15,7 +16,7 @@ namespace GeekDesk.Control.Windows /// /// ConfigDialog.xaml 的交互逻辑 /// - public partial class ConfigWindow + public partial class ConfigWindow : IWindowCommon { private static readonly AboutControl about = new AboutControl(); private static readonly ThemeControl theme = new ThemeControl(); @@ -87,6 +88,15 @@ namespace GeekDesk.Control.Windows window = new ConfigWindow(appConfig, mainWindow); } window.Show(); + Keyboard.Focus(window); + } + + public void OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + this.Close(); + } } } } diff --git a/Control/Windows/IconfontWindow.xaml b/Control/Windows/IconfontWindow.xaml index a6efc33..bb9803f 100644 --- a/Control/Windows/IconfontWindow.xaml +++ b/Control/Windows/IconfontWindow.xaml @@ -14,6 +14,8 @@ AllowsTransparency="True" Background="Transparent" ShowInTaskbar="False" BorderThickness="0" + Focusable="True" + KeyDown="OnKeyDown" > @@ -39,7 +41,7 @@ - + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + -