|
- using BPASmartClient.CustomResource.UserControls;
- using BPASmartClient.CustomResource.UserControls.MessageShow;
- using BPA.Helper;
- using FryPot_DosingSystem.Model;
- using BPA.Helper;
-
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace FryPot_DosingSystem.ViewModel
- {
- internal class DeviceListViewModel : NotifyBase
- {
- public ObservableCollection<string> DeviceName { get; set; } = new ObservableCollection<string>();
- public ObservableCollection<DeviceInfo> devices { get; set; } = new ObservableCollection<DeviceInfo>();
- public BPARelayCommand AddDeviceCommand { get; set; }
- public BPARelayCommand SaveDeviceConfig { get; set; }
- public BPARelayCommand<string> DeleteDevice { get; set; }
- public DeviceListViewModel()
- {
- Json<DeviceManage>.Read();
- devices = Json<DeviceManage>.Data.Devices;
- DeviceName.Add("滚筒输送线");
- DeviceName.Add("炒锅1");
- DeviceName.Add("炒锅2");
- DeviceName.Add("炒锅3");
- DeviceName.Add("炒锅4");
- DeviceName.Add("炒锅5");
- AddDeviceCommand = new BPARelayCommand(() =>
- {
- erp:
- string guid = Guid.NewGuid().ToString();
- DeviceInfo info = devices.FirstOrDefault(p => p.DeviceNum == guid);
- if (info == null)
- {
- devices.Add(new DeviceInfo() { DeviceNum = guid });
- }
- else
- {
- goto erp;
- }
- });
- DeleteDevice = new BPARelayCommand<string>((str) =>
- {
- DeviceInfo device = devices.FirstOrDefault(p => p.DeviceNum == str);
- if (device != null)
- {
- devices.Remove(device);
- }
- });
- SaveDeviceConfig = new BPARelayCommand(() =>
- {
- Json<DeviceManage>.Data.Devices = devices;
- Json<DeviceManage>.Save();
- NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"IP设置成功!");
- });
- }
-
- }
- }
|