Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- using BPASmartClient.Helper;
- using FryPot_DosingSystem.Model;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- 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 : ObservableObject
- {
- public ObservableCollection<string> DeviceName { get; set; } = new ObservableCollection<string>();
- public ObservableCollection<DeviceInfo> devices { get; set; } = new ObservableCollection<DeviceInfo>();
- public RelayCommand AddDeviceCommand { get; set; }
- public RelayCommand SaveDeviceConfig { get; set; }
- public RelayCommand<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 RelayCommand(() =>
- {
- 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 RelayCommand<string>((str) =>
- {
- DeviceInfo device = devices.FirstOrDefault(p => p.DeviceNum == str);
- if (device != null)
- {
- devices.Remove(device);
- }
- });
- SaveDeviceConfig = new RelayCommand(() =>
- {
- Json<DeviceManage>.Data.Devices = devices;
- Json<DeviceManage>.Save();
- });
- }
-
- }
- }
|