MarkWeightTreeUserControl.xaml.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using ivf_tl_Entity.Entity.Mark;
  2. using ivf_tl_Entity.Enums;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  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.Navigation;
  17. using System.Windows.Shapes;
  18. namespace ivf_tl_Manage.UserControls
  19. {
  20. /// <summary>
  21. /// MarkWeightTreeUserControl.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class MarkWeightTreeUserControl : UserControl
  24. {
  25. public event Func<MarkWeight, OperEnum, bool?> MarkWeightOperTreeEvent;
  26. public MarkWeightTreeUserControl()
  27. {
  28. InitializeComponent();
  29. }
  30. public MarkWeight MarkWeightSource
  31. {
  32. get { return (MarkWeight)GetValue(MarkWeightSourceProperty); }
  33. set { SetValue(MarkWeightSourceProperty, value); }
  34. }
  35. // Using a DependencyProperty as the backing store for MarkWeightSource. This enables animation, styling, binding, etc...
  36. public static readonly DependencyProperty MarkWeightSourceProperty =
  37. DependencyProperty.Register("MarkWeightSource", typeof(MarkWeight), typeof(MarkWeightTreeUserControl), new PropertyMetadata(null));
  38. public Brush RectangleFill
  39. {
  40. get { return (Brush)GetValue(RectangleFillProperty); }
  41. set { SetValue(RectangleFillProperty, value); }
  42. }
  43. // Using a DependencyProperty as the backing store for RectangleFill. This enables animation, styling, binding, etc...
  44. public static readonly DependencyProperty RectangleFillProperty =
  45. DependencyProperty.Register("RectangleFill", typeof(Brush), typeof(MarkWeightTreeUserControl), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAEA"))));
  46. public Brush BackgroundSource
  47. {
  48. get { return (Brush)GetValue(BackgroundSourceProperty); }
  49. set { SetValue(BackgroundSourceProperty, value); }
  50. }
  51. // Using a DependencyProperty as the backing store for BackgroundSource. This enables animation, styling, binding, etc...
  52. public static readonly DependencyProperty BackgroundSourceProperty =
  53. DependencyProperty.Register("BackgroundSource", typeof(Brush), typeof(MarkWeightTreeUserControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
  54. private void MarkWeightItemUserControl_ExpandedEvent(MarkWeight obj)
  55. {
  56. if (obj.IsExpanded)
  57. {
  58. foreach (var item in obj.children)
  59. {
  60. if (item.ParentMarkWeight == null) item.ParentMarkWeight = obj;
  61. item.RectangleFill = RectangleFill;
  62. if (item.IsExpanded) item.IsExpanded = false;
  63. }
  64. DetailItemSouce = obj.children;
  65. }
  66. else
  67. {
  68. DetailItemSouce = null;
  69. }
  70. }
  71. public ObservableCollection<MarkWeight> DetailItemSouce
  72. {
  73. get { return (ObservableCollection<MarkWeight>)GetValue(DetailItemSouceProperty); }
  74. set { SetValue(DetailItemSouceProperty, value); }
  75. }
  76. // Using a DependencyProperty as the backing store for DetailItemSouce. This enables animation, styling, binding, etc...
  77. public static readonly DependencyProperty DetailItemSouceProperty =
  78. DependencyProperty.Register("DetailItemSouce", typeof(ObservableCollection<MarkWeight>), typeof(MarkWeightTreeUserControl), new PropertyMetadata(null));
  79. private bool? test1_MarkWeightOperEvent(MarkWeight arg1, ivf_tl_Entity.Enums.OperEnum arg2)
  80. {
  81. return MarkWeightOperTreeEvent?.Invoke(arg1, arg2);
  82. }
  83. private bool? MarkWeightTreeUserControl_MarkWeightOperTreeEvent(MarkWeight arg1, OperEnum arg2)
  84. {
  85. var aa = MarkWeightOperTreeEvent?.Invoke(arg1, arg2);
  86. if (aa == true && arg2== OperEnum.Delete)
  87. {
  88. if (arg1.ParentMarkWeight == MarkWeightSource && !MarkWeightSource.children.Any())
  89. {
  90. this.test1.ex();
  91. }
  92. }
  93. return aa;
  94. }
  95. }
  96. }