终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DeviceListViewModel.cs 2.0 KiB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Toolkit.Mvvm.ComponentModel;
  7. using System.Collections.Concurrent;
  8. using System.Collections.ObjectModel;
  9. using System.Windows;
  10. using BPASmartClient.Helper;
  11. using Microsoft.Toolkit.Mvvm.Input;
  12. using BPASmartClient.JXJFoodSmallStation.View;
  13. using BPASmartClient.JXJFoodSmallStation.Model;
  14. namespace BPASmartClient.JXJFoodSmallStation.ViewModel
  15. {
  16. public class DeviceListViewModel : ObservableObject
  17. {
  18. public DeviceListViewModel()
  19. {
  20. ChangeNameCommand = new RelayCommand<object>((o) =>
  21. {
  22. if (o != null && o is string str)
  23. {
  24. ChangeDeviceNameView cdn = new ChangeDeviceNameView();
  25. ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
  26. cdn.ShowDialog();
  27. }
  28. });
  29. devices = DeviceInquire.GetInstance.devices;
  30. foreach (var device in devices)
  31. {
  32. device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10;
  33. }
  34. devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));
  35. }
  36. public RelayCommand<object> ChangeNameCommand { get; set; }
  37. //public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>();
  38. public ObservableCollection<Devices> devices { get; set; }
  39. }
  40. public class Devices : ObservableObject
  41. {
  42. public int Serial { get { return _mSerial; } set { _mSerial = value; OnPropertyChanged(); } }
  43. private int _mSerial;
  44. public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
  45. private string _mIpAddress;
  46. public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
  47. private string _mDeviceName;
  48. }
  49. }