using FLY.Thick.Base.UI.OnInit; using GalaSoft.MvvmLight.Command; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; 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.Shapes; namespace FLY.Thick.Base.UI { /// <summary> /// WdSkipWarningUnityNames.xaml 的交互逻辑 /// </summary> public partial class WdWarningUnityNames : FLY.ControlLibrary.WindowBigClose { WdWarningUnityNamesVm viewModel; public WdWarningUnityNames() { InitializeComponent(); } public void Init(WarningSystemManager warningSystemManager) { viewModel = new WdWarningUnityNamesVm(); viewModel.Init(warningSystemManager); this.DataContext = viewModel; } } public class WdWarningUnityNamesVm:INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public ObservableCollection<WarningName> WarningNames { get; } = new ObservableCollection<WarningName>(); public RelayCommand OkCmd { get; private set; } WarningSystemManager warningSystemManager; public WdWarningUnityNamesVm() { OkCmd = new RelayCommand(Ok); } public void Init(WarningSystemManager warningSystemManager) { this.warningSystemManager = warningSystemManager; var names = warningSystemManager.GetWarningNames(); foreach (var name in names) WarningNames.Add(name); } private void Ok() { var skips = WarningNames.Where(w => !w.IsRegistered).Select(w => w.UnityName).ToList(); warningSystemManager.SetSkipWarningName(skips); FLY.ControlLibrary.Window_Tip.ShowShortTime("成功", $"{WarningNames.Count() - skips.Count()}个报警服务 需要注册关注"); } } public class WdWarningUnityNamesVmUt : WdWarningUnityNamesVm { public WdWarningUnityNamesVmUt() { WarningNames.Add(new WarningName() { UnityName = "测厚仪" }); WarningNames.Add(new WarningName() { UnityName = "风环" }); WarningNames.Add(new WarningName() { UnityName = "称重" , IsRegistered = false }); } } }