TodoControl.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using GeekDesk.Control.Windows;
  2. using GeekDesk.Util;
  3. using GeekDesk.ViewModel;
  4. using HandyControl.Controls;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. namespace GeekDesk.Control.UserControls.Backlog
  20. {
  21. public enum ToDoType
  22. {
  23. HISTORY = 1,
  24. NEW = 2
  25. }
  26. /// <summary>
  27. /// BacklogControl.xaml 的交互逻辑
  28. /// </summary>
  29. public partial class TodoControl : UserControl
  30. {
  31. public ToDoType type;
  32. public TodoControl()
  33. {
  34. InitializeComponent();
  35. }
  36. private void DeleteMenu_Click(object sender, RoutedEventArgs e)
  37. {
  38. ToDoInfo info = BacklogList.SelectedItem as ToDoInfo;
  39. Growl.Ask("确认删除吗?", isConfirmed =>
  40. {
  41. if (isConfirmed)
  42. {
  43. if (type == ToDoType.NEW)
  44. {
  45. MainWindow.appData.ToDoList.Remove(info);
  46. }
  47. else
  48. {
  49. MainWindow.appData.HiToDoList.Remove(info);
  50. }
  51. CommonCode.SaveAppData(MainWindow.appData);
  52. }
  53. return true;
  54. }, "DeleteConfirm");
  55. }
  56. private void DetailMenu_Click(object sender, RoutedEventArgs e)
  57. {
  58. ToDoInfo info = BacklogList.SelectedItem as ToDoInfo;
  59. ToDoInfoWindow.ShowDetail(info);
  60. }
  61. /// <summary>
  62. /// 禁用设置按钮右键菜单
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void DataGridMenu_Initialized(object sender, EventArgs e)
  67. {
  68. BacklogList.ContextMenu = null;
  69. }
  70. /// <summary>
  71. /// 打开右键菜单
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void DataGridRow_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  76. {
  77. BacklogList.SelectedIndex = ((DataGridRow)sender).GetIndex();
  78. Menu.IsOpen = true;
  79. }
  80. /// <summary>
  81. /// 选中时颜色变化
  82. /// </summary>
  83. /// <param name="sender"></param>
  84. /// <param name="e"></param>
  85. private void DataGridRow_Selected(object sender, RoutedEventArgs e)
  86. {
  87. Color c = Color.FromRgb(91, 192, 222);
  88. SolidColorBrush b = new SolidColorBrush
  89. {
  90. Color = c,
  91. Opacity = 0.9
  92. };
  93. ((DataGridRow)sender).Background = b;
  94. }
  95. }
  96. }