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 { /// /// AlarmSettingItemUserControl.xaml 的交互逻辑 /// public partial class AlarmSettingItemUserControl : UserControl { public event Action EditAlarmDetailEvent; public event Action 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 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); } } }