From edacf3249c7fd952335d3b51fa834a1f06b1322c Mon Sep 17 00:00:00 2001 From: liufei Date: Sun, 9 Jan 2022 15:38:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=8C=E5=87=BB=E6=89=93?= =?UTF-8?q?=E5=BC=80=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E5=AF=BC=E8=87=B4=E4=B8=8D=E8=83=BD=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserControls/Config/MotionControl.xaml | 28 ++++++++---- .../UserControls/Config/MotionControl.xaml.cs | 43 +++++++++++-------- ViewModel/AppConfig.cs | 35 ++++++++++++--- 3 files changed, 72 insertions(+), 34 deletions(-) diff --git a/Control/UserControls/Config/MotionControl.xaml b/Control/UserControls/Config/MotionControl.xaml index 5605c17..8575b46 100644 --- a/Control/UserControls/Config/MotionControl.xaml +++ b/Control/UserControls/Config/MotionControl.xaml @@ -41,7 +41,17 @@ - + + + + + + + + + + + @@ -51,7 +61,7 @@ - + @@ -61,7 +71,7 @@ - + @@ -69,7 +79,7 @@ - + @@ -102,8 +112,8 @@ /> - - + - + - - + + diff --git a/Control/UserControls/Config/MotionControl.xaml.cs b/Control/UserControls/Config/MotionControl.xaml.cs index 14d3761..684e567 100644 --- a/Control/UserControls/Config/MotionControl.xaml.cs +++ b/Control/UserControls/Config/MotionControl.xaml.cs @@ -62,7 +62,7 @@ namespace GeekDesk.Control.UserControls.Config main = true; } - if (prevKeyTemp == Key.None || prevKeyTemp!=downKey) + if (prevKeyTemp == Key.None || prevKeyTemp != downKey) { if (hotkeyFinished) { @@ -71,7 +71,8 @@ namespace GeekDesk.Control.UserControls.Config appConfig.Hotkey = 0; appConfig.HotkeyStr = ""; appConfig.HotkeyModifiers = 0; - } else + } + else { appConfig.ToDoHotkey = 0; appConfig.ToDoHotkeyStr = ""; @@ -80,7 +81,7 @@ namespace GeekDesk.Control.UserControls.Config hotkeyFinished = false; } //首次按下按键 - if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0)) + if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0)) || (!main && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0))) { if (CheckModifierKeys(downKey)) @@ -90,7 +91,8 @@ namespace GeekDesk.Control.UserControls.Config { appConfig.HotkeyStr = GetKeyName(downKey); appConfig.HotkeyModifiers = GetModifierKeys(downKey); - } else + } + else { appConfig.ToDoHotkeyStr = GetKeyName(downKey); appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey); @@ -111,7 +113,8 @@ namespace GeekDesk.Control.UserControls.Config { appConfig.Hotkey = downKey; appConfig.HotkeyStr += downKey.ToString(); - } else + } + else { appConfig.ToDoHotkey = downKey; appConfig.ToDoHotkeyStr += downKey.ToString(); @@ -125,12 +128,13 @@ namespace GeekDesk.Control.UserControls.Config { appConfig.HotkeyStr += GetKeyName(downKey); appConfig.HotkeyModifiers |= GetModifierKeys(downKey); - } else + } + else { appConfig.ToDoHotkeyStr += GetKeyName(downKey); appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey); } - + prevKeyTemp = downKey; keysTemp.Add(e); } @@ -143,7 +147,8 @@ namespace GeekDesk.Control.UserControls.Config if (key == Key.LeftCtrl || key == Key.RightCtrl) { return "Ctrl + "; - } else if (key == Key.LWin || key == Key.RWin) + } + else if (key == Key.LWin || key == Key.RWin) { return "Win + "; } @@ -187,7 +192,7 @@ namespace GeekDesk.Control.UserControls.Config [MethodImpl(MethodImplOptions.Synchronized)] - private void HotKeyUp(object sender, KeyEventArgs e) + private void HotKeyUp(object sender, KeyEventArgs e) { string tag = (sender as TextBox).Tag.ToString(); bool main = false; @@ -195,7 +200,7 @@ namespace GeekDesk.Control.UserControls.Config { main = true; } - lock(this) + lock (this) { bool allKeyUp = true; //判断所有键是否都松开 @@ -221,7 +226,8 @@ namespace GeekDesk.Control.UserControls.Config GlobalHotKey.Dispose(MainWindow.hotKeyId); } MainWindow.RegisterHotKey(false); - } else + } + else { if (MainWindow.toDoHotKeyId != -1) { @@ -231,7 +237,7 @@ namespace GeekDesk.Control.UserControls.Config MainWindow.RegisterCreateToDoHotKey(false); } - + } } } @@ -253,13 +259,11 @@ namespace GeekDesk.Control.UserControls.Config { if (appConfig.MarginHide) { - MainWindow.hide.TimerSet(); - } else + MarginHide.StartHide(); + } + else { - if (MainWindow.hide.timer != null) - { - MainWindow.hide.TimerStop(); - } + MarginHide.StopHide(); } } @@ -284,7 +288,8 @@ namespace GeekDesk.Control.UserControls.Config if (appConfig.MouseMiddleShow) { MouseHookThread.MiddleHook(); - } else + } + else { MouseHookThread.Dispose(); } diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs index fa3a435..cc2c116 100644 --- a/ViewModel/AppConfig.cs +++ b/ViewModel/AppConfig.cs @@ -1,6 +1,7 @@  using GeekDesk.Constant; using GeekDesk.Util; +using Newtonsoft.Json; using System; using System.Collections.ObjectModel; using System.ComponentModel; @@ -70,7 +71,22 @@ namespace GeekDesk.ViewModel private bool showBarIcon = true; //显示托盘图标 默认显示 + private bool doubleOpen = false; //双击打开项目 默认关闭 + #region GetSet + public bool DoubleOpen + { + get + { + return doubleOpen; + } + set + { + doubleOpen = value; + OnPropertyChanged("DoubleOpen"); + } + } + public bool ShowBarIcon { get @@ -105,18 +121,19 @@ namespace GeekDesk.ViewModel if (imageWidth == 0) { return (int)CommonEnum.IMAGE_WIDTH; - } else + } + else { return imageWidth; } - + } set { imageWidth = value; //同时设置高度 ImageHeight = value; - + //计算 容器宽度因子 double i = ((double)imageWidth - (double)CommonEnum.IMAGE_WIDTH) / 5d; @@ -126,7 +143,7 @@ namespace GeekDesk.ViewModel { i /= 10d; } - + if (i > 0d) { s -= i; @@ -380,7 +397,8 @@ namespace GeekDesk.ViewModel if (blurEffect) { BlurValue = 100; - } else + } + else { BlurValue = 0; } @@ -552,7 +570,8 @@ namespace GeekDesk.ViewModel bacImgName = "系统默认"; //Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64)); return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64)); - } else + } + else { return ImageUtil.ByteArrToImage(ImageByteArr); } @@ -707,5 +726,9 @@ namespace GeekDesk.ViewModel #endregion + public override String ToString() + { + return JsonConvert.SerializeObject(this); + } } }