添加待办任务提醒功能
This commit is contained in:
@@ -9,35 +9,41 @@
|
||||
Height="450">
|
||||
<Grid>
|
||||
|
||||
<!--<TextBlock Text="You have a new task"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="25"
|
||||
Foreground="#326CF3"
|
||||
HorizontalAlignment="Center" Margin="37.686,17.333,36.353,0"/>
|
||||
<Border Margin="27.647,69,36.354,329" Style="{StaticResource BorderTipInfo}" Height="50">
|
||||
<TextBlock Margin="10,0,0,0" FontSize="20" Text="任务名称"/>
|
||||
</Border>
|
||||
<Image Source="/Resource/Image/CompleteLogo.png" Margin="22,22,22,361" />
|
||||
|
||||
<Border Style="{StaticResource BorderRegion}" Width="250" Height="200" Effect="{StaticResource EffectShadow1}" Margin="31.646,168,36.353,80">
|
||||
<Border Background="{DynamicResource InfoBrush}">
|
||||
<TextBlock Text="agaharhaewrhehssssssss任务名称ssssssssssssssssss"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="White"
|
||||
TextWrapping="Wrap"
|
||||
TextAlignment="Center"
|
||||
Margin="10"
|
||||
FontSize="15"/>
|
||||
|
||||
<hc:Card MaxWidth="250" Height="200" BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="8">
|
||||
<!--Card 的内容部分-->
|
||||
<Border CornerRadius="4,4,0,0" Width="160" Height="160">
|
||||
<TextBlock TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Msg}"/>
|
||||
</Border>
|
||||
</Border>-->
|
||||
<!--Card 的尾部部分-->
|
||||
<hc:Card.Footer>
|
||||
<StackPanel Margin="10" Width="160">
|
||||
<!--Card 的一级内容-->
|
||||
<TextBlock TextWrapping="NoWrap" FontSize="20" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
|
||||
Text="{Binding Title}"
|
||||
HorizontalAlignment="Left"/>
|
||||
<!--Card 的二级内容-->
|
||||
<TextBlock TextWrapping="NoWrap" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
|
||||
Text="{Binding ExeTime}" Margin="0,6,0,0"
|
||||
HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
</hc:Card.Footer>
|
||||
</hc:Card>
|
||||
|
||||
<ComboBox hc:DropDownElement.ConsistentWidth="False" SelectedIndex="0" Margin="219,334,39,84" Height="20" Width="60">
|
||||
<ComboBox.Items>
|
||||
<ComboBoxItem Content="分"/>
|
||||
<ComboBoxItem Content="时"/>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
<hc:UniformSpacingPanel Spacing="20" HorizontalAlignment="Center" Margin="0,346,0,0">
|
||||
<hc:TextBox x:Name="DelayTime" Height="20" Width="60" Text="10" PreviewTextInput="DelayTime_PreviewTextInput" PreviewLostKeyboardFocus="DelayTime_PreviewLostKeyboardFocus" />
|
||||
<ComboBox x:Name="DelayType" hc:DropDownElement.ConsistentWidth="False" SelectedIndex="0" Height="20" Width="60">
|
||||
<ComboBox.Items>
|
||||
<ComboBoxItem Content="分"/>
|
||||
<ComboBoxItem Content="时"/>
|
||||
</ComboBox.Items>
|
||||
</ComboBox>
|
||||
<Button Content="推迟提醒" Click="DelayButton_Click"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<Button Command="{Binding OpenCmd}" Content="关闭" Margin="10,0,10,20" Width="298" VerticalAlignment="Bottom"/>
|
||||
|
||||
<Button Click="BacklogDone_Click" Content="朕已阅" Margin="10,0,10,20" Width="298" VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using GeekDesk.ViewModel;
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -20,9 +22,84 @@ namespace GeekDesk.Control.Other
|
||||
/// </summary>
|
||||
public partial class BacklogNotificatin
|
||||
{
|
||||
|
||||
private AppData appData = MainWindow.appData;
|
||||
public BacklogNotificatin(BacklogInfo info)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = info;
|
||||
}
|
||||
|
||||
private void BacklogDone_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BacklogInfo info = this.DataContext as BacklogInfo;
|
||||
info.DoneTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
appData.ExeBacklogList.Remove(info); //执行任务删除
|
||||
appData.HiBacklogList.Add(info); //添加历史任务
|
||||
BacklogTask.activityBacklog[info].Close(); //关闭桌面通知
|
||||
BacklogTask.activityBacklog.Remove(info);//激活任务删除
|
||||
CommonCode.SaveAppData(appData);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 只允许输入数字
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DelayTime_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
||||
{
|
||||
int textBoxInt;
|
||||
//转化按下的键为数字,如果不是数字则会抓取到报错信息,不键入,反之则键入
|
||||
try
|
||||
{
|
||||
textBoxInt = int.Parse($"{e.Text}");
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 失去焦点前如果为空
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DelayTime_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
|
||||
{
|
||||
int textBoxInt;
|
||||
//转化val为数字,如果不是数字则会抓取到报错信息
|
||||
try
|
||||
{
|
||||
textBoxInt = int.Parse(DelayTime.Text.Trim());
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
DelayTime.Text = "10";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 推迟提醒
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DelayButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
BacklogInfo info = this.DataContext as BacklogInfo;
|
||||
int time = int.Parse(DelayTime.Text);
|
||||
string type = DelayType.Text;
|
||||
switch(type)
|
||||
{
|
||||
case "分":
|
||||
info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
break;
|
||||
case "时":
|
||||
info.ExeTime = DateTime.Now.AddHours(time).ToString("yyyy-MM-dd HH:mm:ss");
|
||||
break;
|
||||
}
|
||||
BacklogTask.activityBacklog[info].Close(); //关闭桌面通知
|
||||
BacklogTask.activityBacklog.Remove(info);//激活任务删除
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,6 +275,7 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Fonts\iconfont.css" />
|
||||
<Content Include="Fonts\iconfont.js" />
|
||||
<Resource Include="Resource\Image\CompleteLogo.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -2,6 +2,7 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control;
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Task;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using GlobalHotKey;
|
||||
@@ -37,6 +38,7 @@ namespace GeekDesk
|
||||
this.Topmost = true;
|
||||
this.Loaded += Window_Loaded;
|
||||
this.SizeChanged += MainWindow_Resize;
|
||||
BacklogTask.BackLogCheck();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
|
||||
BIN
Resource/Image/CompleteLogo.png
Normal file
BIN
Resource/Image/CompleteLogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -8,28 +8,50 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
|
||||
namespace GeekDesk.Task
|
||||
{
|
||||
class BacklogTask
|
||||
public class BacklogTask
|
||||
{
|
||||
|
||||
private static void BackLogCheck()
|
||||
|
||||
///public static ObservableCollection<BacklogInfo> activityBacklog = new ObservableCollection<BacklogInfo>();
|
||||
|
||||
public static Dictionary<BacklogInfo, Notification> activityBacklog = new Dictionary<BacklogInfo, Notification>();
|
||||
|
||||
public static void BackLogCheck()
|
||||
{
|
||||
while (true)
|
||||
|
||||
System.Timers.Timer timer = new System.Timers.Timer();
|
||||
timer.Enabled = true;
|
||||
timer.Interval = 5000;
|
||||
timer.Start();
|
||||
timer.Elapsed += new System.Timers.ElapsedEventHandler(Check);
|
||||
}
|
||||
|
||||
|
||||
private static void Check(object source, ElapsedEventArgs e)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
ObservableCollection<BacklogInfo> exeBacklogList = MainWindow.appData.ExeBacklogList;
|
||||
foreach (BacklogInfo info in exeBacklogList)
|
||||
if (MainWindow.appData.ExeBacklogList.Count > 0)
|
||||
{
|
||||
if (info.ExeTime.CompareTo(nowTime) == -1)
|
||||
string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
ObservableCollection<BacklogInfo> exeBacklogList = MainWindow.appData.ExeBacklogList;
|
||||
foreach (BacklogInfo info in exeBacklogList)
|
||||
{
|
||||
Notification.Show(new BacklogNotificatin(info), ShowAnimation.Fade, true);
|
||||
if (info.ExeTime.CompareTo(nowTime) == -1 && !activityBacklog.ContainsKey(info))
|
||||
{
|
||||
activityBacklog.Add(info, Notification.Show(new BacklogNotificatin(info), ShowAnimation.Fade, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user