using ivf_tl_CustomControls; using ivf_tl_Entity.Entity.Alarm; using ivf_tl_Manage.ViewModels; 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.Views { /// /// AlarmSettingViewNew.xaml 的交互逻辑 /// public partial class AlarmSettingViewNew : UserControl { AlarmSettingNewViewModel vm; public AlarmSettingViewNew() { InitializeComponent(); Loaded += (a, b) => { vm = (AlarmSettingNewViewModel)this.DataContext; }; } private void ListBox_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e) { e.Handled = true; } bool isMuteChanged = false; private void Mute_Checked(object sender, RoutedEventArgs e) { if (isMuteChanged || vm == null || !this.IsLoaded) return; if (!(sender is CheckBox checkBox)) return; if (!vm.EditAlarmType(checkBox.Tag as AlarmTypeEntity, -1, -1)) { isMuteChanged = true; checkBox.IsChecked = false; isMuteChanged = false; } } private void Mute_Unchecked(object sender, RoutedEventArgs e) { if (isMuteChanged || vm == null || !this.IsLoaded) return; if (!(sender is CheckBox checkBox)) return; if (!vm.EditAlarmType(checkBox.Tag as AlarmTypeEntity, -1, -1)) { isMuteChanged = true; checkBox.IsChecked = true; isMuteChanged = false; } } private void AddPersonne_Click(object sender, RoutedEventArgs e) { if (vm != null) vm.AddAlarmPersonne(); } private void Del_Click(object sender, RoutedEventArgs e) { if (vm == null) return; if (!(sender is ButtonImage buttonImage)) return; vm.DelAlarmPersonne(buttonImage.Tag as AlarmPersonne); } private void Edit_Click(object sender, RoutedEventArgs e) { if (vm == null) return; if (!(sender is ButtonImage buttonImage)) return; vm.EditAlarmPersonne(buttonImage.Tag as AlarmPersonne); } private void IntervalTime_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (vm == null || !this.IsLoaded) return; if (!(sender is ComBoxCustom1 comBoxCustom)) return; AlarmTypeEntity alarmTypeEntity = comBoxCustom.Tag as AlarmTypeEntity; if (alarmTypeEntity == null) return; if (alarmTypeEntity.intervalTime == alarmTypeEntity.SelectedTime.Key) return; if (!vm.EditAlarmType(alarmTypeEntity, alarmTypeEntity.SelectedTime.Key, -1)) { alarmTypeEntity.SelectedTime = alarmTypeEntity.TimeSource.FirstOrDefault(x => x.Key == alarmTypeEntity.intervalTime); } else { alarmTypeEntity.intervalTime = alarmTypeEntity.SelectedTime.Key; } } private void AlarmLevel_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (vm == null || !this.IsLoaded) return; if (!(sender is ComBoxCustom1 comBoxCustom)) return; AlarmTypeEntity alarmTypeEntity = comBoxCustom.Tag as AlarmTypeEntity; if (alarmTypeEntity == null) return; if (alarmTypeEntity.alarmLevel == alarmTypeEntity.SelectedLevel.Key) return; if (!vm.EditAlarmType(alarmTypeEntity, -1, alarmTypeEntity.SelectedLevel.Key)) { alarmTypeEntity.SelectedLevel = alarmTypeEntity.LevelSource.FirstOrDefault(x => x.Key == alarmTypeEntity.alarmLevel); } else { alarmTypeEntity.alarmLevel = alarmTypeEntity.SelectedLevel.Key; } } private void AlarmSetting_Click(object sender, RoutedEventArgs e) { if (vm == null) return; vm.SetAlarmSetting(); } } }