| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using ivf_tl_CustomControls;
- using ivf_tl_Entity.Entity.Alarm;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ivf_tl_Manage.UserControls
- {
- /// <summary>
- /// AlarmSettingItemUserControl.xaml 的交互逻辑
- /// </summary>
- public partial class AlarmSettingItemUserControl : UserControl
- {
- public event Action<AlarmDetailEntity> EditAlarmDetailEvent;
- public event Action<AlarmUserEntity,string> AlarmUserEntityOperEvent;
- public AlarmSettingItemUserControl()
- {
- InitializeComponent();
- }
- public AlarmUserEntity AlarmUserSource
- {
- get { return (AlarmUserEntity)GetValue(AlarmUserSourceProperty); }
- set { SetValue(AlarmUserSourceProperty, value); }
- }
- public static readonly DependencyProperty AlarmUserSourceProperty =
- DependencyProperty.Register("AlarmUserSource", typeof(AlarmUserEntity), typeof(AlarmSettingItemUserControl), new PropertyMetadata(null));
- private static void AlarmUserSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is AlarmSettingItemUserControl source)) return;
- if(!(e.NewValue is AlarmUserEntity newValue)) return;
- }
- public Brush BackgroundSource
- {
- get { return (Brush)GetValue(BackgroundSourceProperty); }
- set { SetValue(BackgroundSourceProperty, value); }
- }
- // Using a DependencyProperty as the backing store for BackgroundSource. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty BackgroundSourceProperty =
- DependencyProperty.Register("BackgroundSource", typeof(Brush), typeof(AlarmSettingItemUserControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
- public Brush RectangleFill
- {
- get { return (Brush)GetValue(RectangleFillProperty); }
- set { SetValue(RectangleFillProperty, value); }
- }
- public static readonly DependencyProperty RectangleFillProperty =
- DependencyProperty.Register("RectangleFill", typeof(Brush), typeof(AlarmSettingItemUserControl), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EAEAEA"))));
- private void Edit_Click(object sender, RoutedEventArgs e)
- {
- AlarmUserEntityOperEvent?.Invoke(AlarmUserSource, "edit");
- }
- private void Del_Click(object sender, RoutedEventArgs e)
- {
- AlarmUserEntityOperEvent?.Invoke(AlarmUserSource, "delete");
- }
- private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (AlarmUserSource.IsExpanded)
- {
- expand_Image1.Width = 10;
- expand_Image1.Height = 20;
- expand_Image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/unfoldMark.png", UriKind.RelativeOrAbsolute));
- AlarmUserSource.IsExpanded = false;
- return;
- }
- expand_Image1.Width = 20;
- expand_Image1.Height = 10;
- expand_Image1.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/foldMark.png", UriKind.RelativeOrAbsolute));
- AlarmUserSource.IsExpanded = true;
- if (this._childreContent.HasItems) return;
- this._childreContent.ItemsSource = AlarmUserSource.AlarmDetailList;
- }
- private void CheckBox_Checked(object sender, RoutedEventArgs e)
- {
- if (!(sender is CheckBox source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
- EditAlarmDetailEvent?.Invoke(alarmDetail);
- }
- private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
- {
- if (!(sender is CheckBox source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
- EditAlarmDetailEvent?.Invoke(alarmDetail);
- }
- private void ComBoxCustom1_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!(sender is ComBoxCustom1 source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
- if (!(source.SelectedItem is KeyValuePair<int, string> newItem)) return;
- if (alarmDetail.intervalTime == newItem.Key) return;
- alarmDetail.intervalTime = newItem.Key;
- if (alarmDetail.perId == 0) return;
- EditAlarmDetailEvent?.Invoke(alarmDetail);
- }
- private void Sms_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!(sender is ComBoxCustom1 source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
- if (!(source.SelectedItem is AlarmTemplateEntity newSms)) return;
- if (alarmDetail.smsTemplateId == newSms.id) return;
- alarmDetail.smsTemplateId = newSms.id;
- alarmDetail.smsTemplate = newSms.templateCode;
- if (alarmDetail.perId == 0) return;
- EditAlarmDetailEvent?.Invoke(alarmDetail);
- }
- private void Call_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!(sender is ComBoxCustom1 source)) return;
- if (!source.IsLoaded) return;
- if (!(source.Tag is AlarmDetailEntity alarmDetail)) return;
- if (!(source.SelectedItem is AlarmTemplateEntity newSms)) return;
- if (alarmDetail.callTemplateId == newSms.id) return;
- alarmDetail.callTemplateId = newSms.id;
- alarmDetail.callTemplate = newSms.templateCode;
- if (alarmDetail.perId == 0) return;
- EditAlarmDetailEvent?.Invoke(alarmDetail);
- }
- }
- }
|