BacklogNotificatin.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using GeekDesk.Task;
  2. using GeekDesk.Util;
  3. using GeekDesk.ViewModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace GeekDesk.Control.Other
  18. {
  19. /// <summary>
  20. /// BacklogNotificatin.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class BacklogNotificatin
  23. {
  24. private AppData appData = MainWindow.appData;
  25. public BacklogNotificatin(BacklogInfo info)
  26. {
  27. InitializeComponent();
  28. this.DataContext = info;
  29. }
  30. private void BacklogDone_Click(object sender, RoutedEventArgs e)
  31. {
  32. BacklogInfo info = this.DataContext as BacklogInfo;
  33. info.DoneTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  34. appData.ExeBacklogList.Remove(info); //执行任务删除
  35. appData.HiBacklogList.Add(info); //添加历史任务
  36. BacklogTask.activityBacklog[info].Close(); //关闭桌面通知
  37. BacklogTask.activityBacklog.Remove(info);//激活任务删除
  38. CommonCode.SaveAppData(appData);
  39. }
  40. /// <summary>
  41. /// 只允许输入数字
  42. /// </summary>
  43. /// <param name="sender"></param>
  44. /// <param name="e"></param>
  45. private void DelayTime_PreviewTextInput(object sender, TextCompositionEventArgs e)
  46. {
  47. int textBoxInt;
  48. //转化按下的键为数字,如果不是数字则会抓取到报错信息,不键入,反之则键入
  49. try
  50. {
  51. textBoxInt = int.Parse($"{e.Text}");
  52. }
  53. catch (FormatException)
  54. {
  55. e.Handled = true;
  56. }
  57. }
  58. /// <summary>
  59. /// 失去焦点前如果为空
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. private void DelayTime_PreviewLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
  64. {
  65. int textBoxInt;
  66. //转化val为数字,如果不是数字则会抓取到报错信息
  67. try
  68. {
  69. textBoxInt = int.Parse(DelayTime.Text.Trim());
  70. }
  71. catch (FormatException)
  72. {
  73. DelayTime.Text = "10";
  74. }
  75. }
  76. /// <summary>
  77. /// 推迟提醒
  78. /// </summary>
  79. /// <param name="sender"></param>
  80. /// <param name="e"></param>
  81. private void DelayButton_Click(object sender, RoutedEventArgs e)
  82. {
  83. BacklogInfo info = this.DataContext as BacklogInfo;
  84. int time = int.Parse(DelayTime.Text);
  85. string type = DelayType.Text;
  86. switch(type)
  87. {
  88. case "分":
  89. info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");
  90. break;
  91. case "时":
  92. info.ExeTime = DateTime.Now.AddHours(time).ToString("yyyy-MM-dd HH:mm:ss");
  93. break;
  94. }
  95. BacklogTask.activityBacklog[info].Close(); //关闭桌面通知
  96. BacklogTask.activityBacklog.Remove(info);//激活任务删除
  97. }
  98. }
  99. }