终端一体化运控平台
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.
 
 
 

60 line
1.9 KiB

  1. using BPA.Helper;
  2. using BPASmartClient.DosingSystem.View;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. namespace BPASmartClient.DosingSystem.ViewModel
  8. {
  9. public class DeviceListViewModel : ViewModelBase
  10. {
  11. public DeviceListViewModel()
  12. {
  13. DetailsCommand = new BPARelayCommand<object>((o) =>
  14. {
  15. if (o != null && o is string str)
  16. {
  17. ChangeDeviceNameView cdn = new ChangeDeviceNameView();
  18. ActionManage.GetInstance.Send("ChangeDeviceNameViewOpen", str);
  19. cdn.ShowDialog();
  20. }
  21. });
  22. //devices = DeviceInquire.GetInstance.devices;
  23. //2023/6/29新加 改为升序排列显示
  24. devices = ConvertToObservableCollention(DeviceInquire.GetInstance.devices.OrderByDescending(p => p.IpAddress.Split(".")[3]).Reverse());
  25. }
  26. public ObservableCollection<Devices> devices { get; set; }
  27. public ObservableCollection<T> ConvertToObservableCollention<T>(IEnumerable<T> array)
  28. {
  29. ObservableCollection<T> collec = new ObservableCollection<T>();
  30. foreach (var item in array)
  31. {
  32. collec.Add(item);
  33. }
  34. return collec;
  35. }
  36. }
  37. public class Devices : NotifyBase
  38. {
  39. public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
  40. private string _mIpAddress;
  41. /// <summary>
  42. /// 设备编号
  43. /// </summary>
  44. public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } }
  45. private int _mDeviceNum;
  46. public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
  47. private string _mDeviceName;
  48. }
  49. }