From d01a27b827776d85cb12fcf5fa5432fe7085e30a Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 May 2022 15:39:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B8=85=E7=90=86/=E6=8B=BE?= =?UTF-8?q?=E8=89=B2=E5=99=A8=E5=8A=9F=E8=83=BD/=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 5 + App.xaml.cs | 5 - Constant/BGStyle.cs | 8 +- Constant/Constants.cs | 4 - Constant/HotKeyType.cs | 10 + Constant/IconStartType.cs | 8 +- Constant/IconType.cs | 8 +- Constant/RunTimeStatus.cs | 8 +- Constant/TodoTaskExecType.cs | 8 +- Constant/UpdateType.cs | 8 +- Control/Other/BacklogNotificatin.xaml.cs | 10 - Control/Other/CustomIconUrlDialog.xaml.cs | 4 - Control/Other/GradientBGDialog.xaml.cs | 3 - Control/Other/IconInfoDialog.xaml.cs | 1 - Control/Other/IconInfoUrlDialog.xaml.cs | 6 +- Control/Other/MyColorPickerDialog.xaml | 30 +++ Control/Other/MyColorPickerDialog.xaml.cs | 120 ++++++++++ .../UserControls/Config/AboutControl.xaml.cs | 15 +- .../UserControls/Config/MotionControl.xaml | 63 +++++- .../UserControls/Config/MotionControl.xaml.cs | 211 +++++++++++------- .../UserControls/Config/OtherControl.xaml.cs | 11 - Control/UserControls/Config/ThemeControl.xaml | 6 +- .../UserControls/Config/ThemeControl.xaml.cs | 105 +-------- .../UserControls/IconFont/IconPannel.xaml.cs | 16 +- .../PannelCard/LeftCardControl.xaml.cs | 18 +- .../PannelCard/RightCardControl.xaml | 2 +- .../PannelCard/RightCardControl.xaml.cs | 26 ++- .../SystemItem/SystemItem.xaml.cs | 15 +- Control/UserControls/ToDo/TodoControl.xaml.cs | 9 - Control/Windows/ConfigWindow.xaml | 4 +- Control/Windows/ConfigWindow.xaml.cs | 12 +- Control/Windows/GlobalColorPickerWindow.xaml | 49 ++++ .../Windows/GlobalColorPickerWindow.xaml.cs | 108 +++++++++ Control/Windows/PixelColorPickerWindow.xaml | 90 ++++++++ .../Windows/PixelColorPickerWindow.xaml.cs | 208 +++++++++++++++++ Control/Windows/SystemItemWindow.xaml.cs | 17 +- Control/Windows/ToDoInfoWindow.xaml.cs | 31 ++- Control/Windows/ToDoWindow.xaml.cs | 12 - Control/Windows/UpdateWindow.xaml.cs | 14 +- Converts/BGStyleConvert.cs | 4 - Converts/DoubleToGridLength.cs | 4 - Converts/HideTypeConvert.cs | 6 +- Converts/IntToCornerRadius.cs | 4 - Converts/MenuInfoConvert.cs | 12 +- Converts/OpcityConvert.cs | 4 - Converts/SearchResWidth.cs | 8 +- Converts/SortTypeConvert.cs | 4 - Converts/StringAppendConvert.cs | 10 +- Converts/TodoTaskExecConvert.cs | 6 +- Converts/UpdateTypeConvert.cs | 4 - Converts/Visibility2BooleanConverter.cs | 10 +- GeekDesk.csproj | 65 ++++++ GeekDesk.sln | 4 +- Interface/IWindowCommon.cs | 8 +- MainWindow.xaml | 3 +- MainWindow.xaml.cs | 98 ++++++-- MyThread/DispatcherBuild.cs | 8 +- MyThread/MouseHookThread.cs | 7 +- MyThread/UpdateThread.cs | 8 +- Task/ToDoTask.cs | 7 +- Util/BGSettingUtil.cs | 11 +- Util/ColorUtil.cs | 15 ++ Util/FileIcon.cs | 25 +-- Util/FileUtil.cs | 3 - Util/GlobalHotKey.cs | 7 +- Util/HttpUtil.cs | 6 +- Util/ImageUtil.cs | 3 - Util/LogUtil.cs | 26 +-- Util/MarginHide.cs | 15 +- Util/MouseUtil.cs | 4 - Util/RegisterUtil.cs | 4 - Util/ShellContextMenu.cs | 12 +- Util/StringUtil.cs | 10 +- Util/SvgToGeometry.cs | 2 - ViewModel/AppConfig.cs | 98 +++++++- ViewModel/AppData.cs | 1 - ViewModel/CPDataContext.cs | 93 ++++++++ ViewModel/GradientBGParam.cs | 7 +- ViewModel/IconInfo.cs | 4 - ViewModel/IconfontInfo.cs | 8 +- ViewModel/MenuInfo.cs | 7 +- ViewModel/Temp/GradientBGParamList.cs | 10 +- ViewModel/ToDoInfo.cs | 4 - 83 files changed, 1320 insertions(+), 627 deletions(-) create mode 100644 Constant/HotKeyType.cs create mode 100644 Control/Other/MyColorPickerDialog.xaml create mode 100644 Control/Other/MyColorPickerDialog.xaml.cs create mode 100644 Control/Windows/GlobalColorPickerWindow.xaml create mode 100644 Control/Windows/GlobalColorPickerWindow.xaml.cs create mode 100644 Control/Windows/PixelColorPickerWindow.xaml create mode 100644 Control/Windows/PixelColorPickerWindow.xaml.cs create mode 100644 Util/ColorUtil.cs create mode 100644 ViewModel/CPDataContext.cs diff --git a/App.config b/App.config index ce0c2d6..2f5f506 100644 --- a/App.config +++ b/App.config @@ -2,6 +2,8 @@
+
+
@@ -16,6 +18,9 @@ + + + diff --git a/App.xaml.cs b/App.xaml.cs index e950c4e..7dc3a17 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,12 +1,7 @@ using GeekDesk.Constant; using GeekDesk.Util; -using Microsoft.Win32; using System; -using System.IO; -using System.Text; using System.Windows; -using System.Windows.Media.Animation; -using System.Windows.Threading; namespace GeekDesk { diff --git a/Constant/BGStyle.cs b/Constant/BGStyle.cs index fedb370..0e6f6dc 100644 --- a/Constant/BGStyle.cs +++ b/Constant/BGStyle.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -/// +/// /// 背景风格 /// namespace GeekDesk.Constant diff --git a/Constant/Constants.cs b/Constant/Constants.cs index a1b482e..18889d7 100644 --- a/Constant/Constants.cs +++ b/Constant/Constants.cs @@ -1,10 +1,6 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Configuration; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace GeekDesk.Constant { diff --git a/Constant/HotKeyType.cs b/Constant/HotKeyType.cs new file mode 100644 index 0000000..a468d88 --- /dev/null +++ b/Constant/HotKeyType.cs @@ -0,0 +1,10 @@ +namespace GeekDesk.Constant +{ + public enum HotKeyType + { + + Main = 0, //主窗口 + ToDo = 1, //待办任务 + ColorPicker = 2 //拾色器 + } +} diff --git a/Constant/IconStartType.cs b/Constant/IconStartType.cs index 1d94174..b633a0a 100644 --- a/Constant/IconStartType.cs +++ b/Constant/IconStartType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -/// +/// /// 图标应用启动方式 /// namespace GeekDesk.Constant diff --git a/Constant/IconType.cs b/Constant/IconType.cs index 859e44d..49400cb 100644 --- a/Constant/IconType.cs +++ b/Constant/IconType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GeekDesk.Constant +namespace GeekDesk.Constant { public enum IconType { diff --git a/Constant/RunTimeStatus.cs b/Constant/RunTimeStatus.cs index 80ac272..81d6896 100644 --- a/Constant/RunTimeStatus.cs +++ b/Constant/RunTimeStatus.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GeekDesk.Constant +namespace GeekDesk.Constant { internal class RunTimeStatus { diff --git a/Constant/TodoTaskExecType.cs b/Constant/TodoTaskExecType.cs index d634ce7..20ade56 100644 --- a/Constant/TodoTaskExecType.cs +++ b/Constant/TodoTaskExecType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GeekDesk.Constant +namespace GeekDesk.Constant { public enum TodoTaskExecType { diff --git a/Constant/UpdateType.cs b/Constant/UpdateType.cs index 6cbb96a..e862b53 100644 --- a/Constant/UpdateType.cs +++ b/Constant/UpdateType.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -/// +/// /// 更新源 /// namespace GeekDesk.Constant diff --git a/Control/Other/BacklogNotificatin.xaml.cs b/Control/Other/BacklogNotificatin.xaml.cs index be06ef4..28b64c9 100644 --- a/Control/Other/BacklogNotificatin.xaml.cs +++ b/Control/Other/BacklogNotificatin.xaml.cs @@ -5,18 +5,8 @@ using GeekDesk.ViewModel; using HandyControl.Controls; using Quartz; 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.Shapes; namespace GeekDesk.Control.Other { diff --git a/Control/Other/CustomIconUrlDialog.xaml.cs b/Control/Other/CustomIconUrlDialog.xaml.cs index fc99031..f632bd0 100644 --- a/Control/Other/CustomIconUrlDialog.xaml.cs +++ b/Control/Other/CustomIconUrlDialog.xaml.cs @@ -1,13 +1,9 @@ using GeekDesk.Control.Windows; using GeekDesk.Util; using GeekDesk.ViewModel; -using Microsoft.Win32; -using System; using System.Configuration; using System.Diagnostics; using System.Windows; -using System.Windows.Controls; -using System.Windows.Media.Imaging; namespace GeekDesk.Control.Other diff --git a/Control/Other/GradientBGDialog.xaml.cs b/Control/Other/GradientBGDialog.xaml.cs index ede92f8..401d2b7 100644 --- a/Control/Other/GradientBGDialog.xaml.cs +++ b/Control/Other/GradientBGDialog.xaml.cs @@ -1,11 +1,8 @@ using GeekDesk.Util; using GeekDesk.ViewModel; using GeekDesk.ViewModel.Temp; -using Microsoft.Win32; -using System; using System.Windows; using System.Windows.Controls; -using System.Windows.Media.Imaging; namespace GeekDesk.Control.Other diff --git a/Control/Other/IconInfoDialog.xaml.cs b/Control/Other/IconInfoDialog.xaml.cs index e7e8444..13a0855 100644 --- a/Control/Other/IconInfoDialog.xaml.cs +++ b/Control/Other/IconInfoDialog.xaml.cs @@ -3,7 +3,6 @@ using GeekDesk.ViewModel; using Microsoft.Win32; using System; using System.Windows; -using System.Windows.Controls; using System.Windows.Media.Imaging; diff --git a/Control/Other/IconInfoUrlDialog.xaml.cs b/Control/Other/IconInfoUrlDialog.xaml.cs index 6962caa..2ecb6f1 100644 --- a/Control/Other/IconInfoUrlDialog.xaml.cs +++ b/Control/Other/IconInfoUrlDialog.xaml.cs @@ -4,7 +4,6 @@ using GeekDesk.ViewModel; using Microsoft.Win32; using System; using System.Windows; -using System.Windows.Controls; using System.Windows.Media.Imaging; @@ -89,12 +88,13 @@ namespace GeekDesk.Control.Other info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName); CommonCode.SaveAppData(MainWindow.appData); } - } catch (Exception ex) + } + catch (Exception ex) { HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!"); LogUtil.WriteErrorLog(ex, "修改图标失败!"); } - + } } } diff --git a/Control/Other/MyColorPickerDialog.xaml b/Control/Other/MyColorPickerDialog.xaml new file mode 100644 index 0000000..c49fc8b --- /dev/null +++ b/Control/Other/MyColorPickerDialog.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Control/Other/MyColorPickerDialog.xaml.cs b/Control/Other/MyColorPickerDialog.xaml.cs new file mode 100644 index 0000000..ef515ce --- /dev/null +++ b/Control/Other/MyColorPickerDialog.xaml.cs @@ -0,0 +1,120 @@ +using GeekDesk.Control.Windows; +using GeekDesk.ViewModel; +using System; +using System.Reflection; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; + + +namespace GeekDesk.Control.Other +{ + + public enum ColorType + { + COLOR_1 = 1, + COLOR_2 = 2, + TEXT_COLOR = 3 + } + + /// + /// TextDialog.xaml 的交互逻辑 + /// + public partial class MyColorPickerDialog + { + public static ColorType COLOR_TYPE = new ColorType(); + private static AppConfig appConfig = MainWindow.appData.AppConfig; + + public static HandyControl.Controls.Dialog dialog; + private System.Windows.Controls.Primitives.ToggleButton toggleButton = null; + + private static ColorType colorType; + + + public MyColorPickerDialog(string strType, string token) + { + InitializeComponent(); + switch (strType) + { + case "Color1": + colorType = ColorType.COLOR_1; break; + case "Color2": + colorType = ColorType.COLOR_2; break; + default: + colorType = ColorType.TEXT_COLOR; break; + } + dialog = HandyControl.Controls.Dialog.Show(this, token); + } + + + /// + /// 取消按钮事件 + /// + /// + /// + private void MyColorPicker_Canceled(object sender, EventArgs e) + { + MyColorPickerClose(sender); + } + private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs e) + { + MyColorPickerClose(sender); + } + + private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs e) + { + SolidColorBrush scb = MyColorPicker.SelectedBrush; + switch (colorType) + { + case ColorType.COLOR_1: + appConfig.GradientBGParam.Color1 = scb.ToString(); break; + case ColorType.COLOR_2: + appConfig.GradientBGParam.Color2 = scb.ToString(); break; + default: + appConfig.TextColor = scb.ToString(); break; + } + } + + /// + /// 移动窗口 + /// + /// + /// + private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + if (e.LeftButton == MouseButtonState.Pressed) + { + Window.GetWindow(this).DragMove(); + } + } + + + private void MyColorPicker_Checked(object sender, RoutedEventArgs e) + { + toggleButton = e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton; + + PixelColorPickerWindow colorPickerWindow = new PixelColorPickerWindow(MyColorPicker); + colorPickerWindow.Show(); + } + + 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/UserControls/Config/AboutControl.xaml.cs b/Control/UserControls/Config/AboutControl.xaml.cs index e2d1747..40adfa4 100644 --- a/Control/UserControls/Config/AboutControl.xaml.cs +++ b/Control/UserControls/Config/AboutControl.xaml.cs @@ -1,20 +1,9 @@ -using System; +using GeekDesk.Constant; +using GeekDesk.Util; using System.Configuration; -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; -using GeekDesk.Util; -using GeekDesk.Constant; namespace GeekDesk.Control.UserControls.Config { diff --git a/Control/UserControls/Config/MotionControl.xaml b/Control/UserControls/Config/MotionControl.xaml index dffd0b8..2c482fc 100644 --- a/Control/UserControls/Config/MotionControl.xaml +++ b/Control/UserControls/Config/MotionControl.xaml @@ -4,10 +4,13 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:cvt="clr-namespace:GeekDesk.Converts" - xmlns:hc="https://handyorg.github.io/handycontrol" mc:Ignorable="d" + xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" + d:DataContext="{d:DesignInstance Type=viewmodel:AppConfig}" + xmlns:cst="clr-namespace:GeekDesk.Constant" Background="Transparent" - d:DesignHeight="300" d:DesignWidth="450"> + d:DesignHeight="400" d:DesignWidth="450"> @@ -109,30 +112,74 @@ - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + diff --git a/Control/UserControls/Config/MotionControl.xaml.cs b/Control/UserControls/Config/MotionControl.xaml.cs index 53b970a..07d2672 100644 --- a/Control/UserControls/Config/MotionControl.xaml.cs +++ b/Control/UserControls/Config/MotionControl.xaml.cs @@ -1,26 +1,12 @@ using GeekDesk.Constant; -using GeekDesk.Control.Windows; using GeekDesk.MyThread; using GeekDesk.Util; using GeekDesk.ViewModel; -using HandyControl.Data; -using Microsoft.Win32; -using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; -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.Interop; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using static GeekDesk.Util.GlobalHotKey; namespace GeekDesk.Control.UserControls.Config @@ -48,7 +34,7 @@ namespace GeekDesk.Control.UserControls.Config /// private void HotKeyDown(object sender, KeyEventArgs e) { - string tag = (sender as TextBox).Tag.ToString(); + HotKeyType hkType = (HotKeyType)(sender as TextBox).Tag; Key downKey = e.Key; if (downKey == Key.System) @@ -56,47 +42,59 @@ namespace GeekDesk.Control.UserControls.Config downKey = e.SystemKey; } - bool main = false; - if ("Main".Equals(tag)) - { - main = true; - } + if (!CheckIsEnable(hkType)) return; + if (prevKeyTemp == Key.None || prevKeyTemp != downKey) { if (hotkeyFinished) { - if (main) + + switch (hkType) { - appConfig.Hotkey = 0; - appConfig.HotkeyStr = ""; - appConfig.HotkeyModifiers = 0; - } - else - { - appConfig.ToDoHotkey = 0; - appConfig.ToDoHotkeyStr = ""; - appConfig.ToDoHotkeyModifiers = 0; + case HotKeyType.Main: + appConfig.Hotkey = 0; + appConfig.HotkeyStr = ""; + appConfig.HotkeyModifiers = 0; + break; + case HotKeyType.ToDo: + appConfig.ToDoHotkey = 0; + appConfig.ToDoHotkeyStr = ""; + appConfig.ToDoHotkeyModifiers = 0; + break; + case HotKeyType.ColorPicker: + appConfig.ColorPickerHotkey = 0; + appConfig.ColorPickerHotkeyStr = ""; + appConfig.ColorPickerHotkeyModifiers = 0; + break; } hotkeyFinished = false; } //首次按下按键 - if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0)) - || (!main && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0))) + if ((HotKeyType.Main == hkType && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0)) + || (HotKeyType.ToDo == hkType && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0)) + || (HotKeyType.ColorPicker == hkType && (appConfig.ColorPickerHotkeyStr == null || appConfig.ColorPickerHotkeyStr.Length == 0)) + ) { if (CheckModifierKeys(downKey)) { //辅助键 - if (main) + switch (hkType) { - appConfig.HotkeyStr = GetKeyName(downKey); - appConfig.HotkeyModifiers = GetModifierKeys(downKey); - } - else - { - appConfig.ToDoHotkeyStr = GetKeyName(downKey); - appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey); + case HotKeyType.Main: + appConfig.HotkeyStr = GetKeyName(downKey); + appConfig.HotkeyModifiers = GetModifierKeys(downKey); + break; + case HotKeyType.ToDo: + appConfig.ToDoHotkeyStr = GetKeyName(downKey); + appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey); + break; + case HotKeyType.ColorPicker: + appConfig.ColorPickerHotkeyStr = GetKeyName(downKey); + appConfig.ColorPickerHotkeyModifiers = GetModifierKeys(downKey); + break; } + prevKeyTemp = downKey; keysTemp.Add(e); } @@ -109,30 +107,41 @@ namespace GeekDesk.Control.UserControls.Config || (downKey >= Key.F1 && downKey <= Key.F12) || (downKey >= Key.D0 && downKey <= Key.D9))) { - if (main) + switch (hkType) { - appConfig.Hotkey = downKey; - appConfig.HotkeyStr += downKey.ToString(); - } - else - { - appConfig.ToDoHotkey = downKey; - appConfig.ToDoHotkeyStr += downKey.ToString(); + case HotKeyType.Main: + appConfig.Hotkey = downKey; + appConfig.HotkeyStr += downKey.ToString(); + break; + case HotKeyType.ToDo: + appConfig.ToDoHotkey = downKey; + appConfig.ToDoHotkeyStr += downKey.ToString(); + break; + case HotKeyType.ColorPicker: + appConfig.ColorPickerHotkey = downKey; + appConfig.ColorPickerHotkeyStr += downKey.ToString(); + break; } + prevKeyTemp = downKey; keysTemp.Add(e); } else if (CheckModifierKeys(downKey)) { - if (main) + switch (hkType) { - appConfig.HotkeyStr += GetKeyName(downKey); - appConfig.HotkeyModifiers |= GetModifierKeys(downKey); - } - else - { - appConfig.ToDoHotkeyStr += GetKeyName(downKey); - appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey); + case HotKeyType.Main: + appConfig.HotkeyStr += GetKeyName(downKey); + appConfig.HotkeyModifiers |= GetModifierKeys(downKey); + break; + case HotKeyType.ToDo: + appConfig.ToDoHotkeyStr += GetKeyName(downKey); + appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey); + break; + case HotKeyType.ColorPicker: + appConfig.ColorPickerHotkeyStr += GetKeyName(downKey); + appConfig.ColorPickerHotkeyModifiers |= GetModifierKeys(downKey); + break; } prevKeyTemp = downKey; @@ -194,12 +203,10 @@ namespace GeekDesk.Control.UserControls.Config [MethodImpl(MethodImplOptions.Synchronized)] private void HotKeyUp(object sender, KeyEventArgs e) { - string tag = (sender as TextBox).Tag.ToString(); - bool main = false; - if ("Main".Equals(tag)) - { - main = true; - } + HotKeyType hkType = (HotKeyType)(sender as TextBox).Tag; + + if (!CheckIsEnable(hkType)) return; + lock (this) { bool allKeyUp = true; @@ -218,30 +225,52 @@ namespace GeekDesk.Control.UserControls.Config prevKeyTemp = Key.None; hotkeyFinished = true; - if (main) + switch (hkType) { - if (MainWindow.hotKeyId != -1) - { - //Hotkey.UnRegist(new WindowInteropHelper(MainWindow.mainWindow).Handle, Hotkey.keymap[MainWindow.hotKeyId]); - GlobalHotKey.Dispose(MainWindow.hotKeyId); - } - MainWindow.RegisterHotKey(false); + case HotKeyType.Main: + if (MainWindow.hotKeyId != -1) + { + //Hotkey.UnRegist(new WindowInteropHelper(MainWindow.mainWindow).Handle, Hotkey.keymap[MainWindow.hotKeyId]); + GlobalHotKey.Dispose(MainWindow.hotKeyId); + } + MainWindow.RegisterHotKey(false); + break; + case HotKeyType.ToDo: + if (MainWindow.toDoHotKeyId != -1) + { + //Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]); + GlobalHotKey.Dispose(MainWindow.toDoHotKeyId); + } + MainWindow.RegisterCreateToDoHotKey(false); + break; + case HotKeyType.ColorPicker: + if (MainWindow.colorPickerHotKeyId != -1) + { + //Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]); + GlobalHotKey.Dispose(MainWindow.colorPickerHotKeyId); + } + MainWindow.RegisterColorPickerHotKey(false); + break; } - else - { - if (MainWindow.toDoHotKeyId != -1) - { - //Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]); - GlobalHotKey.Dispose(MainWindow.toDoHotKeyId); - } - MainWindow.RegisterCreateToDoHotKey(false); - } - } } } + private bool CheckIsEnable(HotKeyType hkType) + { + switch (hkType) + { + case HotKeyType.Main: + return true == appConfig.EnableAppHotKey; + case HotKeyType.ToDo: + return true == appConfig.EnableTodoHotKey; + case HotKeyType.ColorPicker: + return true == appConfig.EnableColorPickerHotKey; + } + return false; + } + /// /// 移动窗口 /// @@ -295,5 +324,29 @@ namespace GeekDesk.Control.UserControls.Config } } + /// + /// 启用热键 + /// + /// + /// + private void EnableHotKey_Click(object sender, RoutedEventArgs e) + { + HotKeyType hkType = (HotKeyType)(sender as CheckBox).Tag; + switch (hkType) + { + case HotKeyType.Main: + if (true == appConfig.EnableAppHotKey) + MainWindow.RegisterHotKey(false); + break; + case HotKeyType.ToDo: + if (true == appConfig.EnableTodoHotKey) + MainWindow.RegisterCreateToDoHotKey(false); + break; + case HotKeyType.ColorPicker: + if (true == appConfig.EnableColorPickerHotKey) + MainWindow.RegisterColorPickerHotKey(false); + break; + } + } } } diff --git a/Control/UserControls/Config/OtherControl.xaml.cs b/Control/UserControls/Config/OtherControl.xaml.cs index bd2b09f..7c3aba1 100644 --- a/Control/UserControls/Config/OtherControl.xaml.cs +++ b/Control/UserControls/Config/OtherControl.xaml.cs @@ -1,20 +1,9 @@ using GeekDesk.Constant; using GeekDesk.Util; using GeekDesk.ViewModel; -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.Config { diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml index d22a810..72a38da 100644 --- a/Control/UserControls/Config/ThemeControl.xaml +++ b/Control/UserControls/Config/ThemeControl.xaml @@ -18,7 +18,7 @@ - + @@ -228,10 +228,10 @@ --> - + SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>--> diff --git a/Control/UserControls/Config/ThemeControl.xaml.cs b/Control/UserControls/Config/ThemeControl.xaml.cs index 4dc4329..d1209bc 100644 --- a/Control/UserControls/Config/ThemeControl.xaml.cs +++ b/Control/UserControls/Config/ThemeControl.xaml.cs @@ -1,53 +1,28 @@ using GeekDesk.Constant; using GeekDesk.Control.Other; -using GeekDesk.Control.Windows; using GeekDesk.Util; using GeekDesk.ViewModel; using Microsoft.Win32; using System; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Controls.Primitives; using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Interop; -using System.Windows.Media; -using System.Windows.Media.Effects; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.Windows.Threading; namespace GeekDesk.Control.UserControls.Config { - enum ColorType - { - COLOR_1 = 1, - COLOR_2 = 2, - TEXT_COLOR = 3 - } - /// /// MotionControl.xaml 的交互逻辑 /// public partial class ThemeControl : System.Windows.Controls.UserControl { - private static ColorType colorType; private static AppConfig appConfig = MainWindow.appData.AppConfig; - private System.Windows.Controls.Primitives.ToggleButton toggleButton = null; public ThemeControl() { - + InitializeComponent(); if (appConfig.BGStyle != BGStyle.GradientBac) { @@ -111,60 +86,9 @@ namespace GeekDesk.Control.UserControls.Config private void ColorButton_Click(object sender, RoutedEventArgs e) { string tag = (sender as Button).Tag.ToString(); - switch (tag) - { - case "Color1": - colorType = ColorType.COLOR_1;break; - case "Color2": - colorType = ColorType.COLOR_2;break; - default: - colorType = ColorType.TEXT_COLOR;break; - } - MyColorPicker.Visibility = Visibility.Visible; - new ColorPickerWindow().Show(); + new MyColorPickerDialog(tag, "ConfigWindowDialog"); } - /// - /// 取消按钮事件 - /// - /// - /// - private void MyColorPicker_Canceled(object sender, EventArgs e) - { - MyColorPickerClose(sender); - } - private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs e) - { - MyColorPickerClose(sender); - } - - private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs e) - { - SolidColorBrush scb = MyColorPicker.SelectedBrush; - - switch (colorType) - { - case ColorType.COLOR_1: - appConfig.GradientBGParam.Color1 = scb.ToString();break; - case ColorType.COLOR_2: - appConfig.GradientBGParam.Color2 = scb.ToString(); break; - default: - appConfig.TextColor = scb.ToString();break; - } - } - - /// - /// 移动窗口 - /// - /// - /// - private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e) - { - if (e.LeftButton == MouseButtonState.Pressed) - { - Window.GetWindow(this).DragMove(); - } - } private void PreviewSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { @@ -174,6 +98,7 @@ namespace GeekDesk.Control.UserControls.Config }; System.Threading.ThreadStart ts = new System.Threading.ThreadStart(cbu.CheckButtonUp); System.Threading.Thread t = new System.Threading.Thread(ts); + t.IsBackground = true; t.Start(); } @@ -201,25 +126,6 @@ namespace GeekDesk.Control.UserControls.Config } } - private void MyColorPicker_Checked(object sender, RoutedEventArgs e) - { - toggleButton = e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton; - } - - - private void MyColorPickerClose(object sender) - { - if (toggleButton != null && toggleButton.IsChecked == true) - { - HandyControl.Controls.ColorPicker cp = sender as HandyControl.Controls.ColorPicker; - const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - Type type = cp.GetType(); - toggleButton.IsChecked = false; - MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags); - mi.Invoke(cp, new object[] { null, null }); - } - MyColorPicker.Visibility = Visibility.Collapsed; - } public void BGStyle_Changed(object sender, RoutedEventArgs e) { @@ -228,7 +134,8 @@ namespace GeekDesk.Control.UserControls.Config { GradientBGConf.Visibility = Visibility.Collapsed; ImgBGConf.Visibility = Visibility.Visible; - } else + } + else { ImgBGConf.Visibility = Visibility.Collapsed; GradientBGConf.Visibility = Visibility.Visible; @@ -248,7 +155,7 @@ namespace GeekDesk.Control.UserControls.Config private void SysBG_Click(object sender, RoutedEventArgs e) { GradientBGDialog gbg = new GradientBGDialog(); - gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "SysBGDialog"); + gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "ConfigWindowDialog"); } } } diff --git a/Control/UserControls/IconFont/IconPannel.xaml.cs b/Control/UserControls/IconFont/IconPannel.xaml.cs index 7cf452a..2d30530 100644 --- a/Control/UserControls/IconFont/IconPannel.xaml.cs +++ b/Control/UserControls/IconFont/IconPannel.xaml.cs @@ -1,18 +1,4 @@ -using GeekDesk.ViewModel; -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; +using System.Windows.Controls; namespace GeekDesk.Control.UserControls.IconFont { diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs index 1fe76cb..f092363 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs @@ -1,7 +1,6 @@ using DraggAnimatedPanelExample; using GeekDesk.Constant; using GeekDesk.Control.Windows; -using GeekDesk.MyThread; using GeekDesk.Util; using GeekDesk.ViewModel; using System; @@ -10,10 +9,8 @@ using System.Collections.ObjectModel; using System.Threading; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Threading; namespace GeekDesk.Control.UserControls.PannelCard { @@ -33,7 +30,7 @@ namespace GeekDesk.Control.UserControls.PannelCard public LeftCardControl() { InitializeComponent(); - + this.Loaded += (s, e) => { @@ -44,7 +41,7 @@ namespace GeekDesk.Control.UserControls.PannelCard private void SetMenuListBoxItemEvent() - { + { int size = MenuListBox.Items.Count; for (int i = 0; i < size; i++) { @@ -87,7 +84,7 @@ namespace GeekDesk.Control.UserControls.PannelCard } } - DelegateCommand _swap; + DelegateCommand _swap; public DelegateCommand SwapCommand { @@ -333,7 +330,7 @@ namespace GeekDesk.Control.UserControls.PannelCard { if (appData.AppConfig.HoverMenu && !IS_EDIT) { - new Thread(() => + Thread t = new Thread(() => { Thread.Sleep(200); this.Dispatcher.Invoke(() => @@ -345,7 +342,9 @@ namespace GeekDesk.Control.UserControls.PannelCard MenuListBox.SelectedIndex = index; } }); - }).Start(); + }); + t.IsBackground = true; + t.Start(); } } @@ -356,7 +355,8 @@ namespace GeekDesk.Control.UserControls.PannelCard /// private void ListBoxItem_MouseDown(object sender, MouseButtonEventArgs e) { - if (RunTimeStatus.SEARCH_BOX_SHOW) { + if (RunTimeStatus.SEARCH_BOX_SHOW) + { MainWindow.mainWindow.HidedSearchBox(); } } diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml b/Control/UserControls/PannelCard/RightCardControl.xaml index 685bfbf..38f36bc 100644 --- a/Control/UserControls/PannelCard/RightCardControl.xaml +++ b/Control/UserControls/PannelCard/RightCardControl.xaml @@ -176,7 +176,7 @@ VirtualizingPanel.IsContainerVirtualizable="True" > - + + { + this.Dispatcher.BeginInvoke(new Action(() => + { + ImgStoryBoard(sender, (int)width, (int)height, 1, true); + })); + }); + t.IsBackground = true; + t.Start(); + } private void StackPanel_MouseLeave(object sender, MouseEventArgs e) { - ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 220); + + Thread t = new Thread(() => + { + this.Dispatcher.BeginInvoke(new Action(() => + { + ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260); + })); + }); + t.IsBackground = true; + t.Start(); + } @@ -491,6 +508,7 @@ namespace GeekDesk.Control.UserControls.PannelCard { ThreadStart ts = new ThreadStart(crs.Remove); System.Threading.Thread t = new System.Threading.Thread(ts); + t.IsBackground = true; t.Start(); } else diff --git a/Control/UserControls/SystemItem/SystemItem.xaml.cs b/Control/UserControls/SystemItem/SystemItem.xaml.cs index 0d58ac9..a5d787d 100644 --- a/Control/UserControls/SystemItem/SystemItem.xaml.cs +++ b/Control/UserControls/SystemItem/SystemItem.xaml.cs @@ -1,20 +1,8 @@ using GeekDesk.Constant; using GeekDesk.Util; using GeekDesk.ViewModel; -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.SystemItem { @@ -47,7 +35,8 @@ namespace GeekDesk.Control.UserControls.SystemItem }; iconInfo.Content_NoWrite = iconInfo.Name_NoWrite + "\n使用次数:" + iconInfo.Count; - } else + } + else { //startupMenu or Store iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite); diff --git a/Control/UserControls/ToDo/TodoControl.xaml.cs b/Control/UserControls/ToDo/TodoControl.xaml.cs index 7957a0a..a1d7e4f 100644 --- a/Control/UserControls/ToDo/TodoControl.xaml.cs +++ b/Control/UserControls/ToDo/TodoControl.xaml.cs @@ -3,19 +3,10 @@ using GeekDesk.Util; using GeekDesk.ViewModel; using HandyControl.Controls; 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.Backlog { diff --git a/Control/Windows/ConfigWindow.xaml b/Control/Windows/ConfigWindow.xaml index cd71764..f3f62ef 100644 --- a/Control/Windows/ConfigWindow.xaml +++ b/Control/Windows/ConfigWindow.xaml @@ -24,7 +24,7 @@ - + @@ -110,7 +110,7 @@ - + diff --git a/Control/Windows/ConfigWindow.xaml.cs b/Control/Windows/ConfigWindow.xaml.cs index bf6b62a..8b20e93 100644 --- a/Control/Windows/ConfigWindow.xaml.cs +++ b/Control/Windows/ConfigWindow.xaml.cs @@ -1,13 +1,7 @@ - -using GeekDesk.Constant; -using GeekDesk.Control.UserControls; -using GeekDesk.Control.UserControls.Config; +using GeekDesk.Control.UserControls.Config; using GeekDesk.Interface; -using GeekDesk.Util; using GeekDesk.ViewModel; using HandyControl.Controls; -using HandyControl.Data; -using System; using System.Collections.Generic; using System.Windows; using System.Windows.Controls; @@ -44,8 +38,8 @@ namespace GeekDesk.Control.Windows this.mainWindow = mainWindow; } - - + + /// /// 点击关闭按钮 diff --git a/Control/Windows/GlobalColorPickerWindow.xaml b/Control/Windows/GlobalColorPickerWindow.xaml new file mode 100644 index 0000000..7d5a69d --- /dev/null +++ b/Control/Windows/GlobalColorPickerWindow.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + diff --git a/Control/Windows/GlobalColorPickerWindow.xaml.cs b/Control/Windows/GlobalColorPickerWindow.xaml.cs new file mode 100644 index 0000000..88c7ccb --- /dev/null +++ b/Control/Windows/GlobalColorPickerWindow.xaml.cs @@ -0,0 +1,108 @@ +using GeekDesk.Interface; +using System; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace GeekDesk.Control.Windows +{ + /// + /// GlobalColorPickerWindow.xaml 的交互逻辑 + /// + public partial class GlobalColorPickerWindow : IWindowCommon + { + PixelColorPickerWindow colorPickerWindow; + public GlobalColorPickerWindow() + { + this.Topmost = true; + InitializeComponent(); + } + + public void OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + this.DataContext = null; + this.Close(); + } + } + + + /// + /// 取消按钮事件 + /// + /// + /// + private void MyColorPicker_Canceled(object sender, EventArgs e) + { + MyColorPickerClose(); + } + private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs e) + { + Color c = MyColorPicker.SelectedBrush.Color; + Clipboard.SetData(DataFormats.Text, string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.A, c.R, c.G, c.B)); + } + + /// + /// 移动窗口 + /// + /// + /// + private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + if (e.LeftButton == MouseButtonState.Pressed) + { + this.DragMove(); + } + } + + + private void MyColorPicker_Checked(object sender, RoutedEventArgs e) + { + + this.Hide(); + colorPickerWindow = new PixelColorPickerWindow(MyColorPicker); + colorPickerWindow.Show(); + } + + private void MyColorPickerClose() + { + this.Close(); + } + + private static System.Windows.Window window = null; + public static void Show() + { + if (window == null || !window.Activate()) + { + window = new GlobalColorPickerWindow(); + } + window.Show(); + Keyboard.Focus(window); + } + + private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs e) + { + Show(); + } + + private void Button_MouseEnter(object sender, MouseEventArgs e) + { + Button btn = sender as Button; + btn.Opacity = 1; + } + + private void Button_MouseLeave(object sender, MouseEventArgs e) + { + Button btn = sender as Button; + btn.Opacity = 0.6; + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + this.Close(); + } + } +} diff --git a/Control/Windows/PixelColorPickerWindow.xaml b/Control/Windows/PixelColorPickerWindow.xaml new file mode 100644 index 0000000..ae8876a --- /dev/null +++ b/Control/Windows/PixelColorPickerWindow.xaml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Control/Windows/PixelColorPickerWindow.xaml.cs b/Control/Windows/PixelColorPickerWindow.xaml.cs new file mode 100644 index 0000000..e500a56 --- /dev/null +++ b/Control/Windows/PixelColorPickerWindow.xaml.cs @@ -0,0 +1,208 @@ +using GeekDesk.Interface; +using GeekDesk.Util; +using HandyControl.Controls; +using System; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace GeekDesk.Control.Windows +{ + /// + /// ColorPickerWindow.xaml 的交互逻辑 + /// + public partial class PixelColorPickerWindow : IWindowCommon + { + private static int PIXEL_REC_LENGTH = 20; + + private static readonly int MIN_LENGTH = 10; + private static readonly int MAX_LENGTH = 50; + + private static System.Drawing.Bitmap bgBitmap; + + private readonly ColorPicker colorPicker; + + public PixelColorPickerWindow(ColorPicker colorPicker) + { + InitializeComponent(); + this.colorPicker = colorPicker; + ColorPickerWindow_Init(); + } + + private void ColorPickerWindow_Init() + { + + this.WindowState = WindowState.Normal;//还原窗口(非最小化和最大化) + + this.Width = SystemParameters.VirtualScreenWidth; + this.Height = SystemParameters.VirtualScreenHeight; + + this.Left = SystemParameters.VirtualScreenLeft; + this.Top = SystemParameters.VirtualScreenTop; + + DesktopBG.Width = this.Width; + DesktopBG.Height = this.Height; + this.Topmost = true; + + bgBitmap = new System.Drawing.Bitmap( + (int)SystemParameters.VirtualScreenWidth, + (int)SystemParameters.VirtualScreenHeight, + System.Drawing.Imaging.PixelFormat.Format32bppArgb + ); + + using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bgBitmap)) + { + g.CopyFromScreen( + 0, + 0, + 0, + 0, + bgBitmap.Size + ); + } + + BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap( + bgBitmap.GetHbitmap(), + IntPtr.Zero, + Int32Rect.Empty, + BitmapSizeOptions.FromEmptyOptions() + ); + ImageBrush ib = (ImageBrush)DesktopBG.Background; + ib.ImageSource = bs; + + VisualBrush b = (VisualBrush)PixelBG.Fill; + b.Visual = DesktopBG; + Mouse.OverrideCursor = Cursors.Cross; + SetPixelAbout(null); + } + + + [DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)] + public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop); + + + public void OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Escape) + { + this.DataContext = null; + this.Close(); + } + } + + private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + Point pos = e.MouseDevice.GetPosition(DesktopBG); + System.Drawing.Color colorD = bgBitmap.GetPixel((int)pos.X, (int)pos.Y); + colorPicker.SelectedBrush = new SolidColorBrush(Color.FromArgb(colorD.A, colorD.R, colorD.G, colorD.B)); + DeleteObject(bgBitmap.GetHbitmap()); + this.Close(); + ClickColorPickerToggleButton(colorPicker); + + } + + public void ClickColorPickerToggleButton(ColorPicker colorPicker) + { + const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + Type type = colorPicker.GetType(); + FieldInfo fi = type.GetField("_toggleButtonDropper", InstanceBindFlags); + + ToggleButton tb = (ToggleButton)fi.GetValue(colorPicker); + if (tb != null && tb.IsChecked == true) + { + tb.IsChecked = false; + MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags); + mi.Invoke(colorPicker, new object[] { null, null }); + } + } + + + private void Window_MouseEnter(object sender, MouseEventArgs e) + { + Mouse.OverrideCursor = Cursors.Cross; + } + + private void Window_PreviewMouseMove(object sender, MouseEventArgs e) + { + SetPixelAbout(e); + } + + [System.Runtime.InteropServices.DllImport("gdi32.dll")] + public static extern bool DeleteObject(IntPtr onj); + + private void SetPixelAbout(MouseEventArgs e) + { + VisualBrush b = (VisualBrush)PixelBG.Fill; + + Point pos; + if (e == null) + { + pos = MouseUtil.GetMousePosition(); + } + else + { + pos = e.MouseDevice.GetPosition(DesktopBG); + } + Rect viewBox = b.Viewbox; + + viewBox.Width = PIXEL_REC_LENGTH; + viewBox.Height = PIXEL_REC_LENGTH; + + viewBox.X = pos.X - PIXEL_REC_LENGTH / 2; + viewBox.Y = pos.Y - PIXEL_REC_LENGTH / 2; + b.Viewbox = viewBox; + + double x = pos.X + 10; + double y = pos.Y + 10; + if (x + ColorCanvas.Width > SystemParameters.VirtualScreenWidth) + { + x = pos.X - ColorCanvas.Width - 10; + } + if (y + ColorCanvas.Height > SystemParameters.VirtualScreenHeight) + { + y = pos.Y - ColorCanvas.Height - 10; + } + + Canvas.SetLeft(ColorCanvas, x); + Canvas.SetTop(ColorCanvas, y); + + + System.Drawing.Color dColor = bgBitmap.GetPixel((int)pos.X, (int)pos.Y); + + PixelColor_HTML.Text = "#" + dColor.Name.ToUpper(); + PixelColor_RGB.Text = dColor.R + "," + dColor.G + "," + dColor.B; + Pixel_XY.Text = pos.X + "*" + pos.Y; + + SolidColorBrush scb = (SolidColorBrush)PixelColor.Fill; + scb.Color = Color.FromArgb(dColor.A, dColor.R, dColor.G, dColor.B); + } + + /// + /// 滚轮控制缩放区域 + /// + /// + /// + private void Window_MouseWheel(object sender, MouseWheelEventArgs e) + { + + if (e.Delta < 0 && PIXEL_REC_LENGTH < MAX_LENGTH) + { + //缩小 + PIXEL_REC_LENGTH += 5; + } + else if (e.Delta > 0 && PIXEL_REC_LENGTH > MIN_LENGTH) + { + //放大 + PIXEL_REC_LENGTH -= 5; + } + SetPixelAbout(e); + } + + } +} diff --git a/Control/Windows/SystemItemWindow.xaml.cs b/Control/Windows/SystemItemWindow.xaml.cs index 7153f30..0f79d65 100644 --- a/Control/Windows/SystemItemWindow.xaml.cs +++ b/Control/Windows/SystemItemWindow.xaml.cs @@ -1,5 +1,4 @@ using GeekDesk.Constant; -using GeekDesk.Control.Other; using GeekDesk.Interface; using GeekDesk.Util; using GeekDesk.ViewModel; @@ -8,13 +7,10 @@ using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; -using System.Drawing; using System.IO; -using System.Resources; using System.Threading; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Input; using System.Windows.Media.Imaging; using static GeekDesk.Util.ShowWindowFollowMouse; @@ -85,7 +81,8 @@ namespace GeekDesk.Control.Windows IsBackground = true }; t.Start(); - } else + } + else { StartMenuLoading.Visibility = Visibility.Collapsed; vm.IconInfos = startMenuIcons; @@ -109,7 +106,8 @@ namespace GeekDesk.Control.Windows vm.IconInfos = null; systemIcons = GetSysteIconInfos(); vm.IconInfos = systemIcons; - } else + } + else { vm.IconInfos = systemIcons; } @@ -142,7 +140,7 @@ namespace GeekDesk.Control.Windows } StartMenuLoading.Visibility = Visibility.Collapsed; })); - + } /// @@ -161,7 +159,8 @@ namespace GeekDesk.Control.Windows if (filePaths == null || filePaths.Length == 0) { dirPaths.CopyTo(paths, 0); - } else + } + else { dirPaths.CopyTo(paths, filePaths.Length - 1); } @@ -195,7 +194,7 @@ namespace GeekDesk.Control.Windows //foreach(FileSystemInfo fi in fileInfoArr) //{ // string path = fi.FullName; - + //} } diff --git a/Control/Windows/ToDoInfoWindow.xaml.cs b/Control/Windows/ToDoInfoWindow.xaml.cs index a5ed3be..5df9841 100644 --- a/Control/Windows/ToDoInfoWindow.xaml.cs +++ b/Control/Windows/ToDoInfoWindow.xaml.cs @@ -5,18 +5,9 @@ using GeekDesk.ViewModel; using HandyControl.Controls; using Quartz; 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.Shapes; namespace GeekDesk.Control.Windows { @@ -42,7 +33,8 @@ namespace GeekDesk.Control.Windows DateTime time = DateTime.Now.AddMinutes(10); ExeTime.SelectedDateTime = time; SetTimePanel.Visibility = Visibility.Visible; - this.DataContext = new ToDoInfo { + this.DataContext = new ToDoInfo + { ExeTime = time.ToString("yyyy-MM-dd HH:mm:ss") }; } @@ -97,7 +89,8 @@ namespace GeekDesk.Control.Windows { Growl.Warning("任务标题不能为空!"); return; - } else + } + else { if (SetTimePanel.Visibility == Visibility.Visible) { @@ -117,7 +110,9 @@ namespace GeekDesk.Control.Windows return; } execTime = ExeTime.Text; - } else { + } + else + { execType = TodoTaskExecType.CRON; if (Cron.Text.Trim() == "") { @@ -128,7 +123,8 @@ namespace GeekDesk.Control.Windows { bool isValid = CronExpression.IsValidExpression(Cron.Text); if (!isValid) throw new Exception(); - } catch (Exception) + } + catch (Exception) { Growl.Warning("请输入正确的Cron表达式!"); return; @@ -155,7 +151,8 @@ namespace GeekDesk.Control.Windows if (appData.HiToDoList.Contains(tdi)) { appData.HiToDoList.Remove(tdi); - } else if (appData.ToDoList.Contains(tdi)) + } + else if (appData.ToDoList.Contains(tdi)) { appData.ToDoList.Remove(tdi); } @@ -175,7 +172,8 @@ namespace GeekDesk.Control.Windows int h = minutes / 60; Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + h + " 小时零 " + m + " 分钟后提醒您!"); - } else + } + else { Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + minutes + " 分钟后提醒您!"); } @@ -202,7 +200,8 @@ namespace GeekDesk.Control.Windows { window = new ToDoInfoWindow(); window.Show(); - } else + } + else { window.Close(); } diff --git a/Control/Windows/ToDoWindow.xaml.cs b/Control/Windows/ToDoWindow.xaml.cs index a374cf0..16469a3 100644 --- a/Control/Windows/ToDoWindow.xaml.cs +++ b/Control/Windows/ToDoWindow.xaml.cs @@ -2,20 +2,8 @@ using GeekDesk.Interface; using GeekDesk.ViewModel; using HandyControl.Controls; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -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.Shapes; namespace GeekDesk.Control.Windows { diff --git a/Control/Windows/UpdateWindow.xaml.cs b/Control/Windows/UpdateWindow.xaml.cs index 1aa8ff0..dde1981 100644 --- a/Control/Windows/UpdateWindow.xaml.cs +++ b/Control/Windows/UpdateWindow.xaml.cs @@ -4,20 +4,10 @@ using GeekDesk.Util; using GeekDesk.ViewModel; using Newtonsoft.Json.Linq; using System; -using System.Collections.Generic; using System.Configuration; using System.Diagnostics; -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.Shapes; namespace GeekDesk.Control.Windows { @@ -42,7 +32,7 @@ namespace GeekDesk.Control.Windows { } - + } /// @@ -68,7 +58,7 @@ namespace GeekDesk.Control.Windows githubUrl = StringUtil.IsEmpty(jo["githubUrl"]) ? ConfigurationManager.AppSettings["GitHubUrl"] : jo["githubUrl"].ToString(); giteeUrl = StringUtil.IsEmpty(jo["giteeUrl"]) ? ConfigurationManager.AppSettings["GiteeUrl"] : jo["giteeUrl"].ToString(); string msg = ""; - for (int i=0; itrue true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true AnyCPU @@ -127,12 +142,14 @@ + + BacklogNotificatin.xaml @@ -140,6 +157,12 @@ CustomIconUrlDialog.xaml + + GradientBGDialog.xaml + + + MyColorPickerDialog.xaml + IconInfoUrlDialog.xaml @@ -155,6 +178,12 @@ IconPannel.xaml + + GlobalColorPickerWindow.xaml + + + PixelColorPickerWindow.xaml + SystemItemWindow.xaml @@ -191,6 +220,7 @@ UpdateWindow.xaml + @@ -198,7 +228,9 @@ + + @@ -208,6 +240,8 @@ + + @@ -225,6 +259,9 @@ + + + @@ -238,6 +275,14 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -258,6 +303,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -402,5 +455,17 @@ + + + False + Microsoft .NET Framework 4.7.2 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/GeekDesk.sln b/GeekDesk.sln index a05cf6d..b21eaf0 100644 --- a/GeekDesk.sln +++ b/GeekDesk.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Blend for Visual Studio Version 16 -VisualStudioVersion = 16.0.30907.101 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32319.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeekDesk", "GeekDesk.csproj", "{B4983CEC-2281-413C-8ECF-92EE0E40A713}" EndProject diff --git a/Interface/IWindowCommon.cs b/Interface/IWindowCommon.cs index d79d0a8..b74eba7 100644 --- a/Interface/IWindowCommon.cs +++ b/Interface/IWindowCommon.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Input; +using System.Windows.Input; namespace GeekDesk.Interface { diff --git a/MainWindow.xaml b/MainWindow.xaml index bed8d00..24cd1c9 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -60,7 +60,7 @@ Focusable="True" > - + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index ed7c425..1ca5d5a 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -2,23 +2,21 @@ using GeekDesk.Control.UserControls.Config; using GeekDesk.Control.Windows; using GeekDesk.Interface; -using GeekDesk.Task; using GeekDesk.MyThread; +using GeekDesk.Task; using GeekDesk.Util; using GeekDesk.ViewModel; - +using GeekDesk.ViewModel.Temp; +using NPinyin; using System; +using System.Collections.ObjectModel; using System.Diagnostics; +using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media.Animation; using static GeekDesk.Util.ShowWindowFollowMouse; -using System.Collections.ObjectModel; -using NPinyin; -using GeekDesk.ViewModel.Temp; -using System.Threading; -using DraggAnimatedPanelExample; namespace GeekDesk { @@ -33,6 +31,7 @@ namespace GeekDesk public static ToDoInfoWindow toDoInfoWindow; public static int hotKeyId = -1; public static int toDoHotKeyId = -1; + public static int colorPickerHotKeyId = -1; public static MainWindow mainWindow; public MainWindow() { @@ -153,8 +152,19 @@ namespace GeekDesk BarIcon.Text = Constants.MY_NAME; //注册热键 - RegisterHotKey(true); - RegisterCreateToDoHotKey(true); + if (true == appData.AppConfig.EnableAppHotKey) + { + RegisterHotKey(true); + } + if (true == appData.AppConfig.EnableTodoHotKey) + { + RegisterCreateToDoHotKey(true); + } + + if (true == appData.AppConfig.EnableColorPickerHotKey) + { + RegisterColorPickerHotKey(true); + } //注册自启动 if (!appData.AppConfig.SelfStartUped && !Constants.DEV) @@ -196,10 +206,10 @@ namespace GeekDesk } } }); - } - if (!first) - { - HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl"); + if (!first) + { + HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl"); + } } } catch (Exception) @@ -236,11 +246,12 @@ namespace GeekDesk ToDoInfoWindow.ShowOrHide(); } }); + if (!first) + { + HandyControl.Controls.Growl.Success("新建待办任务快捷键注册成功(" + appData.AppConfig.ToDoHotkeyStr + ")!", "HotKeyGrowl"); + } } - if (!first) - { - HandyControl.Controls.Growl.Success("新建待办任务快捷键注册成功(" + appData.AppConfig.ToDoHotkeyStr + ")!", "HotKeyGrowl"); - } + } catch (Exception) { @@ -255,6 +266,43 @@ namespace GeekDesk } } + /// + /// 注册新建待办的热键 + /// + public static void RegisterColorPickerHotKey(bool first) + { + try + { + + if (appData.AppConfig.ColorPickerHotkeyModifiers != 0) + { + //加载完毕注册热键 + colorPickerHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ColorPickerHotkeyModifiers, appData.AppConfig.ColorPickerHotkey, () => + { + if (MotionControl.hotkeyFinished) + { + GlobalColorPickerWindow.Show(); + } + }); + if (!first) + { + HandyControl.Controls.Growl.Success("拾色器快捷键注册成功(" + appData.AppConfig.ColorPickerHotkeyStr + ")!", "HotKeyGrowl"); + } + } + } + catch (Exception) + { + if (first) + { + HandyControl.Controls.Growl.WarningGlobal("拾色器快捷键已被其它程序占用(" + appData.AppConfig.ColorPickerHotkeyStr + ")!"); + } + else + { + HandyControl.Controls.Growl.Warning("拾色器快捷键已被其它程序占用(" + appData.AppConfig.ColorPickerHotkeyStr + ")!", "HotKeyGrowl"); + } + } + } + /// /// 重置窗体大小 写入缓存 @@ -384,24 +432,27 @@ namespace GeekDesk if (RunTimeStatus.SEARCH_BOX_SHOW) { mainWindow.HidedSearchBox(); - new Thread(() => + Thread t = new Thread(() => { Thread.Sleep(100); App.Current.Dispatcher.BeginInvoke(new Action(() => { FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed); })); - }).Start(); + }); + t.IsBackground = true; + t.Start(); } else { FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed); } - } else + } + else { ShowApp(); } - + } /// @@ -630,5 +681,10 @@ namespace GeekDesk //防止延迟贴边隐藏 RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false; } + + private void ColorPicker(object sender, RoutedEventArgs e) + { + GlobalColorPickerWindow.Show(); + } } } diff --git a/MyThread/DispatcherBuild.cs b/MyThread/DispatcherBuild.cs index 5112740..4044c04 100644 --- a/MyThread/DispatcherBuild.cs +++ b/MyThread/DispatcherBuild.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; +using System.Threading; using System.Windows.Threading; namespace GeekDesk.MyThread @@ -25,6 +20,7 @@ namespace GeekDesk.MyThread manualResetEvent.Set(); Dispatcher.Run(); }); + thread.IsBackground = true; thread.Start(); manualResetEvent.WaitOne(); manualResetEvent.Dispose(); diff --git a/MyThread/MouseHookThread.cs b/MyThread/MouseHookThread.cs index 4952ff7..5b44c4f 100644 --- a/MyThread/MouseHookThread.cs +++ b/MyThread/MouseHookThread.cs @@ -2,11 +2,6 @@ using GeekDesk.ViewModel; using Gma.System.MouseKeyHook; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; @@ -50,7 +45,7 @@ namespace GeekDesk.MyThread if (MotionControl.hotkeyFinished) { App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() => - { + { if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0) { MainWindow.ShowApp(); diff --git a/MyThread/UpdateThread.cs b/MyThread/UpdateThread.cs index da1ac17..f09ebe4 100644 --- a/MyThread/UpdateThread.cs +++ b/MyThread/UpdateThread.cs @@ -4,13 +4,8 @@ using GeekDesk.Util; using GeekDesk.ViewModel; using Newtonsoft.Json.Linq; using System; -using System.Collections.Generic; using System.Configuration; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; -using System.Windows; namespace GeekDesk.MyThread { @@ -59,7 +54,8 @@ namespace GeekDesk.MyThread })); } } - } catch (Exception ex) + } + catch (Exception ex) { LogUtil.WriteErrorLog(ex, "获取更新失败!"); } diff --git a/Task/ToDoTask.cs b/Task/ToDoTask.cs index 0710b5a..03d31e5 100644 --- a/Task/ToDoTask.cs +++ b/Task/ToDoTask.cs @@ -1,16 +1,11 @@ -using GeekDesk.Control; -using GeekDesk.Control.Other; +using GeekDesk.Control.Other; using GeekDesk.ViewModel; using HandyControl.Controls; using HandyControl.Data; using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; using System.Timers; namespace GeekDesk.Task diff --git a/Util/BGSettingUtil.cs b/Util/BGSettingUtil.cs index 2361605..b851f11 100644 --- a/Util/BGSettingUtil.cs +++ b/Util/BGSettingUtil.cs @@ -1,13 +1,8 @@ using GeekDesk.Constant; using GeekDesk.ViewModel; 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.Media; using System.Windows.Media.Effects; @@ -29,9 +24,9 @@ namespace GeekDesk.Util Margin = new Thickness(-30), Source = appConfig.BitmapImage, Opacity = (double)(Math.Round((decimal)(appConfig.BgOpacity / 100.00), 2)) - }; + }; + - //binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; //image.SetBinding(Image.OpacityProperty, binding); @@ -67,7 +62,7 @@ namespace GeekDesk.Util lgb.GradientStops.Add(gs2); MainWindow.mainWindow.BGBorder.Background = lgb; } - + } } diff --git a/Util/ColorUtil.cs b/Util/ColorUtil.cs new file mode 100644 index 0000000..9858908 --- /dev/null +++ b/Util/ColorUtil.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekDesk.Util +{ + public class ColorUtil + { + + + + } +} diff --git a/Util/FileIcon.cs b/Util/FileIcon.cs index 1acc48b..f0d5c60 100644 --- a/Util/FileIcon.cs +++ b/Util/FileIcon.cs @@ -1,5 +1,4 @@ -using IWshRuntimeLibrary; -using System; +using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; @@ -21,17 +20,17 @@ namespace GeekDesk.Util return list; } - [DllImport("User32.dll")] - public static extern int PrivateExtractIcons( - string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp - int nIconIndex, //从第几个图标开始获取 - int cxIcon, //获取图标的尺寸x - int cyIcon, //获取图标的尺寸y - IntPtr[] phicon, //获取到的图标指针数组 - int[] piconid, //图标对应的资源编号 - int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用 - int flags //标志,默认0就可以,具体可以看LoadImage函数 - ); + [DllImport("User32.dll")] + public static extern int PrivateExtractIcons( + string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp + int nIconIndex, //从第几个图标开始获取 + int cxIcon, //获取图标的尺寸x + int cyIcon, //获取图标的尺寸y + IntPtr[] phicon, //获取到的图标指针数组 + int[] piconid, //图标对应的资源编号 + int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用 + int flags //标志,默认0就可以,具体可以看LoadImage函数 + ); public static BitmapImage GetBitmapImage(string filePath) diff --git a/Util/FileUtil.cs b/Util/FileUtil.cs index 19c4911..eb5a180 100644 --- a/Util/FileUtil.cs +++ b/Util/FileUtil.cs @@ -1,11 +1,8 @@ using IWshRuntimeLibrary; using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace GeekDesk.Util { diff --git a/Util/GlobalHotKey.cs b/Util/GlobalHotKey.cs index 34bcb48..f1c736d 100644 --- a/Util/GlobalHotKey.cs +++ b/Util/GlobalHotKey.cs @@ -53,7 +53,8 @@ namespace GeekDesk.Util UnregisterHotKey(handleTemp[id].Handle, id); GlobalHotKey.handleTemp[id].Dispose(); GlobalHotKey.handleTemp.Remove(id); - } catch + } + catch { //nothing } @@ -75,7 +76,7 @@ namespace GeekDesk.Util { CreateHandle(new CreateParams()); this.callback += callback; - } + } private static readonly int WM_HOTKEY = 0x0312; protected override void WndProc(ref Message m) @@ -94,4 +95,4 @@ namespace GeekDesk.Util } - } +} diff --git a/Util/HttpUtil.cs b/Util/HttpUtil.cs index 165b51f..00bf2c5 100644 --- a/Util/HttpUtil.cs +++ b/Util/HttpUtil.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Net; using System.Text; -using System.Web; namespace GeekDesk.Util { diff --git a/Util/ImageUtil.cs b/Util/ImageUtil.cs index a4d76c4..010f413 100644 --- a/Util/ImageUtil.cs +++ b/Util/ImageUtil.cs @@ -1,12 +1,9 @@ using GeekDesk.Constant; using System; using System.Drawing; -using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.IO; using System.Text.RegularExpressions; -using System.Windows; -using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; diff --git a/Util/LogUtil.cs b/Util/LogUtil.cs index 4fc397b..627c61f 100644 --- a/Util/LogUtil.cs +++ b/Util/LogUtil.cs @@ -1,10 +1,7 @@ using GeekDesk.Constant; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; -using System.Threading.Tasks; namespace GeekDesk.Util { @@ -48,27 +45,30 @@ namespace GeekDesk.Util fs.Write(buffer, 0, buffer.Length); } } - } catch + } + catch { } - + } public static void WriteLog(string msg) { - try { - using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite)) + try { - fs.Seek(0, SeekOrigin.End); - byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n"); - fs.Write(buffer, 0, buffer.Length); + using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite)) + { + fs.Seek(0, SeekOrigin.End); + byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n"); + fs.Write(buffer, 0, buffer.Length); - buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n" ); - fs.Write(buffer, 0, buffer.Length); + buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n"); + fs.Write(buffer, 0, buffer.Length); + } } - } catch { } + catch { } } diff --git a/Util/MarginHide.cs b/Util/MarginHide.cs index 50e99ef..1acc371 100644 --- a/Util/MarginHide.cs +++ b/Util/MarginHide.cs @@ -1,9 +1,8 @@ -using System; - -using System.Windows.Forms; +using GeekDesk.Constant; +using System; using System.Windows; +using System.Windows.Forms; using System.Windows.Media.Animation; -using GeekDesk.Constant; namespace GeekDesk.Util { @@ -71,7 +70,7 @@ namespace GeekDesk.Util #region 窗体贴边隐藏功能 private static void HideWindow(object o, EventArgs e) { - if (window.Visibility != Visibility.Visible + if (window.Visibility != Visibility.Visible || RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW) return; double screenLeft = SystemParameters.VirtualScreenLeft; @@ -302,12 +301,14 @@ namespace GeekDesk.Util public static void WaitHide(int waitTime) { - new System.Threading.Thread(()=> + System.Threading.Thread t = new System.Threading.Thread(() => { System.Threading.Thread.Sleep(waitTime); //修改状态为false 继续执行贴边隐藏 RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false; - }).Start(); + }); + t.IsBackground = true; + t.Start(); } diff --git a/Util/MouseUtil.cs b/Util/MouseUtil.cs index 210e72d..6197053 100644 --- a/Util/MouseUtil.cs +++ b/Util/MouseUtil.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; namespace GeekDesk.Util diff --git a/Util/RegisterUtil.cs b/Util/RegisterUtil.cs index b6572e8..93f4801 100644 --- a/Util/RegisterUtil.cs +++ b/Util/RegisterUtil.cs @@ -1,9 +1,5 @@ using Microsoft.Win32; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace GeekDesk.Util { diff --git a/Util/ShellContextMenu.cs b/Util/ShellContextMenu.cs index dec8a0b..cd10a20 100644 --- a/Util/ShellContextMenu.cs +++ b/Util/ShellContextMenu.cs @@ -1,11 +1,9 @@ using System; -using System.Collections.Generic; -using System.Text; -using System.Runtime.InteropServices; using System.Drawing; -using System.Windows.Forms; using System.IO; -using System.Security.Permissions; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; namespace GeekDesk.Util { @@ -1166,7 +1164,7 @@ namespace GeekDesk.Util Int32 ParseDisplayName( IntPtr hwnd, IntPtr pbc, - [MarshalAs(UnmanagedType.LPWStr)] + [MarshalAs(UnmanagedType.LPWStr)] string pszDisplayName, ref uint pchEaten, out IntPtr ppidl, @@ -1261,7 +1259,7 @@ namespace GeekDesk.Util Int32 SetNameOf( IntPtr hwnd, IntPtr pidl, - [MarshalAs(UnmanagedType.LPWStr)] + [MarshalAs(UnmanagedType.LPWStr)] string pszName, SHGNO uFlags, out IntPtr ppidlOut); diff --git a/Util/StringUtil.cs b/Util/StringUtil.cs index 33c54c2..029d0ca 100644 --- a/Util/StringUtil.cs +++ b/Util/StringUtil.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GeekDesk.Util +namespace GeekDesk.Util { - public class StringUtil + public class StringUtil { diff --git a/Util/SvgToGeometry.cs b/Util/SvgToGeometry.cs index 55f5d91..c202253 100644 --- a/Util/SvgToGeometry.cs +++ b/Util/SvgToGeometry.cs @@ -4,10 +4,8 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Security.Cryptography; using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Xml; diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs index 16196e5..008e05b 100644 --- a/ViewModel/AppConfig.cs +++ b/ViewModel/AppConfig.cs @@ -48,7 +48,12 @@ namespace GeekDesk.ViewModel private string toDoHotkeyStr = "Ctrl + Shift + Q"; //待办任务快捷键 private HotkeyModifiers toDoHotkeyModifiers; //待办任务快捷键 - private Key toDoHotkey = Key.E; //待办任务快捷键 + private Key toDoHotkey = Key.Q; //待办任务快捷键 + + + private string colorPickerHotkeyStr = ""; //拾色器快捷键 + private HotkeyModifiers colorPickerHotkeyModifiers; //拾色器快捷键 + private Key colorPickerHotkey; //拾色器快捷键 private string customIconUrl; //自定义图标url private string customIconJsonUrl; //自定义图标json信息url @@ -81,9 +86,55 @@ namespace GeekDesk.ViewModel private GradientBGParam gradientBGParam = null; //渐变背景参数 + private bool? enableAppHotKey = true; //可能为null + private bool? enableTodoHotKey = true; //可能为null + + private bool enableColorPickerHotKey; //新增 默认为false 不需要考虑null值 + + #region GetSet - + public bool EnableColorPickerHotKey + { + get + { + return enableColorPickerHotKey; + } + set + { + enableColorPickerHotKey = value; + OnPropertyChanged("EnableColorPickerHotKey"); + } + } + + public bool? EnableAppHotKey + { + get + { + if (enableAppHotKey == null) enableAppHotKey = true; + return enableAppHotKey; + } + set + { + enableAppHotKey = value; + OnPropertyChanged("EnableAppHotKey"); + } + } + + public bool? EnableTodoHotKey + { + get + { + if (enableTodoHotKey == null) enableTodoHotKey = true; + return enableTodoHotKey; + } + set + { + enableTodoHotKey = value; + OnPropertyChanged("EnableTodoHotKey"); + } + } + public Visibility TitleLogoVisible { get @@ -375,6 +426,47 @@ namespace GeekDesk.ViewModel } } + public Key ColorPickerHotkey + { + get + { + return colorPickerHotkey; + } + set + { + colorPickerHotkey = value; + OnPropertyChanged("ColorPickerHotkey"); + } + } + + + public HotkeyModifiers ColorPickerHotkeyModifiers + { + get + { + return colorPickerHotkeyModifiers; + } + set + { + colorPickerHotkeyModifiers = value; + OnPropertyChanged("ColorPickerHotkeyModifiers"); + } + } + + public string ColorPickerHotkeyStr + { + get + { + return colorPickerHotkeyStr; + } + set + { + colorPickerHotkeyStr = value; + OnPropertyChanged("ColorPickerHotkeyStr"); + } + } + + public Key ToDoHotkey { get @@ -382,7 +474,7 @@ namespace GeekDesk.ViewModel //兼容老版本 if (toDoHotkey == Key.None) { - toDoHotkey = Key.Q; + toDoHotkey = Key.E; } return toDoHotkey; } diff --git a/ViewModel/AppData.cs b/ViewModel/AppData.cs index e3d06da..1a96533 100644 --- a/ViewModel/AppData.cs +++ b/ViewModel/AppData.cs @@ -1,6 +1,5 @@ using GeekDesk.Util; using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; diff --git a/ViewModel/CPDataContext.cs b/ViewModel/CPDataContext.cs new file mode 100644 index 0000000..929da18 --- /dev/null +++ b/ViewModel/CPDataContext.cs @@ -0,0 +1,93 @@ +using System.ComponentModel; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +namespace GeekDesk.ViewModel +{ + + public class CPDataContext : INotifyPropertyChanged + { + private BitmapSource pixelIMG; + + private System.Drawing.Color pixelColor_D; + + public Color pixelColor; + + private string colorHtml; + + private string colorRGB; + + private string pixelXY; + + public BitmapSource PixelIMG + { + set + { + pixelIMG = value; + OnPropertyChanged("PixelIMG"); + } + get { return pixelIMG; } + } + + public System.Drawing.Color PixelColor_D + { + set + { + pixelColor_D = value; + ColorHtml = pixelColor_D.Name.ToUpper().Substring(2); + ColorRGB = pixelColor_D.R + "," + pixelColor_D.G + "," + pixelColor_D.B; + PixelColor = Color.FromArgb(pixelColor_D.A, pixelColor_D.R, pixelColor_D.G, pixelColor_D.B); + } + get { return pixelColor_D; } + } + + public Color PixelColor + { + set + { + pixelColor = value; + OnPropertyChanged("PixelColor"); + } + get { return pixelColor; } + } + + public string ColorRGB + { + set + { + colorRGB = value; + OnPropertyChanged("ColorRGB"); + } + get { return colorRGB; } + } + + public string ColorHtml + { + set + { + colorHtml = value; + OnPropertyChanged("ColorHtml"); + } + get { return colorHtml; } + } + + + public string PixelXY + { + set + { + pixelXY = value; + OnPropertyChanged("PixelXY"); + } + get { return pixelXY; } + } + + + + public event PropertyChangedEventHandler PropertyChanged; + private void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } +} diff --git a/ViewModel/GradientBGParam.cs b/ViewModel/GradientBGParam.cs index d031f54..afaa258 100644 --- a/ViewModel/GradientBGParam.cs +++ b/ViewModel/GradientBGParam.cs @@ -1,10 +1,6 @@ using GeekDesk.Util; using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace GeekDesk.ViewModel { @@ -19,7 +15,8 @@ namespace GeekDesk.ViewModel public GradientBGParam() { } - public GradientBGParam(string name, string color1, string color2) { + public GradientBGParam(string name, string color1, string color2) + { this.name = name; this.color1 = color1; this.color2 = color2; diff --git a/ViewModel/IconInfo.cs b/ViewModel/IconInfo.cs index e2f1b34..2ae550a 100644 --- a/ViewModel/IconInfo.cs +++ b/ViewModel/IconInfo.cs @@ -1,11 +1,7 @@ using GeekDesk.Constant; using GeekDesk.Util; -using Newtonsoft.Json; using System; using System.ComponentModel; -using System.IO; -using System.Reflection; -using System.Text; using System.Windows.Media.Imaging; /// diff --git a/ViewModel/IconfontInfo.cs b/ViewModel/IconfontInfo.cs index b5428f7..f36a176 100644 --- a/ViewModel/IconfontInfo.cs +++ b/ViewModel/IconfontInfo.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GeekDesk.ViewModel +namespace GeekDesk.ViewModel { public class IconfontInfo { diff --git a/ViewModel/MenuInfo.cs b/ViewModel/MenuInfo.cs index 2db5812..328ab62 100644 --- a/ViewModel/MenuInfo.cs +++ b/ViewModel/MenuInfo.cs @@ -11,7 +11,7 @@ namespace GeekDesk.ViewModel [Serializable] public class MenuInfo : INotifyPropertyChanged { - + private string menuName; private string menuId; @@ -65,7 +65,7 @@ namespace GeekDesk.ViewModel set { menuName = value; - OnPropertyChanged("MenuName"); + OnPropertyChanged("MenuName"); } } @@ -94,7 +94,8 @@ namespace GeekDesk.ViewModel if (menuEdit == Visibility.Visible) { NotMenuEdit = Visibility.Collapsed; - } else + } + else { NotMenuEdit = Visibility.Visible; } diff --git a/ViewModel/Temp/GradientBGParamList.cs b/ViewModel/Temp/GradientBGParamList.cs index 6c5886f..87b3e0d 100644 --- a/ViewModel/Temp/GradientBGParamList.cs +++ b/ViewModel/Temp/GradientBGParamList.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Configuration; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.ObjectModel; namespace GeekDesk.ViewModel.Temp { @@ -37,6 +31,6 @@ namespace GeekDesk.ViewModel.Temp gradientBGParams = value; } } - + } } diff --git a/ViewModel/ToDoInfo.cs b/ViewModel/ToDoInfo.cs index 1491dcd..b0dd8d2 100644 --- a/ViewModel/ToDoInfo.cs +++ b/ViewModel/ToDoInfo.cs @@ -1,11 +1,7 @@ using GeekDesk.Constant; using GeekDesk.Util; using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace GeekDesk.ViewModel {