diff --git a/App.config b/App.config
index a42ba7c..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/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/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 @@
-
+
-
-
+
+
-
+
@@ -56,13 +56,13 @@
-
+
-
+
@@ -71,14 +71,14 @@
-
+
-
+
@@ -86,27 +86,44 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
diff --git a/Control/UserControls/Config/ThemeControl.xaml.cs b/Control/UserControls/Config/ThemeControl.xaml.cs
index 20ff430..3be49f3 100644
--- a/Control/UserControls/Config/ThemeControl.xaml.cs
+++ b/Control/UserControls/Config/ThemeControl.xaml.cs
@@ -3,6 +3,7 @@ using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -87,5 +88,40 @@ namespace GeekDesk.Control.UserControls.Config
Window.GetWindow(this).DragMove();
}
}
+
+ private void PreviewSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ CheckButtonUpClass cbu = new CheckButtonUpClass
+ {
+ e = e
+ };
+ System.Threading.ThreadStart ts = new System.Threading.ThreadStart(cbu.CheckButtonUp);
+ System.Threading.Thread t = new System.Threading.Thread(ts);
+ t.Start();
+ }
+
+ private class CheckButtonUpClass
+ {
+ public MouseButtonEventArgs e;
+
+ public void CheckButtonUp()
+ {
+ while (true)
+ {
+ if (e.LeftButton == MouseButtonState.Released)
+ {
+ App.Current.Dispatcher.Invoke((Action)(() =>
+ {
+ AppData appData = MainWindow.appData;
+ ObservableCollection selectIcons = appData.AppConfig.SelectedMenuIcons;
+ appData.AppConfig.SelectedMenuIcons = null;
+ appData.AppConfig.SelectedMenuIcons = selectIcons;
+ }));
+ return;
+ }
+ System.Threading.Thread.Sleep(50);
+ }
+ }
+ }
}
}
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml b/Control/UserControls/PannelCard/RightCardControl.xaml
index ee78712..590679e 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml
@@ -12,12 +12,9 @@
+
-
-
+
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml.cs b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
index f02fa77..da8fb00 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
@@ -3,6 +3,7 @@ using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Util;
using GeekDesk.ViewModel;
+using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -11,6 +12,7 @@ using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -263,46 +265,142 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
{
- ImgStoryBoard(sender, (int)CommonEnum.IMAGE_HEIGHT_AM, (int)CommonEnum.IMAGE_WIDTH_AM, 1);
+
+ double width = appData.AppConfig.ImageWidth;
+ double height = appData.AppConfig.ImageHeight;
+ width += width * 0.15;
+ height += height * 0.15;
+ ImgStoryBoard(sender, (int)width, (int)height, 1, true);
}
private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
{
- ImgStoryBoard(sender, (int)CommonEnum.IMAGE_HEIGHT, (int)CommonEnum.IMAGE_WIDTH, 220);
+ ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 220);
}
- private void ImgStoryBoard(object sender, int height, int width, int milliseconds)
+ private void ImgStoryBoard(object sender, int height, int width, int milliseconds, bool checkRmStoryboard = false)
{
if (appData.AppConfig.PMModel) return;
- StackPanel sp = sender as StackPanel;
+ Panel sp = sender as Panel;
+
+ DependencyObject dos = sp.Parent;
Image img = sp.Children[0] as Image;
+ double afterHeight = img.Height;
+ double afterWidth = img.Width;
- DoubleAnimation heightAnimation = new DoubleAnimation();
- DoubleAnimation widthAnimation = new DoubleAnimation();
+ //动画定义
+ Storyboard myStoryboard = new Storyboard();
+
- heightAnimation.From = img.Height;
- widthAnimation.From = img.Width;
- heightAnimation.To = height;
- widthAnimation.To = width;
-
- heightAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds));
- widthAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds));
+ DoubleAnimation heightAnimation = new DoubleAnimation
+ {
+ From = afterHeight,
+ To = height,
+ Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
+ };
+ DoubleAnimation widthAnimation = new DoubleAnimation
+ {
+ From = afterWidth,
+ To = width,
+ Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
+ };
Timeline.SetDesiredFrameRate(heightAnimation, 60);
Timeline.SetDesiredFrameRate(widthAnimation, 60);
- img.BeginAnimation(HeightProperty, null);
- img.BeginAnimation(WidthProperty, null);
+ Storyboard.SetTarget(widthAnimation, img);
+ Storyboard.SetTargetProperty(widthAnimation, new PropertyPath("Width"));
+ Storyboard.SetTarget(heightAnimation, img);
+ Storyboard.SetTargetProperty(heightAnimation, new PropertyPath("Height"));
- img.BeginAnimation(HeightProperty, heightAnimation);
+ myStoryboard.Children.Add(heightAnimation);
+ myStoryboard.Children.Add(widthAnimation);
+
+ CheckRemoveStoryboard crs = new CheckRemoveStoryboard
+ {
+ sb = myStoryboard,
+ sp = sp,
+ heightAnimation = heightAnimation,
+ widthAnimation = widthAnimation,
+ img = img,
+ isMouseOver = !checkRmStoryboard
+ };
+
+ heightAnimation.Completed += (s, e) =>
+ {
+ if (checkRmStoryboard)
+ {
+ ThreadStart ts = new ThreadStart(crs.Remove);
+ System.Threading.Thread t = new System.Threading.Thread(ts);
+ t.Start();
+ } else
+ {
+ img.BeginAnimation(WidthProperty, null);
+ img.BeginAnimation(HeightProperty, null);
+ }
+ };
img.BeginAnimation(WidthProperty, widthAnimation);
+ img.BeginAnimation(HeightProperty, heightAnimation);
+
+ //myStoryboard.Completed += (s, e) =>
+ //{
+ // if (checkRmStoryboard || true)
+ // {
+ // ThreadStart ts = new ThreadStart(crs.Remove);
+ // System.Threading.Thread t = new System.Threading.Thread(ts);
+ // t.Start();
+ // }
+ // else
+ // {
+ // myStoryboard.Remove();
+ // }
+ //};
+ //myStoryboard.Begin();
+ }
+
+ private class CheckRemoveStoryboard
+ {
+ public Storyboard sb;
+ public Panel sp;
+ public Image img;
+ public DoubleAnimation heightAnimation;
+ public DoubleAnimation widthAnimation;
+ public bool isMouseOver;
+ public void Remove()
+ {
+ while (true)
+ {
+ if (sp.IsMouseOver == isMouseOver)
+ {
+ App.Current.Dispatcher.Invoke((Action)(() =>
+ {
+ img.BeginAnimation(WidthProperty, null);
+ img.BeginAnimation(HeightProperty, null);
+ //heightAnimation.FillBehavior = FillBehavior.Stop;
+ //widthAnimation.FillBehavior = FillBehavior.Stop;
+ }));
+ return;
+ }
+ else
+ {
+ System.Threading.Thread.Sleep(500);
+ }
+ }
+ }
+ }
+
+ public void RemoveSB(Object sb)
+ {
+ Storyboard sb2 = sb as Storyboard;
+ System.Threading.Thread.Sleep(500);
+ sb2.Remove();
}
private void AddUrlIcon(object sender, RoutedEventArgs e)
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/ConfigWindow.xaml b/Control/Windows/ConfigWindow.xaml
index d158b8f..8aab8ad 100644
--- a/Control/Windows/ConfigWindow.xaml
+++ b/Control/Windows/ConfigWindow.xaml
@@ -121,7 +121,7 @@
-
+
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/Control/Windows/ToDoInfoWindow.xaml b/Control/Windows/ToDoInfoWindow.xaml
index 2e0f734..2d278bc 100644
--- a/Control/Windows/ToDoInfoWindow.xaml
+++ b/Control/Windows/ToDoInfoWindow.xaml
@@ -4,10 +4,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:hc="https://handyorg.github.io/handycontrol"
+ xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:local="clr-namespace:GeekDesk"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
- Height="670"
+ Height="700"
Width="450"
Title="TaskInfo"
WindowStyle="None"
@@ -15,7 +16,7 @@
Background="Transparent" ShowInTaskbar="False"
>
-
+
@@ -23,48 +24,72 @@
-
+
-
+
-
+
-
+
-
-
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
diff --git a/Control/Windows/ToDoInfoWindow.xaml.cs b/Control/Windows/ToDoInfoWindow.xaml.cs
index c722043..b85be5b 100644
--- a/Control/Windows/ToDoInfoWindow.xaml.cs
+++ b/Control/Windows/ToDoInfoWindow.xaml.cs
@@ -1,6 +1,8 @@
-using GeekDesk.Util;
+using GeekDesk.Constant;
+using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
+using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -29,23 +31,28 @@ namespace GeekDesk.Control.Windows
private AppData appData = MainWindow.appData;
- private ToDoInfo info;
+ //private ToDoInfo info;
private ToDoInfoWindow()
{
InitializeComponent();
- ExeTime.SelectedDateTime = DateTime.Now.AddMinutes(10);
+
this.Topmost = true;
+ ExeTime.SelectedDateTime = DateTime.Now.AddMinutes(10);
+ SetTimePanel.Visibility = Visibility.Visible;
+ this.DataContext = new ToDoInfo();
}
private ToDoInfoWindow(ToDoInfo info)
{
InitializeComponent();
this.Topmost = true;
- Title.Text = info.Title;
- Msg.Text = info.Msg;
- ExeTime.Text = info.ExeTime;
- DoneTime.Text = info.DoneTime;
- this.info = info;
+ this.DataContext = info;
+ SetTimePanel.Visibility = Visibility.Visible;
+ //Title.Text = info.Title;
+ //Msg.Text = info.Msg;
+ //ExeTime.Text = info.ExeTime;
+ //DoneTime.Text = info.DoneTime;
+ //this.info = info;
}
@@ -79,41 +86,70 @@ namespace GeekDesk.Control.Windows
///
private void Save_Button_Click(object sender, RoutedEventArgs e)
{
-
DateTime dt;
- if (Title.Text.Trim() == "" || ExeTime.Text.Trim() == "")
+ string execTime;
+ TodoTaskExecType execType;
+ if (Title.Text.Trim() == "")
{
- Growl.Warning("任务标题 和 待办时间不能为空!");
+ Growl.Warning("任务标题不能为空!");
return;
} else
{
- try
+ if (SetTimePanel.Visibility == Visibility.Visible)
{
- dt = Convert.ToDateTime(ExeTime.Text);
- } catch (Exception)
- {
- Growl.Warning("请输入正确的时间!");
- return;
+ execType = TodoTaskExecType.SET_TIME;
+ if (ExeTime.Text.Trim() == "")
+ {
+ Growl.Warning("执行时间不能为空!");
+ return;
+ }
+ try
+ {
+ dt = Convert.ToDateTime(ExeTime.Text);
+ }
+ catch (Exception)
+ {
+ Growl.Warning("请输入正确的时间!");
+ return;
+ }
+ execTime = ExeTime.Text;
+ } else {
+ execType = TodoTaskExecType.CRON;
+ if (Cron.Text.Trim() == "")
+ {
+ Growl.Warning("Cron表达式不能为空!");
+ return;
+ }
+ try
+ {
+ bool isValid = CronExpression.IsValidExpression(Cron.Text);
+ if (!isValid) throw new Exception();
+ } catch (Exception)
+ {
+ Growl.Warning("请输入正确的Cron表达式!");
+ return;
+ }
+ CronExpression exp = new CronExpression(Cron.Text);
+ DateTime dd = DateTime.Now;
+ DateTimeOffset ddo = DateTime.SpecifyKind(dd, DateTimeKind.Local);
+ ddo = (DateTimeOffset)exp.GetNextValidTimeAfter(ddo);
+ execTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
}
}
- if (windowType == NEW_TODO)
+ dt = Convert.ToDateTime(execTime);
+ ToDoInfo info = new ToDoInfo
{
- info = new ToDoInfo
- {
- Title = Title.Text,
- Msg = Msg.Text,
- ExeTime = ExeTime.Text
- };
- appData.ToDoList.Add(info);
- } else
+ Title = Title.Text,
+ Msg = Msg.Text,
+ ExeTime = execTime,
+ ExecType = execType,
+ Cron = Cron.Text
+ };
+ if (windowType != NEW_TODO)
{
- appData.HiToDoList.Remove(info);
- info.Title = Title.Text;
- info.Msg = Msg.Text;
- info.ExeTime = ExeTime.Text;
- info.DoneTime = null;
- appData.ToDoList.Add(info);
- }
+ appData.HiToDoList.Remove(this.DataContext as ToDoInfo);
+ }
+ appData.ToDoList.Add(info);
DateTime dtNow = DateTime.Now;
TimeSpan ts = dt.Subtract(dtNow);
@@ -184,5 +220,21 @@ namespace GeekDesk.Control.Windows
windowType = DETAIL_TODO;
window2.Show();
}
+
+ private void ExecType_Checked(object sender, RoutedEventArgs e)
+ {
+ TodoTaskExecType tag = (TodoTaskExecType)Convert.ToInt32((sender as RadioButton).Tag.ToString());
+ switch (tag)
+ {
+ case TodoTaskExecType.SET_TIME:
+ SetTimePanel.Visibility = Visibility.Visible;
+ CronPanel.Visibility = Visibility.Collapsed;
+ break;
+ default:
+ CronPanel.Visibility = Visibility.Visible;
+ SetTimePanel.Visibility = Visibility.Collapsed;
+ break;
+ }
+ }
}
}
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;
}
}
diff --git a/Converts/TodoTaskExecConvert.cs b/Converts/TodoTaskExecConvert.cs
new file mode 100644
index 0000000..529dda2
--- /dev/null
+++ b/Converts/TodoTaskExecConvert.cs
@@ -0,0 +1,29 @@
+using GeekDesk.Constant;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace GeekDesk.Converts
+{
+ public class TodoTaskExecConvert : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (TodoTaskExecType)value == (TodoTaskExecType)int.Parse(parameter.ToString());
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isChecked = (bool)value;
+ if (!isChecked)
+ {
+ return null;
+ }
+ return (TodoTaskExecType)int.Parse(parameter.ToString());
+ }
+ }
+}
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index 88712c6..ae318be 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -60,16 +60,39 @@
packages\HandyControl.3.1.0\lib\net472\HandyControl.dll
+
+ packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll
+
packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
+
+ packages\Quartz.3.3.3\lib\net472\Quartz.dll
+
+
+ packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+ packages\System.Diagnostics.DiagnosticSource.4.7.1\lib\net46\System.Diagnostics.DiagnosticSource.dll
+
packages\System.Drawing.Common.6.0.0-preview.6.21352.12\lib\net461\System.Drawing.Common.dll
+
+ packages\System.Memory.4.5.4\lib\net461\System.Memory.dll
+
+
+
+ packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll
+
+
@@ -99,6 +122,7 @@
+
BacklogNotificatin.xaml
@@ -152,6 +176,7 @@
UpdateWindow.xaml
+
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index d20c83d..fd9b5ff 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.1.0")]
+[assembly: AssemblyFileVersion("2.3.1.0")]
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
}
diff --git a/Update.json b/Update.json
index 62d6955..42378ce 100644
--- a/Update.json
+++ b/Update.json
@@ -1,9 +1,9 @@
{
"title" : "汾",
- "subTitle" : "V2.2 ʽ",
+ "subTitle" : "V2.3.10 ʽ",
"msgTitle" : "θ",
- "msg" : "['Ե','ڵ뵭','ݼ(ĬCtrl+Shift+Q)','ҼͼĿ¼˵']",
+ "msg" : "['ʾú,ؿٵ','ɾʷBUG','Ӷʱڴ,ڿռøСڴ','ʱڵ㴰ڵBUG','ԶͼС','ʹCRONʽԶƵ']",
"githubUrl" : "https://github.com/Demo-Liu/GeekDesk/releases/tag",
"giteeUrl" : "https://gitee.com/demo_liu/GeekDesk/releases",
- "version": "2.2"
+ "version": "2.3.10"
}
\ 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/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();
+ }
+ }
+
+
+ }
}
-}
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;
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);
}
}
diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs
index 3656295..0c0cad1 100644
--- a/ViewModel/AppConfig.cs
+++ b/ViewModel/AppConfig.cs
@@ -61,13 +61,89 @@ namespace GeekDesk.ViewModel
private string textColor = "#000000"; //字体颜色
private double imgPanelWidth = (double)CommonEnum.IMAGE_PANEL_WIDTH;
private double imgPanelHeight = (double)CommonEnum.IMAGE_PANEL_HEIGHT;
-
private bool marginHide = false; //贴边隐藏
-
private bool appAnimation = false; //主窗口动画效果
-
+ private int imageWidth = (int)CommonEnum.IMAGE_WIDTH; //图片宽度
+ private int imageHeight = (int)CommonEnum.IMAGE_HEIGHT; //图片高度
#region GetSet
+ public int ImageWidth
+ {
+ get
+ {
+ // 为了兼容旧版 暂时使用默认
+ if (imageWidth == 0)
+ {
+ return (int)CommonEnum.IMAGE_WIDTH;
+ } else
+ {
+ return imageWidth;
+ }
+
+ }
+ set
+ {
+ imageWidth = value;
+ //同时设置高度
+ ImageHeight = value;
+
+
+ //计算 容器宽度因子
+ double i = ((double)imageWidth - (double)CommonEnum.IMAGE_WIDTH) / 5d;
+ double s = 2.44;
+ i *= 2d;
+ while (i > 1)
+ {
+ i /= 10d;
+ }
+
+ if (i > 0d)
+ {
+ s -= i;
+ }
+ //设置容器宽度
+ ImgPanelWidth = (int)(ImageWidth * s);
+
+ OnPropertyChanged("ImageWidth");
+ }
+ }
+
+ public int ImageHeight
+ {
+ get
+ {
+ //都使用宽度来确定大小
+ // 为了兼容旧版 暂时使用默认
+ if (imageHeight == 0)
+ {
+ return (int)CommonEnum.IMAGE_HEIGHT;
+ }
+ else
+ {
+ return imageHeight;
+ }
+ }
+ set
+ {
+ imageHeight = value;
+
+ //计算容器高度因子
+ double i = ((double)imageHeight - (double)CommonEnum.IMAGE_HEIGHT) / 5d;
+ while (i > 1)
+ {
+ i /= 10d;
+ }
+ double s = 2.00;
+ if (i > 0d)
+ {
+ s -= i;
+ }
+
+ //设置容器高度
+ ImgPanelHeight = ImageHeight * s;
+ OnPropertyChanged("ImageHeight");
+ }
+ }
public bool AppAnimation
{
diff --git a/ViewModel/IconInfo.cs b/ViewModel/IconInfo.cs
index 5dbb425..c5c1943 100644
--- a/ViewModel/IconInfo.cs
+++ b/ViewModel/IconInfo.cs
@@ -20,8 +20,6 @@ namespace GeekDesk.ViewModel
private BitmapImage bitmapImage; //位图
private byte[] imageByteArr; //图片 byte数组
private string content; //显示信息
- private int imageWidth = (int)CommonEnum.IMAGE_WIDTH; //图片宽度
- private int imageHeight = (int)CommonEnum.IMAGE_HEIGHT; //图片高度
private bool adminStartUp = false; //始终管理员方式启动 默认否
private byte[] defaultImage; //默认图标
@@ -152,33 +150,7 @@ namespace GeekDesk.ViewModel
}
}
- public int ImageWidth
- {
- get
- {
- // 为了兼容旧版 暂时使用默认
- return (int)CommonEnum.IMAGE_WIDTH;
- }
- set
- {
- imageWidth = value;
- OnPropertyChanged("ImageWidth");
- }
- }
-
- public int ImageHeight
- {
- get
- {
- // 为了兼容旧版 暂时使用默认
- return (int)CommonEnum.IMAGE_HEIGHT;
- }
- set
- {
- imageHeight = value;
- OnPropertyChanged("ImageHeight");
- }
- }
+
diff --git a/ViewModel/ToDoInfo.cs b/ViewModel/ToDoInfo.cs
index 032ec78..1491dcd 100644
--- a/ViewModel/ToDoInfo.cs
+++ b/ViewModel/ToDoInfo.cs
@@ -1,4 +1,5 @@
-using GeekDesk.Util;
+using GeekDesk.Constant;
+using GeekDesk.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -17,8 +18,38 @@ namespace GeekDesk.ViewModel
private string msg; //事项详情
private string exeTime; //待办时间
private string doneTime; //完成时间
+ private TodoTaskExecType execType = TodoTaskExecType.SET_TIME;
+ private string cron; //cron表达式
//private int status; //状态 0 未处理 1 已处理
+ public string Cron
+ {
+ get
+ {
+ return cron;
+ }
+ set
+ {
+ cron = value;
+ OnPropertyChanged("Cron");
+ }
+ }
+
+
+ public TodoTaskExecType ExecType
+ {
+ get
+ {
+ //兼容老版本 需要给个默认值
+ if (execType == 0) return TodoTaskExecType.SET_TIME;
+ return execType;
+ }
+ set
+ {
+ execType = value;
+ OnPropertyChanged("ExecType");
+ }
+ }
public string DoneTime
{
diff --git a/packages.config b/packages.config
index 7099fce..b2dc769 100644
--- a/packages.config
+++ b/packages.config
@@ -2,6 +2,13 @@
+
+
+
+
+
+
+
\ No newline at end of file