| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- using ivf_tl_CustomControls;
- using ivf_tl_Entity.Entity.Alarm;
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Manage.Converts;
- using ivf_tl_Manage.ViewModels;
- using ivf_tl_Manage.Win;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- 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
- {
- /// <summary>
- /// AlarmHistoryView.xaml 的交互逻辑
- /// </summary>
- public partial class AlarmHistoryView : UserControl
- {
- private AlarmHistoryViewModel vm;
- public AlarmHistoryView()
- {
- InitializeComponent();
- bool isStop = false;
- Loaded += (s, e) =>
- {
- vm = (AlarmHistoryViewModel)this.DataContext;
- if (vm == null) return;
- this._tlName_ComBox.SelectedItem = vm.CurrentTlInfo;
- Task.Run(() =>
- {
- Dispatcher.Invoke(() =>
- {
- vm.Init();
- });
- return;
- List<AlarmHistoryEntity> lista = new List<AlarmHistoryEntity>();
- while (true)
- {
- if (vm == null) return;
- if (isStop) return;
- lista.Clear();
- lista = vm.Updata1();
- Dispatcher.Invoke(() =>
- {
- vm.AlarmHistoryList.Clear();
- foreach (var item in lista)
- {
- vm.AlarmHistoryList.Add(item);
- }
- });
- Thread.Sleep(5000);
- }
- });
- };
- Unloaded += (s, e) =>
- {
- isStop = true;
- vm = null;
- this.rootCanvas.Children.Clear();
- };
- }
- public void MessageShow(string message)
- {
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, message).Show();
- }
- private void test_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- string ss = "";
- }
- private void test_DropDownClosed(object sender, EventArgs e)
- {
-
- }
- private void TLSN_DropDownClosed(object sender, EventArgs e)
- {
- if (vm == null) return;
- if (!(sender is ComBoxCustom2 source)) return;
- if (!source.IsLoaded) return;
- if(source.SelectedItem == null)
- {
- vm.SetCurrentTlInfo(null);
- return;
- }
- vm.SetCurrentTlInfo((TLInfo)source.SelectedItem);
- }
- private void House_DropDownClosed(object sender, EventArgs e)
- {
- if (vm == null) return;
- if (!(sender is ComBoxCustom2 source)) return;
- if (!source.IsLoaded) return;
- if (source.SelectedItem == null)
- {
- vm.SetCurrentHouse(-1);
- return;
- }
- vm.SetCurrentHouse((int)source.SelectedItem);
- }
- private void AlarmType_DropDownClosed(object sender, EventArgs e)
- {
- if (vm == null) return;
- if (!(sender is ComBoxCustom2 source)) return;
- if (!source.IsLoaded) return;
- if (source.SelectedItem == null)
- {
- vm.SetCurrentAlarmType(null);
- return;
- }
- vm.SetCurrentAlarmType((AlarmTypeEntity)source.SelectedItem);
- }
- private void RadioButtonMarkSetting_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null) return;
- if (!(sender is RadioButtonMarkSetting source)) return;
- if (!source.IsLoaded) return;
- vm.SetSelectedType(source.Tag.ToString());
- }
- private void PaginationUserControl_PageChangedEvent(UserControls.PaginationUserControl arg1, int arg2)
- {
- if (vm == null) return;
- if (!arg1.IsLoaded) return;
- NoUp = true;
- this._all_CheckBox1.IsChecked = false;
- this._all_CheckBox2.IsChecked = true;
- NoUp = false;
- vm.SetPageCurrent(arg2);
- }
- private void canvasItemsControl_MouseDown(object sender, MouseButtonEventArgs e)
- {
-
- }
- private void Detail_Click(object sender, RoutedEventArgs e)
- {
- if (!(sender is ButtonImage source)) return;
- if (!(source.Tag is AlarmHistoryEntity alarmHistoryEntity)) return;
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- new AlarmDetailWindow(alarmHistoryEntity, AppData.Instance.MainWindow).ShowDialog();
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- }
- private void All_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null || NoUp || !this.IsLoaded) return;
- foreach (var item in vm.AlarmHistoryList)
- {
- item.IsCheck = true;
- }
- }
- private void All_UnChecked(object sender, RoutedEventArgs e)
- {
- if (vm == null || NoUp || !this.IsLoaded) return;
- foreach (var item in vm.AlarmHistoryList)
- {
- item.IsCheck = false;
- }
- }
- bool NoUp = false;
- private void Detail_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null || !this.IsLoaded) return;
- if (vm.AlarmHistoryList.FirstOrDefault(x => !x.IsCheck) == null)
- {
- NoUp = true;
- this._all_CheckBox1.IsChecked = true;
- NoUp = false;
- }
- }
- private void Detail_Unchecked(object sender, RoutedEventArgs e)
- {
- if (vm == null || !this.IsLoaded) return;
- NoUp = true;
- this._all_CheckBox1.IsChecked = false;
- NoUp = false;
- }
- bool isNotifyChanged = false;
- private void Notify_Checked(object sender, RoutedEventArgs e)
- {
- if (isNotifyChanged || vm == null || !this.IsLoaded) return;
- if (!(sender is CheckBox checkBox)) return;
- if (!checkBox.IsLoaded) return;
- AlarmHistoryEntity alarmHistoryEntity = checkBox.Tag as AlarmHistoryEntity;
- if (alarmHistoryEntity == null) return;
- if (alarmHistoryEntity.type == 1)
- {
- //MessageShow("报警已结束");
- MessageShow(KeyToStringConvert.GetLanguageStringByKey("0544"));
- isNotifyChanged = true;
- checkBox.IsChecked = false;
- isNotifyChanged = false;
- return;
- }
- if (!vm.EditAlarmNotify(alarmHistoryEntity))
- {
- isNotifyChanged = true;
- checkBox.IsChecked = false;
- isNotifyChanged = false;
- }
- }
- private void Notify_Unchecked(object sender, RoutedEventArgs e)
- {
- if (isNotifyChanged || vm == null || !this.IsLoaded) return;
- if (!(sender is CheckBox checkBox)) return;
- if (!checkBox.IsLoaded) return;
- AlarmHistoryEntity alarmHistoryEntity = checkBox.Tag as AlarmHistoryEntity;
- if (alarmHistoryEntity == null) return;
- if (alarmHistoryEntity.type == 1)
- {
- MessageShow(KeyToStringConvert.GetLanguageStringByKey("0544"));
- isNotifyChanged = true;
- checkBox.IsChecked = true;
- isNotifyChanged = false;
- return;
- }
- if (!vm.EditAlarmNotify(alarmHistoryEntity))
- {
- isNotifyChanged = true;
- checkBox.IsChecked = true;
- isNotifyChanged = false;
- }
- }
- private void AllDetail_Unchecked(object sender, RoutedEventArgs e)
- {
- if (vm == null || !this.IsLoaded || NoUp) return;
- var list = vm.AlarmHistoryList.Where(x => x.IsCheck && x.notify == 1);
- foreach (AlarmHistoryEntity alarm in list)
- {
-
- if (vm.EditAlarmNotify(alarm.id, 0))
- {
- alarm.notify = 0;
- }
- else
- {
- NoUp = true;
- this._all_CheckBox2.IsChecked = true;
- NoUp = false;
- break;
- }
- }
- }
- private void AllDetail_Checked(object sender, RoutedEventArgs e)
- {
- if (vm == null || !this.IsLoaded || NoUp) return;
- var list = vm.AlarmHistoryList.Where(x => x.IsCheck && x.notify == 0);
- foreach (AlarmHistoryEntity alarm in list)
- {
- if (alarm.type == 1)
- {
- MessageShow(KeyToStringConvert.GetLanguageStringByKey("0544"));
- NoUp = true;
- this._all_CheckBox2.IsChecked = false;
- NoUp = false;
- break;
- }
- if (vm.EditAlarmNotify(alarm.id, 1))
- {
- alarm.notify = 1;
- }
- else
- {
- NoUp = true;
- this._all_CheckBox2.IsChecked = false;
- NoUp = false;
- break;
- }
- }
- }
- }
- }
|