StandDetailItem.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using MeterVision.db;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MeterVision.model
  10. {
  11. public class StandDetailItem : INotifyPropertyChanged
  12. {
  13. public event PropertyChangedEventHandler PropertyChanged;
  14. public static Dictionary<int, double> LastUnitMapping = new Dictionary<int, double>
  15. {
  16. {0,0.0001 },
  17. {1,0.001 },
  18. {2,0.01 },
  19. {3,0.1 },
  20. {4,1 },
  21. {5,10 },
  22. {6,100 },
  23. {7,1000 },
  24. {8,10000 }
  25. };
  26. // 触发属性变更通知
  27. protected virtual void OnPropertyChanged(string propertyName)
  28. {
  29. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  30. }
  31. private int _index;
  32. public int Index
  33. {
  34. get => _index;
  35. set
  36. {
  37. if(_index != value)
  38. {
  39. _index = value;
  40. OnPropertyChanged(nameof(Index));
  41. }
  42. }
  43. }
  44. public string StandId { get; set; }
  45. public string StandDetailId { get; set; }
  46. public string SrcImage { get; set; }
  47. private string _standValue;
  48. public string StandValue
  49. {
  50. get => _standValue;
  51. set
  52. {
  53. if(_standValue != value)
  54. {
  55. _standValue = value;
  56. OnPropertyChanged(nameof(StandValue));
  57. }
  58. }
  59. }
  60. private string _stationId;
  61. public string StationId
  62. {
  63. get => _stationId;
  64. set
  65. {
  66. if(_stationId != value)
  67. {
  68. _stationId = value;
  69. OnPropertyChanged(nameof(StationId));
  70. }
  71. }
  72. }
  73. private string _deviceSn;
  74. public string DeviceSn
  75. {
  76. get => _deviceSn;
  77. set
  78. {
  79. if(_deviceSn != value)
  80. {
  81. _deviceSn = value;
  82. OnPropertyChanged(nameof(DeviceSn));
  83. }
  84. }
  85. }
  86. private string _sampleTime;
  87. public string SampleTime
  88. {
  89. get => _sampleTime;
  90. set
  91. {
  92. if(_sampleTime != value)
  93. {
  94. _sampleTime = value;
  95. OnPropertyChanged(nameof(SampleTime));
  96. }
  97. }
  98. }
  99. private int _numCount;
  100. public int NumCount
  101. {
  102. get => _numCount;
  103. set
  104. {
  105. if(_numCount != value)
  106. {
  107. _numCount = value;
  108. OnPropertyChanged(nameof(NumCount));
  109. }
  110. }
  111. }
  112. private int _lastUnit;
  113. public int LastUnit
  114. {
  115. get => _lastUnit;
  116. set
  117. {
  118. if(_lastUnit != value)
  119. {
  120. _lastUnit = value;
  121. OnPropertyChanged(nameof(LastUnit));
  122. OnPropertyChanged(nameof(LastUnitName));
  123. }
  124. }
  125. }
  126. public string LastUnitName
  127. {
  128. get
  129. {
  130. if(LastUnitMapping.TryGetValue(LastUnit,out double lastUnit))
  131. {
  132. return lastUnit + "";
  133. }
  134. return "";
  135. }
  136. }
  137. public StandDetailItem()
  138. {
  139. }
  140. public StandDetailItem(TStandDetail standDetail)
  141. {
  142. StandId = standDetail.StandId;
  143. StandDetailId = standDetail.StandDetailId;
  144. SrcImage = standDetail.SrcImage;
  145. StandValue = standDetail.StandValue;
  146. StationId = standDetail.StationId;
  147. SampleTime = standDetail.SampleTime;
  148. NumCount = standDetail.NumCount;
  149. LastUnit = standDetail.LastUnit;
  150. }
  151. ///////////////////////////////////////////////////////////
  152. }
  153. }