From f7b3cf71c760e3f7bd6bfda58cacb66ccf9ec17d Mon Sep 17 00:00:00 2001 From: liufei Date: Thu, 21 Apr 2022 20:28:14 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=9B=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 2 +- Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/App.config b/App.config index 3a3e105..ce0c2d6 100644 --- a/App.config +++ b/App.config @@ -44,7 +44,7 @@ - + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 4f52fcb..4d07409 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ using System.Windows; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.4.1.4")] -[assembly: AssemblyFileVersion("2.4.1.4")] +[assembly: AssemblyVersion("2.4.1.5")] +[assembly: AssemblyFileVersion("2.4.1.5")] From 49410370819f8c683348db936666e8a4de61ed58 Mon Sep 17 00:00:00 2001 From: liufei Date: Tue, 26 Apr 2022 15:22:44 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B4=B4=E8=BE=B9?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E5=8A=9F=E8=83=BDbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Control/UserControls/PannelCard/RightCardControl.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml.cs b/Control/UserControls/PannelCard/RightCardControl.xaml.cs index c05b7b4..2a9ff2e 100644 --- a/Control/UserControls/PannelCard/RightCardControl.xaml.cs +++ b/Control/UserControls/PannelCard/RightCardControl.xaml.cs @@ -204,7 +204,7 @@ namespace GeekDesk.Control.UserControls.PannelCard //如果开启了贴边隐藏 则窗体不贴边才隐藏窗口 if (appData.AppConfig.MarginHide) { - if (!MarginHide.IS_HIDE) + if (!MarginHide.IsMargin()) { MainWindow.HideApp(); } @@ -222,7 +222,7 @@ namespace GeekDesk.Control.UserControls.PannelCard //如果开启了贴边隐藏 则窗体不贴边才隐藏窗口 if (appData.AppConfig.MarginHide) { - if (!MarginHide.IS_HIDE) + if (!MarginHide.IsMargin()) { MainWindow.HideApp(); } From ed0eaee98f35d29cdac0ffafdb8405c32b0e17b7 Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 9 May 2022 15:25:48 +0800 Subject: [PATCH 03/22] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B8=90=E5=8F=98?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Control/UserControls/Config/ThemeControl.xaml | 132 +++++++++++++----- .../UserControls/Config/ThemeControl.xaml.cs | 70 +++++++++- Converts/BGStyleConvert.cs | 29 ++++ MainWindow.xaml | 33 ++--- MainWindow.xaml.cs | 4 +- Util/BGSettingUtil.cs | 74 ++++++++++ 6 files changed, 287 insertions(+), 55 deletions(-) create mode 100644 Converts/BGStyleConvert.cs create mode 100644 Util/BGSettingUtil.cs diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml index ecc94a5..dbea9d4 100644 --- a/Control/UserControls/Config/ThemeControl.xaml +++ b/Control/UserControls/Config/ThemeControl.xaml @@ -4,42 +4,109 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:cvt="clr-namespace:GeekDesk.Converts" mc:Ignorable="d" Background="Transparent" d:DesignHeight="500" d:DesignWidth="450"> + + + + - - + + - - - - + + + + + + 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 { From 84727d8040e3bcd2eb57850349292f3b0af6d279 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 May 2022 16:36:54 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BB=9A=E8=BD=AE?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=8F=9C=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PannelCard/LeftCardControl.xaml | 4 ++- .../PannelCard/LeftCardControl.xaml.cs | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml b/Control/UserControls/PannelCard/LeftCardControl.xaml index 997973f..13138b9 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml @@ -8,7 +8,8 @@ xmlns:cvt="clr-namespace:GeekDesk.Converts" xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel" mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="450" d:DesignWidth="800" + > @@ -104,6 +105,7 @@ SelectedIndex="{Binding AppConfig.SelectedMenuIndex}" VirtualizingPanel.VirtualizationMode="Recycling" SelectionChanged="Menu_SelectionChanged" + PreviewMouseWheel="Menu_MouseWheel" > diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs index f092363..53fa4ba 100644 --- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs +++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs @@ -373,5 +373,33 @@ namespace GeekDesk.Control.UserControls.PannelCard MainWindow.mainWindow.HidedSearchBox(); } } + + private void Menu_MouseWheel(object sender, MouseWheelEventArgs e) + { + if (e.Delta < 0) + { + int index = MenuListBox.SelectedIndex; + if (index < MenuListBox.Items.Count - 1) + { + index ++; + } else + { + index = 0; + } + MenuListBox.SelectedIndex = index; + } else if (e.Delta > 0) + { + int index = MenuListBox.SelectedIndex; + if (index > 0) + { + index --; + } + else + { + index = MenuListBox.Items.Count - 1; + } + MenuListBox.SelectedIndex = index; + } + } } } From 09ab951ccd17a9aad69760c044ffc87cbf0a5dc7 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 May 2022 17:40:29 +0800 Subject: [PATCH 12/22] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E5=8A=A8=E7=94=BB,=20=E7=BA=B5=E4=BA=AB=E4=B8=9D=E6=BB=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Util/MarginHide.cs | 265 +++++++++++++++++++++++++++++---------------- 1 file changed, 173 insertions(+), 92 deletions(-) diff --git a/Util/MarginHide.cs b/Util/MarginHide.cs index 1acc371..0912d0d 100644 --- a/Util/MarginHide.cs +++ b/Util/MarginHide.cs @@ -1,8 +1,11 @@ using GeekDesk.Constant; +using GeekDesk.MyThread; using System; +using System.Threading; using System.Windows; -using System.Windows.Forms; + using System.Windows.Media.Animation; +using System.Windows.Threading; namespace GeekDesk.Util { @@ -22,10 +25,14 @@ namespace GeekDesk.Util { private static Window window;//定义使用该方法的窗体 - private static readonly int hideTime = 200; - private static readonly int fadeHideTime = 180; - private static readonly int fadeShowTime = 200; - private static readonly int taskTime = 250; + private static readonly int hideTime = 50; + private static readonly int showTime = 30; + + private static int animalTime; + + private static readonly int fadeHideTime = 50; + private static readonly int fadeShowTime = 50; + private static readonly int taskTime = 200; public static readonly int shadowWidth = 20; @@ -36,7 +43,7 @@ namespace GeekDesk.Util public static bool IS_HIDE = false; - private static Timer timer = null; + private static System.Windows.Forms.Timer timer = null; public static void ReadyHide(Window window) { @@ -96,7 +103,7 @@ namespace GeekDesk.Util if (windowTop <= screenTop) { IS_HIDE = true; - FadeAnimation(1, 0); + //FadeAnimation(1, 0); HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty, HideType.TOP_HIDE); return; } @@ -104,7 +111,7 @@ namespace GeekDesk.Util if (windowLeft <= screenLeft) { IS_HIDE = true; - FadeAnimation(1, 0); + //FadeAnimation(1, 0); HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty, HideType.LEFT_HIDE); return; } @@ -112,7 +119,7 @@ namespace GeekDesk.Util if (windowLeft + windowWidth + Math.Abs(screenLeft) >= screenWidth) { IS_HIDE = true; - FadeAnimation(1, 0); + //FadeAnimation(1, 0); HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty, HideType.RIGHT_HIDE); return; } @@ -125,7 +132,7 @@ namespace GeekDesk.Util { IS_HIDE = false; HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW); - FadeAnimation(0, 1); + //FadeAnimation(0, 1); return; } //左侧显示 @@ -133,7 +140,7 @@ namespace GeekDesk.Util { IS_HIDE = false; HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW); - FadeAnimation(0, 1); + //FadeAnimation(0, 1); return; } //右侧显示 @@ -141,7 +148,7 @@ namespace GeekDesk.Util { IS_HIDE = false; HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty, HideType.RIGHT_SHOW); - FadeAnimation(0, 1); + //FadeAnimation(0, 1); return; } } @@ -154,7 +161,7 @@ namespace GeekDesk.Util { ON_HIDE = true; if (timer != null) return; - timer = new Timer + timer = new System.Windows.Forms.Timer { Interval = taskTime };//添加timer计时器,隐藏功能 @@ -185,7 +192,7 @@ namespace GeekDesk.Util if (windowLeft <= screenLeft - showMarginWidth) { IS_HIDE = false; - FadeAnimation(0, 1); + //FadeAnimation(0, 1); HideAnimation(windowLeft, screenLeft, Window.LeftProperty, HideType.LEFT_SHOW); return; } @@ -194,7 +201,7 @@ namespace GeekDesk.Util if (windowTop <= screenTop - showMarginWidth) { IS_HIDE = false; - FadeAnimation(0, 1); + //FadeAnimation(0, 1); HideAnimation(windowTop, screenTop, Window.TopProperty, HideType.TOP_SHOW); return; } @@ -203,7 +210,7 @@ namespace GeekDesk.Util if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth) { IS_HIDE = false; - FadeAnimation(0, 1); + //FadeAnimation(0, 1); HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty, HideType.RIGHT_SHOW); return; } @@ -213,89 +220,163 @@ namespace GeekDesk.Util private static void HideAnimation(double from, double to, DependencyProperty property, HideType hideType) { + new Thread(() => + { + App.Current.Dispatcher.Invoke(() => + { + double abs = Math.Abs(Math.Abs(to) - Math.Abs(from)); + double subLen = abs / hideTime; - double toTemp = to; - double leftT = window.Width / 4 * 3; - double topT = window.Height / 4 * 3; - switch (hideType) - { - case HideType.LEFT_HIDE: - to += leftT; - break; - case HideType.LEFT_SHOW: - to -= leftT; - break; - case HideType.RIGHT_HIDE: - to -= leftT; - break; - case HideType.RIGHT_SHOW: - to += leftT; - break; - case HideType.TOP_HIDE: - to += topT; - break; - case HideType.TOP_SHOW: - to -= topT; - break; - } - DoubleAnimation da = new DoubleAnimation - { - From = from, - To = to, - Duration = new Duration(TimeSpan.FromMilliseconds(hideTime)) - }; - // 如果是显示 则贴屏幕侧不显示阴影 - bool isShow = false; - int shadowWidthTemp = Constants.SHADOW_WIDTH; - if (hideType <= HideType.RIGHT_SHOW) - { - isShow = true; - if (hideType == HideType.RIGHT_SHOW) - { - shadowWidthTemp = -shadowWidthTemp; - } - } - da.Completed += (s, e) => - { - if ("Top".Equals(property.Name)) - { - window.Top = isShow ? toTemp - shadowWidthTemp : toTemp; - } - else - { - window.Left = isShow ? toTemp - shadowWidthTemp : toTemp; - } - window.BeginAnimation(property, null); - }; + if ((int)hideType <= 3) + { + animalTime = showTime; + } else + { + animalTime = hideTime; + } - Timeline.SetDesiredFrameRate(da, 60); - window.BeginAnimation(property, da); + int count = 0; + while (count < animalTime) + { + switch (hideType) + { + case HideType.LEFT_HIDE: + window.Left -= subLen; + break; + case HideType.LEFT_SHOW: + window.Left += subLen; + break; + case HideType.RIGHT_HIDE: + window.Left += subLen; + break; + case HideType.RIGHT_SHOW: + window.Left -= subLen; + break; + case HideType.TOP_HIDE: + window.Top -= subLen; + break; + case HideType.TOP_SHOW: + window.Top += subLen; + break; + } + count++; + Thread.Sleep(1); + } + + switch (hideType) + { + case HideType.LEFT_HIDE: + window.Left = to; + break; + case HideType.LEFT_SHOW: + window.Left = to - 20; + break; + case HideType.RIGHT_HIDE: + window.Left = to; + break; + case HideType.RIGHT_SHOW: + window.Left = to + 20; + break; + case HideType.TOP_HIDE: + window.Top = to; + break; + case HideType.TOP_SHOW: + window.Top = to - 20; + break; + } + + //double toTemp = to; + //double leftT = 0; + //double topT = 0; + //switch (hideType) + //{ + // case HideType.LEFT_HIDE: + // to += leftT; + // break; + // case HideType.LEFT_SHOW: + // to -= leftT; + // break; + // case HideType.RIGHT_HIDE: + // to -= leftT; + // break; + // case HideType.RIGHT_SHOW: + // to += leftT; + // break; + // case HideType.TOP_HIDE: + // to += topT; + // break; + // case HideType.TOP_SHOW: + // to -= topT; + // break; + //} + //DoubleAnimation da = new DoubleAnimation + //{ + // From = from, + // To = to, + // Duration = new Duration(TimeSpan.FromMilliseconds(hideTime)) + //}; + //// 如果是显示 则贴屏幕侧不显示阴影 + //bool isShow = false; + //int shadowWidthTemp = Constants.SHADOW_WIDTH; + //if (hideType <= HideType.RIGHT_SHOW) + //{ + // isShow = true; + // if (hideType == HideType.RIGHT_SHOW) + // { + // shadowWidthTemp = -shadowWidthTemp; + // } + //} + //da.Completed += (s, e) => + //{ + // if ("Top".Equals(property.Name)) + // { + // window.Top = isShow ? toTemp - shadowWidthTemp : toTemp; + // } + // else + // { + // window.Left = isShow ? toTemp - shadowWidthTemp : toTemp; + // } + // window.BeginAnimation(property, null); + //}; + + //Timeline.SetDesiredFrameRate(da, 60); + //window.BeginAnimation(property, da); + }); + }).Start(); + + } private static void FadeAnimation(double from, double to) { - double time; - if (to == 0D) + new Thread(() => { - time = fadeHideTime; - } - else - { - time = fadeShowTime; - } - DoubleAnimation opacityAnimation = new DoubleAnimation - { - From = from, - To = to, - Duration = new Duration(TimeSpan.FromMilliseconds(time)) - }; - opacityAnimation.Completed += (s, e) => - { - //window.Opacity = to; - window.BeginAnimation(Window.OpacityProperty, null); - }; - Timeline.SetDesiredFrameRate(opacityAnimation, 60); - window.BeginAnimation(Window.OpacityProperty, opacityAnimation); + App.Current.Dispatcher.Invoke(() => + { + double time; + if (to == 0D) + { + time = fadeHideTime; + } + else + { + time = fadeShowTime; + } + DoubleAnimation opacityAnimation = new DoubleAnimation + { + From = from, + To = to, + Duration = new Duration(TimeSpan.FromMilliseconds(time)) + }; + opacityAnimation.Completed += (s, e) => + { + //window.Opacity = to; + window.BeginAnimation(Window.OpacityProperty, null); + }; + Timeline.SetDesiredFrameRate(opacityAnimation, 60); + window.BeginAnimation(Window.OpacityProperty, opacityAnimation); + }); + }).Start(); } From ddabf0a11358409e8639bd2394713f5db5d51639 Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 23 May 2022 17:52:35 +0800 Subject: [PATCH 13/22] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8B=BE=E8=89=B2?= =?UTF-8?q?=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; } } } From 1a1350ee5323660c016537942aae164ecda30868 Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 23 May 2022 17:53:08 +0800 Subject: [PATCH 14/22] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=8A=A8=E7=94=BB=E9=80=9F=E5=BA=A6,=20fail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PannelCard/RightCardControl.xaml.cs | 66 +++++++++++++++++-- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml.cs b/Control/UserControls/PannelCard/RightCardControl.xaml.cs index 1017ac9..ebc1473 100644 --- a/Control/UserControls/PannelCard/RightCardControl.xaml.cs +++ b/Control/UserControls/PannelCard/RightCardControl.xaml.cs @@ -14,6 +14,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media.Animation; +using System.Windows.Threading; namespace GeekDesk.Control.UserControls.PannelCard { @@ -437,10 +438,10 @@ namespace GeekDesk.Control.UserControls.PannelCard Thread t = new Thread(() => { - this.Dispatcher.BeginInvoke(new Action(() => - { - ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260); - })); + this.Dispatcher.BeginInvoke(new Action(() => + { + ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260); + })); }); t.IsBackground = true; t.Start(); @@ -453,6 +454,59 @@ namespace GeekDesk.Control.UserControls.PannelCard if (appData.AppConfig.PMModel) return; + //int count = 0; + //Panel sp = sender as Panel; + //Image img = sp.Children[0] as Image; + + + //int nowH = (int)img.Height; + + //bool isSmall = nowH > height; + + //if (!isSmall) + //{ + // img.Height = height; + // img.Width = width; + // return; + //} + //double subLen = (double)Math.Abs(nowH - height) / (double)milliseconds; + + //new Thread(() => + //{ + // this.Dispatcher.Invoke(() => + // { + // while (count < milliseconds) + // { + // if (!isSmall) + // { + // img.Height += subLen; + // img.Width += subLen; + // } else + // { + // //if (img.Height > 1) + // //{ + // // img.Height -= 1; + // // img.Width -= 1; + // //} + // Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, + // new Action(delegate { + // img.Height -= subLen; + // img.Width -= subLen; + // })); + // //img.Height -= subLen; + // //img.Width -= subLen; + // } + // count++; + // Thread.Sleep(1); + // } + // img.Height = height; + // img.Width = width; + // }); + //}).Start(); + + + + Panel sp = sender as Panel; DependencyObject dos = sp.Parent; @@ -519,10 +573,10 @@ namespace GeekDesk.Control.UserControls.PannelCard }; img.BeginAnimation(WidthProperty, widthAnimation); img.BeginAnimation(HeightProperty, heightAnimation); - + //################################################################### //myStoryboard.Completed += (s, e) => //{ - // if (checkRmStoryboard || true) + // if (checkRmStoryboard) // { // ThreadStart ts = new ThreadStart(crs.Remove); // System.Threading.Thread t = new System.Threading.Thread(ts); From a7a2ee9f08ac4e09943d37859c7469d5b88a3780 Mon Sep 17 00:00:00 2001 From: liufei Date: Mon, 23 May 2022 17:56:39 +0800 Subject: [PATCH 15/22] =?UTF-8?q?fix=20#41=20=E4=BC=98=E5=8C=96=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.xaml.cs | 15 +++ Control/UserControls/ToDo/TodoControl.xaml | 98 +++++++++++++++++-- Control/UserControls/ToDo/TodoControl.xaml.cs | 12 ++- Control/Windows/ToDoWindow.xaml | 12 ++- Control/Windows/ToDoWindow.xaml.cs | 50 ++++++++++ Converts/Count2VisibleConvert.cs | 43 ++++++++ Converts/CountGreZero2BoolConvert.cs | 28 ++++++ GeekDesk.csproj | 2 + 8 files changed, 248 insertions(+), 12 deletions(-) create mode 100644 Converts/Count2VisibleConvert.cs create mode 100644 Converts/CountGreZero2BoolConvert.cs diff --git a/App.xaml.cs b/App.xaml.cs index 7dc3a17..72790e9 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -2,6 +2,8 @@ using GeekDesk.Util; using System; using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; namespace GeekDesk { @@ -38,6 +40,7 @@ namespace GeekDesk void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。 + Mouse.OverrideCursor = null; LogUtil.WriteErrorLog(e, "未捕获异常!"); if (Constants.DEV) { @@ -50,6 +53,18 @@ namespace GeekDesk LogUtil.WriteErrorLog(e, "严重异常!"); MessageBox.Show("GeekDesk遇到未知问题崩溃!"); } + public static void DoEvents() + { + var frame = new DispatcherFrame(); + Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, + new DispatcherOperationCallback( + delegate (object f) + { + ((DispatcherFrame)f).Continue = false; + return null; + }), frame); + Dispatcher.PushFrame(frame); + } } diff --git a/Control/UserControls/ToDo/TodoControl.xaml b/Control/UserControls/ToDo/TodoControl.xaml index d400a76..657799d 100644 --- a/Control/UserControls/ToDo/TodoControl.xaml +++ b/Control/UserControls/ToDo/TodoControl.xaml @@ -6,25 +6,58 @@ xmlns:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard" xmlns:hc="https://handyorg.github.io/handycontrol" xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:ToDoInfo}" mc:Ignorable="d" + xmlns:cst="clr-namespace:GeekDesk.Converts" Background="Transparent" > + + + + + + + HeadersVisibility="All" + AutoGenerateColumns="False" + ItemsSource="{Binding}" + IsReadOnly="True" + Initialized="DataGridMenu_Initialized" + > - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - -