From 8d44429bdaa13723f4eaad9e8227e8d6dbb1c797 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 15:43:02 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=B4=E4=BC=98=E9=9B=85=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=B3=A8=E5=86=8C=E7=83=AD=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Util/GlobalHotKey.cs | 71 +++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/Util/GlobalHotKey.cs b/Util/GlobalHotKey.cs index b626522..a6a4164 100644 --- a/Util/GlobalHotKey.cs +++ b/Util/GlobalHotKey.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using System.Windows; +using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; @@ -18,9 +19,7 @@ namespace GeekDesk.Util } private static int currentID; - const int WM_HOTKEY = 0x312; - private static Dictionary handleTemp = new Dictionary(); - public static Dictionary callbackTemp = new Dictionary(); + private static readonly Dictionary handleTemp = new Dictionary(); public delegate void HotKeyCallBackHanlder(); /// @@ -38,50 +37,22 @@ namespace GeekDesk.Util public static int RegisterHotKey(HotkeyModifiers aModifier, Key key, HotKeyCallBackHanlder callback) { - Window window = new Window - { - WindowStyle = WindowStyle.None, - Height = 0, - Width = 0, - Visibility = Visibility.Collapsed, - ShowInTaskbar = false - }; - window.Show(); - IntPtr handle = new WindowInteropHelper(window).Handle; - HwndSource hs = HwndSource.FromHwnd(handle); - hs.AddHook(WndProc); + InvisibleWindowForMessages window = new InvisibleWindowForMessages(callback); currentID += 1; - if (!RegisterHotKey(handle, currentID, aModifier, (uint)KeyInterop.VirtualKeyFromKey(key))) + if (!RegisterHotKey(window.Handle, currentID, aModifier, (uint)KeyInterop.VirtualKeyFromKey(key))) { - window.Close(); + window.Dispose(); throw new Exception("RegisterHotKey Failed"); } handleTemp.Add(currentID, window); - callbackTemp.Add(currentID, callback); return currentID; } - /// - /// 快捷键消息处理 - /// - static IntPtr WndProc(IntPtr windowHandle, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) - { - if (msg == WM_HOTKEY) - { - int id = wParam.ToInt32(); - if (callbackTemp.TryGetValue(id, out var callback)) - { - callback(); - } - } - return IntPtr.Zero; - } public static void Dispose(int id) { - bool test = UnregisterHotKey(new WindowInteropHelper(handleTemp[id]).Handle, id); - GlobalHotKey.handleTemp[id].Close(); + bool test = UnregisterHotKey(handleTemp[id].Handle, id); + GlobalHotKey.handleTemp[id].Dispose(); GlobalHotKey.handleTemp.Remove(id); - GlobalHotKey.callbackTemp.Remove(id); Console.WriteLine(test); } @@ -91,5 +62,31 @@ namespace GeekDesk.Util // Unregisters the hot key with Windows. [DllImport("user32.dll")] private static extern bool UnregisterHotKey(IntPtr hWnd, int id); + + private class InvisibleWindowForMessages : NativeWindow, IDisposable + { + public event HotKeyCallBackHanlder callback; + public InvisibleWindowForMessages(HotKeyCallBackHanlder callback) + { + CreateHandle(new CreateParams()); + this.callback += callback; + } + + private static readonly int WM_HOTKEY = 0x0312; + protected override void WndProc(ref Message m) + { + base.WndProc(ref m); + if (m.Msg == WM_HOTKEY) + { + callback(); + } + } + public void Dispose() + { + this.DestroyHandle(); + } + } + + + } } -} From 4a94aab3c7b3d8df227bc15183364cafbc00a1c6 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 15:43:25 +0800 Subject: [PATCH 2/8] =?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 --- Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index d20c83d..95cd4cb 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ using System.Windows; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.2")] -[assembly: AssemblyFileVersion("2.2")] +[assembly: AssemblyVersion("2.3")] +[assembly: AssemblyFileVersion("2.3")] From d46eae4c6ea0c6e2bf986dfec8c2c902a504bef7 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 15:43:47 +0800 Subject: [PATCH 3/8] =?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 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App.config b/App.config index a42ba7c..c1c065b 100644 --- a/App.config +++ b/App.config @@ -24,7 +24,7 @@ - + From fd406fea4dec7eaaab68d8cec72b58b8caf51c7b Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 15:44:07 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=86=E5=8F=B2=E5=BE=85=E5=8A=9Ebug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Control/UserControls/ToDo/TodoControl.xaml.cs | 17 +++++++++++++++-- Control/Windows/ToDoWindow.xaml.cs | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Control/UserControls/ToDo/TodoControl.xaml.cs b/Control/UserControls/ToDo/TodoControl.xaml.cs index 25442d3..971ab83 100644 --- a/Control/UserControls/ToDo/TodoControl.xaml.cs +++ b/Control/UserControls/ToDo/TodoControl.xaml.cs @@ -19,12 +19,18 @@ using System.Windows.Shapes; namespace GeekDesk.Control.UserControls.Backlog { + + public enum ToDoType + { + HISTORY = 1, + NEW = 2 + } /// /// BacklogControl.xaml 的交互逻辑 /// public partial class TodoControl : UserControl { - private AppData appData = MainWindow.appData; + public ToDoType type; public TodoControl() { InitializeComponent(); @@ -37,7 +43,14 @@ namespace GeekDesk.Control.UserControls.Backlog { if (isConfirmed) { - appData.ToDoList.Remove(info); + if (type == ToDoType.NEW) + { + MainWindow.appData.ToDoList.Remove(info); + } + else + { + MainWindow.appData.HiToDoList.Remove(info); + } CommonCode.SaveAppData(MainWindow.appData); } return true; diff --git a/Control/Windows/ToDoWindow.xaml.cs b/Control/Windows/ToDoWindow.xaml.cs index c68072d..4f1ded7 100644 --- a/Control/Windows/ToDoWindow.xaml.cs +++ b/Control/Windows/ToDoWindow.xaml.cs @@ -64,9 +64,11 @@ namespace GeekDesk.Control.Windows { case "History": backlog.BacklogList.ItemsSource = appData.HiToDoList; + backlog.type = ToDoType.HISTORY; break; default: backlog.BacklogList.ItemsSource = appData.ToDoList; + backlog.type = ToDoType.NEW; break; } } From 7e3babe0c3b573fb9708212f61e1e862c5828e85 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 15:53:58 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=AE=BE=E7=BD=AE=E5=90=8E=20=E8=B4=B4?= =?UTF-8?q?=E8=BE=B9=E9=9A=90=E8=97=8F=E5=8D=A1=E9=A1=BF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Util/MarginHide.cs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Util/MarginHide.cs b/Util/MarginHide.cs index dccf12f..cd7979d 100644 --- a/Util/MarginHide.cs +++ b/Util/MarginHide.cs @@ -25,10 +25,12 @@ namespace GeekDesk.Util { readonly Window window;//定义使用该方法的窗体 - private readonly int hideTime = 150; + private readonly int hideTime = 80; private readonly int taskTime = 200; + private double showMarginWidth = 1; + private bool isHide; public Timer timer; @@ -89,39 +91,39 @@ namespace GeekDesk.Util //上方隐藏条件 if (windowTop <= screenTop) { - HideAnimation(windowTop, screenTop - windowHeight + 1, Window.TopProperty); + HideAnimation(windowTop, screenTop - windowHeight + showMarginWidth, Window.TopProperty); isHide = true; return; } //左侧隐藏条件 if (windowLeft <= screenLeft) { - HideAnimation(windowLeft, screenLeft - windowWidth + 1, Window.LeftProperty); + HideAnimation(windowLeft, screenLeft - windowWidth + showMarginWidth, Window.LeftProperty); return; } //右侧隐藏条件 if (windowLeft + windowWidth + Math.Abs(screenLeft) >= screenWidth) { - HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - 1, Window.LeftProperty); + HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - showMarginWidth, Window.LeftProperty); return; } } else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth && mouseY >= windowTop && mouseY <= windowTop + windowHeight) { //上方显示 - if (windowTop <= screenTop - 1) + if (windowTop <= screenTop - showMarginWidth) { HideAnimation(windowTop, screenTop, Window.TopProperty); return; } //左侧显示 - if (windowLeft <= screenLeft -1) + if (windowLeft <= screenLeft - showMarginWidth) { HideAnimation(windowLeft, screenLeft, Window.LeftProperty); return; } //右侧显示 - if (windowLeft + Math.Abs(screenLeft) == screenWidth -1) + if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth) { HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty); return; @@ -134,6 +136,7 @@ namespace GeekDesk.Util public void TimerSet() { + if (timer != null) return; timer = new Timer();//添加timer计时器,隐藏功能 #region 计时器设置,隐藏功能 timer.Interval = taskTime; @@ -145,6 +148,8 @@ namespace GeekDesk.Util public void TimerStop() { timer.Stop(); + timer.Dispose(); + timer = null; //功能关闭 如果界面是隐藏状态 那么要显示界面 ↓ double screenLeft = SystemParameters.VirtualScreenLeft; @@ -157,21 +162,21 @@ namespace GeekDesk.Util double windowLeft = window.Left; //左侧显示 - if (windowLeft <= screenLeft - 1) + if (windowLeft <= screenLeft - showMarginWidth) { HideAnimation(windowLeft, screenLeft, Window.LeftProperty); return; } //上方显示 - if (windowTop <= screenTop - 1) + if (windowTop <= screenTop - showMarginWidth) { HideAnimation(windowTop, screenTop, Window.TopProperty); return; } //右侧显示 - if (windowLeft + Math.Abs(screenLeft) == screenWidth - 1) + if (windowLeft + Math.Abs(screenLeft) == screenWidth - showMarginWidth) { HideAnimation(windowLeft, screenWidth - Math.Abs(screenLeft) - windowWidth, Window.LeftProperty); return; @@ -191,7 +196,7 @@ namespace GeekDesk.Util { window.BeginAnimation(property, null); }; - Timeline.SetDesiredFrameRate(da, 30); + Timeline.SetDesiredFrameRate(da, 60); window.BeginAnimation(property, da); } } From 787c23ef7759e1f81626239715e200e0e3e4c934 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 16:49:20 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=86=85=E5=AD=98=E5=9B=9E=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Task/ToDoTask.cs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/Task/ToDoTask.cs b/Task/ToDoTask.cs index 7aa2b46..0710b5a 100644 --- a/Task/ToDoTask.cs +++ b/Task/ToDoTask.cs @@ -7,6 +7,7 @@ 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; @@ -24,9 +25,11 @@ namespace GeekDesk.Task public static void BackLogCheck() { - System.Timers.Timer timer = new System.Timers.Timer(); - timer.Enabled = true; - timer.Interval = 5000; + System.Timers.Timer timer = new System.Timers.Timer + { + Enabled = true, + Interval = 5000 + }; timer.Start(); timer.Elapsed += new System.Timers.ElapsedEventHandler(Check); } @@ -48,9 +51,27 @@ namespace GeekDesk.Task } } } + ClearMemory(); })); } + /// + /// 释放内存 + /// + public static void ClearMemory() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1); + } + } + + #region 内存回收 + [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")] + public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize); + #endregion } From c2315875431c2c7a614fcea41ab419a7de645b73 Mon Sep 17 00:00:00 2001 From: liufei Date: Fri, 20 Aug 2021 16:50:24 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Control/UserControls/Config/AboutControl.xaml.cs | 1 + Control/UserControls/Config/MotionControl.xaml.cs | 6 +++--- Control/Windows/ConfigWindow.xaml.cs | 8 ++++---- Update.json | 4 ++-- Update.json.bak | 9 +++++++++ Util/ImageUtil.cs | 7 +++++-- 6 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 Update.json.bak diff --git a/Control/UserControls/Config/AboutControl.xaml.cs b/Control/UserControls/Config/AboutControl.xaml.cs index 9495b9a..5a1558a 100644 --- a/Control/UserControls/Config/AboutControl.xaml.cs +++ b/Control/UserControls/Config/AboutControl.xaml.cs @@ -32,6 +32,7 @@ namespace GeekDesk.Control.UserControls.Config ZFBCode.Source = ImageUtil.Base64ToBitmapImage(Constants.ZFB_CODE_IMG_BASE64); } + /// /// 移动窗口 /// diff --git a/Control/UserControls/Config/MotionControl.xaml.cs b/Control/UserControls/Config/MotionControl.xaml.cs index 79785c8..89e5caa 100644 --- a/Control/UserControls/Config/MotionControl.xaml.cs +++ b/Control/UserControls/Config/MotionControl.xaml.cs @@ -30,9 +30,9 @@ namespace GeekDesk.Control.UserControls.Config public partial class MotionControl : UserControl { public static bool hotkeyFinished = true; //热键设置结束 - private static KeyEventArgs prevKeyTemp; //上一个按键 - private static List keysTemp = new List();//存储一次快捷键集合 - private static AppConfig appConfig = MainWindow.appData.AppConfig; + private KeyEventArgs prevKeyTemp; //上一个按键 + private readonly List keysTemp = new List();//存储一次快捷键集合 + private readonly AppConfig appConfig = MainWindow.appData.AppConfig; public MotionControl() { diff --git a/Control/Windows/ConfigWindow.xaml.cs b/Control/Windows/ConfigWindow.xaml.cs index ca0d638..020c5bf 100644 --- a/Control/Windows/ConfigWindow.xaml.cs +++ b/Control/Windows/ConfigWindow.xaml.cs @@ -15,10 +15,10 @@ namespace GeekDesk.Control.Windows /// public partial class ConfigWindow { - private static AboutControl about = new AboutControl(); - private static ThemeControl theme = new ThemeControl(); - private static MotionControl motion = new MotionControl(); - private static OtherControl other = new OtherControl(); + private static readonly AboutControl about = new AboutControl(); + private static readonly ThemeControl theme = new ThemeControl(); + private static readonly MotionControl motion = new MotionControl(); + private static readonly OtherControl other = new OtherControl(); public MainWindow mainWindow; private ConfigWindow(AppConfig appConfig, MainWindow mainWindow) diff --git a/Update.json b/Update.json index 62d6955..9a7a1db 100644 --- a/Update.json +++ b/Update.json @@ -1,9 +1,9 @@ { "title" : "汾", - "subTitle" : "V2.2 ʽ", + "subTitle" : "V2.3 ʽ", "msgTitle" : "θ", "msg" : "['Ե','ڵ뵭','ݼ(ĬCtrl+Shift+Q)','Ҽͼ򿪳Ŀ¼˵']", "githubUrl" : "https://github.com/Demo-Liu/GeekDesk/releases/tag", "giteeUrl" : "https://gitee.com/demo_liu/GeekDesk/releases", - "version": "2.2" + "version": "2.3" } \ No newline at end of file diff --git a/Update.json.bak b/Update.json.bak new file mode 100644 index 0000000..e918fb7 --- /dev/null +++ b/Update.json.bak @@ -0,0 +1,9 @@ +{ + "title" : "版本更新", + "subTitle" : "V2.3 正式版", + "msgTitle" : "本次更新内容如下", + "msg" : "['边缘吸附功能','窗口淡入淡出动画','待办任务快捷键(默认Ctrl+Shift+Q)','右键任务栏图标打开程序目录菜单']", + "githubUrl" : "https://github.com/Demo-Liu/GeekDesk/releases/tag", + "giteeUrl" : "https://gitee.com/demo_liu/GeekDesk/releases", + "version": "2.3" +} \ No newline at end of file diff --git a/Util/ImageUtil.cs b/Util/ImageUtil.cs index 33bcfca..803358c 100644 --- a/Util/ImageUtil.cs +++ b/Util/ImageUtil.cs @@ -6,6 +6,7 @@ using System.Drawing.Imaging; using System.IO; using System.Windows; using System.Windows.Interop; +using System.Windows.Media; using System.Windows.Media.Imaging; namespace GeekDesk.Util @@ -22,9 +23,10 @@ namespace GeekDesk.Util { using (var ms = new System.IO.MemoryStream(array)) { - var image = new BitmapImage(); + BitmapImage image = new BitmapImage(); image.BeginInit(); image.CacheOption = BitmapCacheOption.OnLoad; // here + RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.LowQuality); image.StreamSource = ms; image.EndInit(); return image; @@ -184,7 +186,7 @@ namespace GeekDesk.Util Bitmap bmpOut = new Bitmap(lnNewWidth, lnNewHeight); Graphics g = Graphics.FromImage(bmpOut); g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; - g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight); + g.FillRectangle(System.Drawing.Brushes.White, 0, 0, lnNewWidth, lnNewHeight); g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight); loBMP.Dispose(); string tempPath = Constants.APP_DIR + "\\temp"; @@ -211,6 +213,7 @@ namespace GeekDesk.Util BitmapImage bmImg = new BitmapImage(); bmImg.BeginInit(); bmImg.CacheOption = BitmapCacheOption.OnLoad; + RenderOptions.SetBitmapScalingMode(bmImg, BitmapScalingMode.LowQuality); using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { bmImg.StreamSource = fs; From 274541303a87f65aff5f149cf849bf8242cff86b Mon Sep 17 00:00:00 2001 From: liufei Date: Sat, 11 Sep 2021 15:32:30 +0800 Subject: [PATCH 8/8] =?UTF-8?q?'=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=9B=BE=E6=A0=87=E5=A4=A7=E5=B0=8F','=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E4=BB=BB=E5=8A=A1=E5=8F=AF=E4=BD=BF=E7=94=A8CRON?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8F=90?= =?UTF-8?q?=E9=86=92=E9=A2=91=E7=8E=87'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 6 +- Constant/CommonEnum.cs | 2 +- Constant/TodoTaskExecType.cs | 14 ++ Control/Other/BacklogNotificatin.xaml.cs | 39 +++++- Control/UserControls/Config/ThemeControl.xaml | 59 +++++--- .../UserControls/Config/ThemeControl.xaml.cs | 36 +++++ .../PannelCard/RightCardControl.xaml | 29 ++-- .../PannelCard/RightCardControl.xaml.cs | 130 +++++++++++++++--- Control/Windows/ConfigWindow.xaml | 2 +- Control/Windows/ToDoInfoWindow.xaml | 53 +++++-- Control/Windows/ToDoInfoWindow.xaml.cs | 118 +++++++++++----- Converts/TodoTaskExecConvert.cs | 29 ++++ GeekDesk.csproj | 25 ++++ Properties/AssemblyInfo.cs | 4 +- Update.json | 6 +- ViewModel/AppConfig.cs | 82 ++++++++++- ViewModel/IconInfo.cs | 30 +--- ViewModel/ToDoInfo.cs | 33 ++++- packages.config | 7 + 19 files changed, 562 insertions(+), 142 deletions(-) create mode 100644 Constant/TodoTaskExecType.cs create mode 100644 Converts/TodoTaskExecConvert.cs diff --git a/App.config b/App.config index c1c065b..e4b9285 100644 --- a/App.config +++ b/App.config @@ -21,10 +21,14 @@ + + + + - + diff --git a/Constant/CommonEnum.cs b/Constant/CommonEnum.cs index 33310c9..c45c948 100644 --- a/Constant/CommonEnum.cs +++ b/Constant/CommonEnum.cs @@ -14,6 +14,6 @@ namespace GeekDesk.Constant IMAGE_HEIGHT_AM = 52, //动画变换高度 IMAGE_PANEL_WIDTH = 110, //图标容器宽度 IMAGE_PANEL_HEIGHT = 90, //图标容器高度 - WINDOW_ANIMATION_TIME = 200, //主窗口动画时间 + WINDOW_ANIMATION_TIME = 200, //主窗口动画时间, } } diff --git a/Constant/TodoTaskExecType.cs b/Constant/TodoTaskExecType.cs new file mode 100644 index 0000000..d634ce7 --- /dev/null +++ b/Constant/TodoTaskExecType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace GeekDesk.Constant +{ + public enum TodoTaskExecType + { + SET_TIME = 1, //指定时间 + CRON = 2 //cron表达式 + } +} diff --git a/Control/Other/BacklogNotificatin.xaml.cs b/Control/Other/BacklogNotificatin.xaml.cs index cfe0aed..b00460d 100644 --- a/Control/Other/BacklogNotificatin.xaml.cs +++ b/Control/Other/BacklogNotificatin.xaml.cs @@ -1,6 +1,9 @@ -using GeekDesk.Task; +using GeekDesk.Constant; +using GeekDesk.Task; using GeekDesk.Util; using GeekDesk.ViewModel; +using HandyControl.Controls; +using Quartz; using System; using System.Collections.Generic; using System.Linq; @@ -34,8 +37,36 @@ namespace GeekDesk.Control.Other { ToDoInfo info = this.DataContext as ToDoInfo; info.DoneTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - appData.ToDoList.Remove(info); //执行任务删除 - appData.HiToDoList.Add(info); //添加历史任务 + if (info.ExecType == TodoTaskExecType.CRON) + { + CronExpression exp = new CronExpression(info.Cron); + DateTime dtNow = DateTime.Now; + DateTimeOffset ddo = DateTime.SpecifyKind(dtNow, DateTimeKind.Local); + string nextExecTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss"); + info.ExeTime = nextExecTime; + + DateTime nextTime = ddo.LocalDateTime; + TimeSpan ts = nextTime.Subtract(dtNow); + int minutes = (int)Math.Ceiling(ts.TotalMinutes); + if (minutes < 0) + { + minutes = 0; + } + if (minutes > 60) + { + int m = minutes % 60; + int h = minutes / 60; + Growl.SuccessGlobal("下次任务将在 " + h + " 小时零 " + m + " 分钟后提醒您!"); + } + else + { + Growl.SuccessGlobal("下次任务将在 " + minutes + " 分钟后提醒您!"); + } + } else + { + appData.ToDoList.Remove(info); //执行任务删除 + appData.HiToDoList.Add(info); //添加历史任务 + } ToDoTask.activityBacklog[info].Close(); //关闭桌面通知 ToDoTask.activityBacklog.Remove(info);//激活任务删除 CommonCode.SaveAppData(appData); @@ -93,9 +124,11 @@ namespace GeekDesk.Control.Other { case "分": info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss"); + Growl.SuccessGlobal("将在 " + time + " 分钟后再次提醒您!"); break; case "时": info.ExeTime = DateTime.Now.AddHours(time).ToString("yyyy-MM-dd HH:mm:ss"); + Growl.SuccessGlobal("将在 " + time + " 小时后再次提醒您!"); break; } ToDoTask.activityBacklog[info].Close(); //关闭桌面通知 diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml index 2ca2e15..8bc53a2 100644 --- a/Control/UserControls/Config/ThemeControl.xaml +++ b/Control/UserControls/Config/ThemeControl.xaml @@ -12,11 +12,11 @@ - - + + - + - + @@ -38,16 +38,16 @@ - + - - + + - + - + - + - + - + - + - + + + + + + + + + + - - + +