From 274541303a87f65aff5f149cf849bf8242cff86b Mon Sep 17 00:00:00 2001 From: liufei Date: Sat, 11 Sep 2021 15:32:30 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=A4=A7=E5=B0=8F','=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=8F=AF=E4=BD=BF=E7=94=A8CRON=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E8=87=AA=E5=AE=9A=E4=B9=89=E6=8F=90=E9=86=92?= =?UTF-8?q?=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 @@ - + - - + + - + - + - + - + - + - + - + + + + + + + + + + - - + +