AlarmSettingItemUserControl.xaml.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using ivf_tl_CustomControls;
  2. using ivf_tl_Entity.Entity.Alarm;
  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. /// AlarmSettingItemUserControl.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class AlarmSettingItemUserControl : UserControl
  23. {
  24. public event Action<AlarmDetailEntity> EditAlarmDetailEvent;
  25. public event Action<AlarmUserEntity,string> AlarmUserEntityOperEvent;
  26. public AlarmSettingItemUserControl()
  27. {
  28. InitializeComponent();
  29. }
  30. public AlarmUserEntity AlarmUserSource
  31. {
  32. get { return (AlarmUserEntity)GetValue(AlarmUserSourceProperty); }
  33. set { SetValue(AlarmUserSourceProperty, value); }
  34. }
  35. public static readonly DependencyProperty AlarmUserSourceProperty =
  36. DependencyProperty.Register("AlarmUserSource", typeof(AlarmUserEntity), typeof(AlarmSettingItemUserControl), new PropertyMetadata(null));
  37. private static void AlarmUserSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  38. {
  39. if (!(d is AlarmSettingItemUserControl source)) return;
  40. if(!(e.NewValue is AlarmUserEntity newValue)) return;
  41. }
  42. public Brush BackgroundSource
  43. {
  44. get { return (Brush)GetValue(BackgroundSourceProperty); }
  45. set { SetValue(BackgroundSourceProperty, value); }
  46. }
  47. // Using a DependencyProperty as the backing store for BackgroundSource. This enables animation, styling, binding, etc...
  48. public static readonly DependencyProperty BackgroundSourceProperty =
  49. DependencyProperty.Register("BackgroundSource", typeof(Brush), typeof(AlarmSettingItemUserControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
  50. public Brush RectangleFill
  51. {
  52. get { return (Brush)GetValue(RectangleFillProperty); }
  53. set { SetValue(RectangleFillProperty, value); }
  54. }
  55. public static readonly DependencyProperty RectangleFillProperty =
  56. DependencyProperty.Register("RectangleFill", typeof(Brush), typeof(AlarmSettingItemUserControl), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAEA"))));
  57. private void Edit_Click(object sender, RoutedEventArgs e)
  58. {
  59. AlarmUserEntityOperEvent?.Invoke(AlarmUserSource, "edit");
  60. }
  61. private void Del_Click(object sender, RoutedEventArgs e)
  62. {
  63. AlarmUserEntityOperEvent?.Invoke(AlarmUserSource, "delete");
  64. }
  65. private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
  66. {
  67. if (AlarmUserSource.IsExpanded)
  68. {
  69. expand_Image1.Width = 10;
  70. expand_Image1.Height = 20;
  71. expand_Image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/unfoldMark.png", UriKind.RelativeOrAbsolute));
  72. AlarmUserSource.IsExpanded = false;
  73. return;
  74. }
  75. expand_Image1.Width = 20;
  76. expand_Image1.Height = 10;
  77. expand_Image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/foldMark.png", UriKind.RelativeOrAbsolute));
  78. AlarmUserSource.IsExpanded = true;
  79. if (this._childreContent.HasItems) return;
  80. this._childreContent.ItemsSource = AlarmUserSource.AlarmDetailList;
  81. }
  82. private void CheckBox_Checked(object sender, RoutedEventArgs e)
  83. {
  84. if (!(sender is CheckBox source)) return;
  85. if (!source.IsLoaded) return;
  86. if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
  87. EditAlarmDetailEvent?.Invoke(alarmDetail);
  88. }
  89. private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
  90. {
  91. if (!(sender is CheckBox source)) return;
  92. if (!source.IsLoaded) return;
  93. if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
  94. EditAlarmDetailEvent?.Invoke(alarmDetail);
  95. }
  96. private void ComBoxCustom1_SelectionChanged(object sender, SelectionChangedEventArgs e)
  97. {
  98. if (!(sender is ComBoxCustom1 source)) return;
  99. if (!source.IsLoaded) return;
  100. if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
  101. if (!(source.SelectedItem is KeyValuePair<int, string> newItem)) return;
  102. if (alarmDetail.intervalTime == newItem.Key) return;
  103. alarmDetail.intervalTime = newItem.Key;
  104. if (alarmDetail.perId == 0) return;
  105. EditAlarmDetailEvent?.Invoke(alarmDetail);
  106. }
  107. private void Sms_SelectionChanged(object sender, SelectionChangedEventArgs e)
  108. {
  109. if (!(sender is ComBoxCustom1 source)) return;
  110. if (!source.IsLoaded) return;
  111. if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
  112. if (!(source.SelectedItem is AlarmTemplateEntity newSms)) return;
  113. if (alarmDetail.smsTemplateId == newSms.id) return;
  114. alarmDetail.smsTemplateId = newSms.id;
  115. alarmDetail.smsTemplate = newSms.templateCode;
  116. if (alarmDetail.perId == 0) return;
  117. EditAlarmDetailEvent?.Invoke(alarmDetail);
  118. }
  119. private void Call_SelectionChanged(object sender, SelectionChangedEventArgs e)
  120. {
  121. if (!(sender is ComBoxCustom1 source)) return;
  122. if (!source.IsLoaded) return;
  123. if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
  124. if (!(source.SelectedItem is AlarmTemplateEntity newSms)) return;
  125. if (alarmDetail.callTemplateId == newSms.id) return;
  126. alarmDetail.callTemplateId = newSms.id;
  127. alarmDetail.callTemplate = newSms.templateCode;
  128. if (alarmDetail.perId == 0) return;
  129. EditAlarmDetailEvent?.Invoke(alarmDetail);
  130. }
  131. }
  132. }