using Cowain.Bake.Common; using Cowain.Bake.Communication.Interface; using Prism.Regions; using Prism.Services.Dialogs; using System.Collections.ObjectModel; using Unity; namespace Cowain.Bake.UI.FactoryMaintenance.ViewModels { public class PLCVarMonitorViewModel : ViewModelBase { IDialogService _dialogService; public ObservableCollection plcList; public PLCVarMonitorViewModel(IUnityContainer unityContainer, IRegionManager regionManager, IDialogService dialogService) : base(unityContainer, regionManager) { this.PageTitle = "标签监视"; _dialogService = dialogService; } public ObservableCollection PlcList { get => plcList ?? (plcList = new ObservableCollection()); } public override void Refresh() { // 用户信息刷新 PlcList.Clear(); var pList = _unityContainer.ResolveAll(); foreach (var item in pList) { PlcList.Add(item); } } //public DelegateCommand SelectScriptCommand => new DelegateCommand((x) => //{ // DialogParameters param = new DialogParameters(); // param.Add("variable", x); // _dialogService.ShowDialog( // "ScriptSelectDialog", // param, // result => // { // if (result.Result == ButtonResult.OK) // { // this.Refresh(); // } // }); //}); //public DelegateCommand DeleteScriptCommand => new DelegateCommand((x) => //{ // var result = HandyControl.Controls.MessageBox.Ask($@"是否确定要删除脚本关联?", "操作提示"); // if (result == System.Windows.MessageBoxResult.Cancel) // { // return; // } // IPLCService service = _unityContainer.Resolve(); // int res = service.DelectScript(x); // if (res > 0) // { // Growl.Success("变量删除脚本关联成功!"); // x.ScriptName = ""; // x.ScriptId = 0; // this.Refresh(); // } // else // { // Growl.Success("变量删除脚本关联失败,Id不存在!"); // } //}); } }