Files
6098/Cowain.Bake.UI/FactoryMaintenance/ViewModels/PLCVarMonitorViewModel.cs

83 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<IPLCDevice> plcList;
public PLCVarMonitorViewModel(IUnityContainer unityContainer, IRegionManager regionManager, IDialogService dialogService)
: base(unityContainer, regionManager)
{
this.PageTitle = "标签监视";
_dialogService = dialogService;
}
public ObservableCollection<IPLCDevice> PlcList
{
get => plcList ?? (plcList = new ObservableCollection<IPLCDevice>());
}
public override void Refresh()
{
// 用户信息刷新
PlcList.Clear();
var pList = _unityContainer.ResolveAll<IPLCDevice>();
foreach (var item in pList)
{
PlcList.Add(item);
}
}
//public DelegateCommand<Variable> SelectScriptCommand => new DelegateCommand<Variable>((x) =>
//{
// DialogParameters param = new DialogParameters();
// param.Add("variable", x);
// _dialogService.ShowDialog(
// "ScriptSelectDialog",
// param,
// result =>
// {
// if (result.Result == ButtonResult.OK)
// {
// this.Refresh();
// }
// });
//});
//public DelegateCommand<Variable> DeleteScriptCommand => new DelegateCommand<Variable>((x) =>
//{
// var result = HandyControl.Controls.MessageBox.Ask($@"是否确定要删除脚本关联?", "操作提示");
// if (result == System.Windows.MessageBoxResult.Cancel)
// {
// return;
// }
// IPLCService service = _unityContainer.Resolve<IPLCService>();
// int res = service.DelectScript(x);
// if (res > 0)
// {
// Growl.Success("变量删除脚本关联成功!");
// x.ScriptName = "";
// x.ScriptId = 0;
// this.Refresh();
// }
// else
// {
// Growl.Success("变量删除脚本关联失败,Id不存在");
// }
//});
}
}