PatchItem.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using MeterVision.db;
  2. using MeterVision.Util;
  3. using System;
  4. using System.Collections.Generic;
  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 PatchItem : INotifyPropertyChanged
  12. {
  13. public event PropertyChangedEventHandler PropertyChanged;
  14. protected virtual void OnPropertyChanged(string propertyName)
  15. {
  16. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  17. }
  18. private int _index;
  19. public int Index
  20. {
  21. get => _index;
  22. set
  23. {
  24. if(_index != value)
  25. {
  26. _index = value;
  27. OnPropertyChanged(nameof(Index));
  28. }
  29. }
  30. }
  31. public string PatchId { get; set; }
  32. public string CreateTime { get; set; }
  33. public string CreateTimeName
  34. {
  35. get => ThisApp.ConvertDateFormat(CreateTime);
  36. }
  37. private string _patchName;
  38. public string PatchName
  39. {
  40. get => _patchName;
  41. set
  42. {
  43. if(_patchName != value)
  44. {
  45. _patchName = value;
  46. OnPropertyChanged(nameof(PatchName));
  47. }
  48. }
  49. }
  50. public string PatchNameColor => GetPatchNameColor();
  51. public string StandId { get; set; }
  52. public string StandName { get; set; }
  53. private int _detailCount;
  54. public int DetailCount
  55. {
  56. get => _detailCount;
  57. set
  58. {
  59. if(_detailCount != value)
  60. {
  61. _detailCount = value;
  62. OnPropertyChanged(nameof(DetailCount));
  63. }
  64. }
  65. }
  66. private int _runCount;
  67. public int RunCount
  68. {
  69. get => _runCount;
  70. set
  71. {
  72. if(_runCount != value)
  73. {
  74. _runCount = value;
  75. OnPropertyChanged(nameof(RunCount));
  76. OnPropertyChanged(nameof(RunRate));
  77. OnPropertyChanged(nameof(EqualRate));
  78. OnPropertyChanged(nameof(InvalidRate));
  79. OnPropertyChanged(nameof(ErrorRate));
  80. OnPropertyChanged(nameof(PatchState));
  81. OnPropertyChanged(nameof(PatchStateColor));
  82. }
  83. }
  84. }
  85. private string GetPatchNameColor()
  86. {
  87. /*if(RunCount == DetailCount)
  88. {
  89. return "DarkGreen";
  90. }
  91. else
  92. {
  93. return "#000000";
  94. }*/
  95. return "#000000";
  96. }
  97. //已完成识别率
  98. public float RunRate
  99. {
  100. //get => (float)RunCount / DetailCount; // * 100);
  101. get
  102. {
  103. if(DetailCount == 0)
  104. {
  105. return 0.0f;
  106. }
  107. else
  108. {
  109. return (float)RunCount / DetailCount; // * 100)
  110. }
  111. }
  112. }
  113. private int _equalCount;
  114. public int EqualCount
  115. {
  116. get => _equalCount;
  117. set
  118. {
  119. if(_equalCount != value)
  120. {
  121. _equalCount = value;
  122. OnPropertyChanged(nameof(EqualRate));
  123. OnPropertyChanged(nameof(EqualCount));
  124. }
  125. }
  126. }
  127. public float EqualRate
  128. {
  129. get
  130. {
  131. if(RunCount == 0)
  132. {
  133. return 0.0f;
  134. }
  135. else
  136. {
  137. return (float)EqualCount / RunCount; // * 100);
  138. }
  139. }
  140. }
  141. private int _invalidCount;
  142. public int InvalidCount
  143. {
  144. get => _invalidCount;
  145. set
  146. {
  147. if(_invalidCount != value)
  148. {
  149. _invalidCount = value;
  150. OnPropertyChanged(nameof(InvalidCount));
  151. OnPropertyChanged(nameof(InvalidRate));
  152. }
  153. }
  154. }
  155. //无效率
  156. public float InvalidRate
  157. {
  158. get
  159. {
  160. if(RunCount > 0)
  161. {
  162. return (float)InvalidCount / RunCount;
  163. }
  164. return 0.0f;
  165. }
  166. }
  167. public int _errorCount;
  168. public int ErrorCount
  169. {
  170. get => _errorCount;
  171. set
  172. {
  173. if(_errorCount != value)
  174. {
  175. _errorCount = value;
  176. OnPropertyChanged(nameof(ErrorCount));
  177. OnPropertyChanged(nameof(ErrorRate));
  178. }
  179. }
  180. }
  181. public float ErrorRate
  182. {
  183. get
  184. {
  185. if (RunCount > 0)
  186. {
  187. return (float)ErrorCount / RunCount;
  188. }
  189. return 0.0f;
  190. }
  191. }
  192. public string PatchState
  193. {
  194. get
  195. {
  196. if(RunCount == 0)
  197. {
  198. return "🔲[未开始]";
  199. }
  200. else if(RunCount < DetailCount)
  201. {
  202. return "⏳[进行中]";
  203. }
  204. else
  205. {
  206. return "✔️[已完成]";
  207. }
  208. }
  209. }
  210. public string PatchStateColor
  211. {
  212. get
  213. {
  214. if (RunCount == 0)
  215. {
  216. return "#6C757D";
  217. }
  218. else if (RunCount < DetailCount)
  219. {
  220. return "#FFC107";
  221. }
  222. else
  223. {
  224. return "#28A745";
  225. }
  226. }
  227. }
  228. public PatchItem()
  229. {
  230. PatchId = string.Empty;
  231. CreateTime = string.Empty;
  232. PatchName = string.Empty;
  233. StandId = string.Empty;
  234. StandName = string.Empty;
  235. DetailCount = 0;
  236. RunCount = 0;
  237. EqualCount = 0;
  238. }
  239. public PatchItem(VPatch vPatch)
  240. {
  241. ObjectHelper.CopyMatchingFields(vPatch, this);
  242. }
  243. /////////////////////////////////////////////////////
  244. }
  245. }