终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

60 行
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. }