MarkWeightItemUserControl.xaml.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. /// MarkWeightItemUserControl.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class MarkWeightItemUserControl : UserControl
  23. {
  24. public event Func<MarkWeight, OperEnum, bool?> MarkWeightOperEvent;
  25. public event Action<MarkWeight> ExpandedEvent;
  26. public MarkWeightItemUserControl()
  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(MarkWeightItemUserControl), 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(MarkWeightItemUserControl), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAEA"))));
  46. private void StackPanel_MouseUp(object sender, MouseButtonEventArgs e)
  47. {
  48. ex();
  49. }
  50. private void Edit_Click(object sender, RoutedEventArgs e)
  51. {
  52. if (MarkWeightSource == null) return;
  53. MarkWeightOperEvent?.Invoke(MarkWeightSource, OperEnum.Edit);
  54. }
  55. private void Del_Click(object sender, RoutedEventArgs e)
  56. {
  57. if (MarkWeightSource == null) return;
  58. MarkWeightOperEvent?.Invoke(MarkWeightSource, OperEnum.Delete);
  59. }
  60. private void Add_Click(object sender, RoutedEventArgs e)
  61. {
  62. if (MarkWeightSource == null) return;
  63. MarkWeightOperEvent?.Invoke(MarkWeightSource, OperEnum.Add);
  64. }
  65. public void ex()
  66. {
  67. if (MarkWeightSource.IsExpanded)
  68. {
  69. MarkWeightSource.IsExpanded = false;
  70. ExpandedEvent?.Invoke(MarkWeightSource);
  71. if (MarkWeightSource.parentId == -1)
  72. {
  73. this.expand_Image1.Width = 10;
  74. this.expand_Image1.Height = 20;
  75. this.expand_Image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/unfoldMark.png", UriKind.Absolute));
  76. }
  77. else
  78. {
  79. this.expand_Image2.Width = 10;
  80. this.expand_Image2.Height = 20;
  81. this.expand_Image2.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/unfoldMark.png", UriKind.Absolute));
  82. }
  83. }
  84. else
  85. {
  86. MarkWeightSource.IsExpanded = true;
  87. ExpandedEvent?.Invoke(MarkWeightSource);
  88. if (MarkWeightSource.parentId == -1)
  89. {
  90. this.expand_Image1.Width = 20;
  91. this.expand_Image1.Height = 10;
  92. this.expand_Image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/foldMark.png", UriKind.RelativeOrAbsolute));
  93. }
  94. else
  95. {
  96. this.expand_Image2.Width = 20;
  97. this.expand_Image2.Height = 10;
  98. this.expand_Image2.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/foldMark.png", UriKind.RelativeOrAbsolute));
  99. }
  100. }
  101. }
  102. }
  103. }