StandItem.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using MeterVision.db;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MeterVision.model
  10. {
  11. //标准模板目录
  12. public class StandItem : INotifyPropertyChanged
  13. {
  14. public event PropertyChangedEventHandler PropertyChanged;
  15. protected void OnPropertyChanged(string propertyName)
  16. {
  17. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  18. }
  19. private int _index;
  20. public int Index
  21. {
  22. get => _index;
  23. set
  24. {
  25. if (_index != value)
  26. {
  27. _index = value;
  28. OnPropertyChanged(nameof(Index));
  29. }
  30. }
  31. }
  32. public string StandId { get; set; }
  33. public string CreateTime { get; set; }
  34. public string StandTime => GetStandTime();
  35. private string _standName;
  36. public string StandName
  37. {
  38. get => _standName;
  39. set
  40. {
  41. if(_standName != value)
  42. {
  43. _standName = value;
  44. OnPropertyChanged(nameof(StandName));
  45. }
  46. }
  47. }
  48. public int StandType { get; set; }
  49. public string StandTypeName
  50. {
  51. get
  52. {
  53. //return StandType == 1 ? "自定义" :
  54. // (StandType == 2 ? "导入" : string.Empty);
  55. return StandType == 1 ? "⚙️[自建模板]" : " 📊[导入Excel]";
  56. //(StandType == 2 ? "导入" : string.Empty);
  57. }
  58. }
  59. public string StandTypeNameColor
  60. {
  61. get
  62. {
  63. return StandType == 1 ? "#007BFF" : "#28A745";
  64. }
  65. }
  66. private int _standCount;
  67. public int StandCount
  68. {
  69. get => _standCount;
  70. set
  71. {
  72. if(_standCount != value)
  73. {
  74. _standCount = value;
  75. OnPropertyChanged(nameof(StandCount));
  76. }
  77. }
  78. }
  79. //标准模板的文件全路径+文件名称
  80. public string StandFile { get; set; }
  81. public string StandFileName
  82. {
  83. get
  84. {
  85. if (StandFile != String.Empty)
  86. {
  87. return ThisApp.GetFileNameWithoutExtension(StandFile);
  88. }
  89. return string.Empty;
  90. }
  91. }
  92. private string GetStandTime()
  93. {
  94. if(CreateTime != string.Empty)
  95. {
  96. return ThisApp.ConvertDateFormat(CreateTime);
  97. }
  98. return string.Empty;
  99. }
  100. public StandItem()
  101. {
  102. }
  103. public StandItem(VStand vStand)
  104. {
  105. this.StandId = vStand.StandId;
  106. this.CreateTime = vStand.CreateTime;
  107. this.StandName = vStand.StandName;
  108. this.StandType = vStand.StandType;
  109. this.StandFile = vStand.StandFile;
  110. this.StandCount = vStand.StandCount;
  111. }
  112. ///////////////////////////////////////////
  113. }
  114. }