PatchItem.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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(PatchState));
  79. OnPropertyChanged(nameof(PatchStateColor));
  80. }
  81. }
  82. }
  83. private string GetPatchNameColor()
  84. {
  85. /*if(RunCount == DetailCount)
  86. {
  87. return "DarkGreen";
  88. }
  89. else
  90. {
  91. return "#000000";
  92. }*/
  93. return "#000000";
  94. }
  95. //已完成识别率
  96. public float RunRate
  97. {
  98. //get => (float)RunCount / DetailCount; // * 100);
  99. get
  100. {
  101. if(DetailCount == 0)
  102. {
  103. return 0.0f;
  104. }
  105. else
  106. {
  107. return (float)RunCount / DetailCount; // * 100)
  108. }
  109. }
  110. }
  111. private int _equalCount;
  112. public int EqualCount
  113. {
  114. get => _equalCount;
  115. set
  116. {
  117. if(_equalCount != value)
  118. {
  119. _equalCount = value;
  120. OnPropertyChanged(nameof(EqualRate));
  121. OnPropertyChanged(nameof(EqualCount));
  122. }
  123. }
  124. }
  125. public float EqualRate
  126. {
  127. get
  128. {
  129. if(RunCount == 0)
  130. {
  131. return 0.0f;
  132. }
  133. else
  134. {
  135. return (float)EqualCount / RunCount; // * 100);
  136. }
  137. }
  138. }
  139. public string PatchState
  140. {
  141. get
  142. {
  143. if(RunCount == 0)
  144. {
  145. return "🔲[未开始]";
  146. }
  147. else if(RunCount < DetailCount)
  148. {
  149. return "⏳[进行中]";
  150. }
  151. else
  152. {
  153. return "✔️[已完成]";
  154. }
  155. }
  156. }
  157. public string PatchStateColor
  158. {
  159. get
  160. {
  161. if (RunCount == 0)
  162. {
  163. return "#6C757D";
  164. }
  165. else if (RunCount < DetailCount)
  166. {
  167. return "#FFC107";
  168. }
  169. else
  170. {
  171. return "#28A745";
  172. }
  173. }
  174. }
  175. public PatchItem()
  176. {
  177. PatchId = string.Empty;
  178. CreateTime = string.Empty;
  179. PatchName = string.Empty;
  180. StandId = string.Empty;
  181. StandName = string.Empty;
  182. DetailCount = 0;
  183. RunCount = 0;
  184. EqualCount = 0;
  185. }
  186. public PatchItem(VPatch vPatch)
  187. {
  188. ObjectHelper.CopyMatchingFields(vPatch, this);
  189. }
  190. /////////////////////////////////////////////////////
  191. }
  192. }