From 71cd33434a94cc963e7acc5442fe320b73d6f721 Mon Sep 17 00:00:00 2001 From: liufei Date: Tue, 1 Jun 2021 17:31:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E7=8F=AD=E5=9B=9E=E5=AE=B6,=20?= =?UTF-8?q?=E4=BB=8A=E6=97=A5=E6=97=A0=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Control/UserControls/MotionControl.xaml.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Control/UserControls/MotionControl.xaml.cs b/Control/UserControls/MotionControl.xaml.cs index dbccc76..e31e92f 100644 --- a/Control/UserControls/MotionControl.xaml.cs +++ b/Control/UserControls/MotionControl.xaml.cs @@ -48,15 +48,29 @@ namespace GeekDesk.Control.UserControls || e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows) || e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt)) { - appConfig.HotkeyStr = "Ctrl + "; - } else if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) - || e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows) - || e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt) + appConfig.HotkeyStr += GetKeyName(e); + } else if (appConfig.HotkeyStr.Length > 0 && (e.Key >= Key.A && e.Key <= Key.Z)) { appConfig.HotkeyStr += e.Key.ToString(); } } } + + private string GetKeyName(KeyEventArgs e) + { + if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control)) + { + return "Ctrl + "; + } else if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows)) + { + return "Win + "; + } else if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt)) + { + return "Alt + "; + } + return ""; + } + } }