using GeekDesk.Util; using GeekDesk.ViewModel; using Microsoft.Win32; 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.Navigation; using System.Windows.Shapes; namespace GeekDesk.Control.UserControls { /// /// 动作设置 /// public partial class MotionControl : UserControl { private static bool controlKeyDown = false; private static AppConfig appConfig = MainWindow.appData.AppConfig; public MotionControl() { InitializeComponent(); } /// /// 热键按下 /// /// /// private void HotKeyDown(object sender, KeyEventArgs e) { if (e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) || e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Windows) || e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Alt) || (e.Key >= Key.A && e.Key <= Key.Z)) { 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 ""; } } }