MarkTreeUserControl.xaml.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using ivf_tl_Entity.Entity.Mark;
  2. using ivf_tl_Entity.Enums;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. namespace ivf_tl_Manage.UserControls
  18. {
  19. /// <summary>
  20. /// MarkTreeUserControl.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class MarkTreeUserControl : UserControl
  23. {
  24. public event Func<MarkEntity, string, bool> MarkOperEvent;
  25. public MarkTreeUserControl()
  26. {
  27. InitializeComponent();
  28. }
  29. public MarkEntity MarkSource
  30. {
  31. get { return (MarkEntity)GetValue(MarkSourceProperty); }
  32. set { SetValue(MarkSourceProperty, value); }
  33. }
  34. // Using a DependencyProperty as the backing store for MarkSource. This enables animation, styling, binding, etc...
  35. public static readonly DependencyProperty MarkSourceProperty =
  36. DependencyProperty.Register("MarkSource", typeof(MarkEntity), typeof(MarkTreeUserControl), new PropertyMetadata(null));
  37. private static void MarkSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  38. {
  39. if (!(d is MarkTreeUserControl source)) return;
  40. if (!(e.NewValue is MarkEntity newValue)) return;
  41. //source.items.MarkSource = newValue;
  42. }
  43. public Brush BackgroundSource
  44. {
  45. get { return (Brush)GetValue(BackgroundSourceProperty); }
  46. set { SetValue(BackgroundSourceProperty, value); }
  47. }
  48. // Using a DependencyProperty as the backing store for BackgroundSource. This enables animation, styling, binding, etc...
  49. public static readonly DependencyProperty BackgroundSourceProperty =
  50. DependencyProperty.Register("BackgroundSource", typeof(Brush), typeof(MarkTreeUserControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
  51. public Brush RectangleFill
  52. {
  53. get { return (Brush)GetValue(RectangleFillProperty); }
  54. set { SetValue(RectangleFillProperty, value); }
  55. }
  56. // Using a DependencyProperty as the backing store for RectangleFill. This enables animation, styling, binding, etc...
  57. public static readonly DependencyProperty RectangleFillProperty =
  58. DependencyProperty.Register("RectangleFill", typeof(Brush), typeof(MarkTreeUserControl), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAEA"))));
  59. /// <summary>
  60. /// 展开关闭事件
  61. /// </summary>
  62. /// <param name="obj"></param>
  63. private void Item_ExpandedEvent(MarkEntity obj)
  64. {
  65. if (obj.IsExpanded)
  66. {
  67. foreach (var item in obj.children)
  68. {
  69. if (item.IsExpanded) item.IsExpanded = false;
  70. if (item.ParentMark == null) item.ParentMark = obj;
  71. }
  72. list.DetailItemSouce = obj.children;
  73. }
  74. else
  75. {
  76. list.DetailItemSouce = null;
  77. }
  78. }
  79. private bool MarkTreeItemUserControl_MarkOperEvent(MarkEntity arg1, string arg2)
  80. {
  81. var aa = MarkOperEvent?.Invoke(arg1, arg2) == true;
  82. if (aa == true && arg2 == "del")
  83. {
  84. if (arg1.ParentMark == MarkSource && !MarkSource.children.Any())
  85. {
  86. this.test1.ex();
  87. }
  88. }
  89. return aa;
  90. }
  91. }
  92. }