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((o) => { if (o != null && o is string str) { ChangeDeviceNameView cdn = new ChangeDeviceNameView(); ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str); cdn.ShowDialog(); } }); 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.OrderBy(item => item.Serial)); } public RelayCommand ChangeNameCommand { get; set; } //public static ObservableCollection devices { get; set; } = new ObservableCollection(); public ObservableCollection 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; } }