1
0

TodoControl.xaml.cs 2.7 KB

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