From ddabf0a11358409e8639bd2394713f5db5d51639 Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 23 May 2022 17:52:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8B=BE=E8=89=B2=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Control/Other/MyColorPickerDialog.xaml.cs | 14 ------- .../Windows/GlobalColorPickerWindow.xaml.cs | 40 +++++++++++++++++-- Control/Windows/PixelColorPickerWindow.xaml | 9 ++--- .../Windows/PixelColorPickerWindow.xaml.cs | 19 ++------- MainWindow.xaml | 3 +- MainWindow.xaml.cs | 26 ++++++++++-- 6 files changed, 67 insertions(+), 44 deletions(-) diff --git a/Control/Other/MyColorPickerDialog.xaml.cs b/Control/Other/MyColorPickerDialog.xaml.cs index ef515ce..f1075b2 100644 --- a/Control/Other/MyColorPickerDialog.xaml.cs +++ b/Control/Other/MyColorPickerDialog.xaml.cs @@ -99,22 +99,8 @@ namespace GeekDesk.Control.Other private void MyColorPickerClose(object sender) { - ClickColorPickerToggleButton(sender as HandyControl.Controls.ColorPicker); dialog.Close(); } - public void ClickColorPickerToggleButton(HandyControl.Controls.ColorPicker colorPicker) - { - if (toggleButton != null && toggleButton.IsChecked == true) - { - const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - Type type = colorPicker.GetType(); - toggleButton.IsChecked = false; - MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags); - mi.Invoke(colorPicker, new object[] { null, null }); - } - } - - } } diff --git a/Control/Windows/GlobalColorPickerWindow.xaml.cs b/Control/Windows/GlobalColorPickerWindow.xaml.cs index 88c7ccb..1407734 100644 --- a/Control/Windows/GlobalColorPickerWindow.xaml.cs +++ b/Control/Windows/GlobalColorPickerWindow.xaml.cs @@ -13,7 +13,7 @@ namespace GeekDesk.Control.Windows /// public partial class GlobalColorPickerWindow : IWindowCommon { - PixelColorPickerWindow colorPickerWindow; + PixelColorPickerWindow colorPickerWindow = null; public GlobalColorPickerWindow() { this.Topmost = true; @@ -60,10 +60,12 @@ namespace GeekDesk.Control.Windows private void MyColorPicker_Checked(object sender, RoutedEventArgs e) - { - + { this.Hide(); - colorPickerWindow = new PixelColorPickerWindow(MyColorPicker); + if (colorPickerWindow == null || !colorPickerWindow.Activate()) + { + colorPickerWindow = new PixelColorPickerWindow(MyColorPicker); + } colorPickerWindow.Show(); } @@ -73,6 +75,22 @@ namespace GeekDesk.Control.Windows } private static System.Windows.Window window = null; + + public static void CreateNoShow() + { + if (window == null || !window.Activate()) + { + window = new GlobalColorPickerWindow(); + } + window.Hide(); + GlobalColorPickerWindow thisWindow = (GlobalColorPickerWindow)window; + if (thisWindow.colorPickerWindow == null || !thisWindow.colorPickerWindow.Activate()) + { + thisWindow.colorPickerWindow = new PixelColorPickerWindow(thisWindow.MyColorPicker); + } + thisWindow.colorPickerWindow.Show(); + } + public static void Show() { if (window == null || !window.Activate()) @@ -83,6 +101,20 @@ namespace GeekDesk.Control.Windows Keyboard.Focus(window); } + public static void ShowOrHide() + { + if (window == null || !window.Activate()) + { + window = new GlobalColorPickerWindow(); + window.Show(); + Keyboard.Focus(window); + } + else + { + window.Close(); + } + } + private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs e) { Show(); diff --git a/Control/Windows/PixelColorPickerWindow.xaml b/Control/Windows/PixelColorPickerWindow.xaml index ae8876a..c6769af 100644 --- a/Control/Windows/PixelColorPickerWindow.xaml +++ b/Control/Windows/PixelColorPickerWindow.xaml @@ -5,6 +5,7 @@ xml:lang="zh-CN" WindowStyle="None" AllowsTransparency="True" + Background="Black" PreviewMouseMove="Window_PreviewMouseMove" MouseLeftButtonDown="Window_MouseLeftButtonDown" MouseWheel="Window_MouseWheel" @@ -19,11 +20,8 @@ - - - - - + + - + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 1ca5d5a..b4ae315 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -16,6 +16,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media.Animation; +using System.Windows.Threading; using static GeekDesk.Util.ShowWindowFollowMouse; namespace GeekDesk @@ -243,7 +244,7 @@ namespace GeekDesk { if (MotionControl.hotkeyFinished) { - ToDoInfoWindow.ShowOrHide(); + ToDoWindow.ShowOrHide(); } }); if (!first) @@ -273,7 +274,6 @@ namespace GeekDesk { try { - if (appData.AppConfig.ColorPickerHotkeyModifiers != 0) { //加载完毕注册热键 @@ -281,7 +281,7 @@ namespace GeekDesk { if (MotionControl.hotkeyFinished) { - GlobalColorPickerWindow.Show(); + GlobalColorPickerWindow.CreateNoShow(); } }); if (!first) @@ -432,6 +432,7 @@ namespace GeekDesk if (RunTimeStatus.SEARCH_BOX_SHOW) { mainWindow.HidedSearchBox(); + Thread t = new Thread(() => { Thread.Sleep(100); @@ -682,9 +683,26 @@ namespace GeekDesk RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false; } + /// + /// 打开屏幕拾色器 + /// + /// + /// private void ColorPicker(object sender, RoutedEventArgs e) { - GlobalColorPickerWindow.Show(); + TaskbarContextMenu.Visibility = Visibility.Collapsed; + App.DoEvents(); + GlobalColorPickerWindow.CreateNoShow(); + } + + /// + /// 防止点击拾色器后无法显示菜单的问题 + /// + /// + /// + private void BarIcon_MouseRightButtonDown(object sender, MouseButtonEventArgs e) + { + TaskbarContextMenu.Visibility = Visibility.Visible; } } }