|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using System.Collections.Concurrent;
- using System.Collections.ObjectModel;
- using System.Windows;
- using BPASmartClient.Helper;
- using Microsoft.Toolkit.Mvvm.Input;
- using BPASmartClient.JXJFoodSmallStation.View;
- using BPASmartClient.JXJFoodSmallStation.Model;
-
- namespace BPASmartClient.JXJFoodSmallStation.ViewModel
- {
- public class DeviceListViewModel : ObservableObject
- {
- public DeviceListViewModel()
- {
- ChangeNameCommand = new RelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- ChangeDeviceNameView cdn = new ChangeDeviceNameView();
- ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
- cdn.ShowDialog();
- }
- });
-
- Open = new RelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- DeviceInquire.GetInstance.GetDevice(str).OpenLid();//设置PLC名称
- }
- });
-
- Close = new RelayCommand<object>((o) =>
- {
- if (o != null && o is string str)
- {
- DeviceInquire.GetInstance.GetDevice(str).CloseLid();//设置PLC名称
- }
- });
-
- devices = DeviceInquire.GetInstance.devices;
- /*foreach (var device in devices)
- {
- device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10;
- }
- devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));*/
- }
-
- public RelayCommand<object> ChangeNameCommand { get; set; }
- public RelayCommand<object> Open { get; set; }
- public RelayCommand<object> Close { get; set; }
-
- //public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
- public ObservableCollection<Devices> devices { get; set; }
- }
-
- public class Devices : ObservableObject
- {
- public int Serial { get { return _mSerial; } set { _mSerial = value; OnPropertyChanged(); } }
- private int _mSerial;
-
- public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
- private string _mIpAddress;
-
- public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
- private string _mDeviceName;
-
- }
- }
|