TestTemplate.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. using Newtonsoft.Json;
  2. //using OpenCvSharp;
  3. namespace DaJiaoYan.Models
  4. {
  5. public class TestTemplate
  6. {
  7. private const string V2 = "v2";
  8. public enum TemplateVersion
  9. {
  10. V1, V2
  11. }
  12. // {
  13. // "barcodeRect": {
  14. // "height": 394,
  15. // "width": 631,
  16. // "x": 953,
  17. // "y": 411
  18. // },
  19. // "card_size_type": 4,
  20. // "missedRect": {
  21. // "height": 20,
  22. // "width": 56,
  23. // "x": 702,
  24. // "y": 234
  25. // },
  26. // "nameRect": {
  27. // "height": 292,
  28. // "width": 492,
  29. // "x": 251,
  30. // "y": 233
  31. // },
  32. // "numberRect": {
  33. // "height": 154,
  34. // "width": 670,
  35. // "x": 839,
  36. // "y": 272
  37. // },
  38. // "temp_height": 2004,
  39. // "temp_rect": {
  40. // "height": 26,
  41. // "width": 48,
  42. // "x": 125,
  43. // "y": 126
  44. // },
  45. // "temp_width": 2937
  46. //}
  47. [JsonProperty(PropertyName = "barcodeRect", NullValueHandling = NullValueHandling.Ignore)]
  48. public Rect BarcodeRect { get; set; }
  49. [JsonProperty(PropertyName = "card_size_type")]
  50. public Enumerates.CardSizeType CardSizeType { get; set; }
  51. [JsonProperty(PropertyName = "missedRect", NullValueHandling = NullValueHandling.Ignore)]
  52. public Rect MissedRect { get; set; }
  53. [JsonProperty(PropertyName = "nameRect", NullValueHandling = NullValueHandling.Ignore)]
  54. public Rect NameRect { get; set; }
  55. [JsonProperty(PropertyName = "numberRect", NullValueHandling = NullValueHandling.Ignore)]
  56. public Rect NumberRect { get; set; }
  57. //[JsonProperty(PropertyName = "temp_rect", NullValueHandling = NullValueHandling.Ignore)]
  58. public TemplateRect TemplateRect { get; set; }
  59. /// <summary>
  60. /// 锚点内宽度
  61. /// </summary>
  62. [JsonProperty(PropertyName = "temp_width", NullValueHandling = NullValueHandling.Ignore)]
  63. public int TemplateWidth { get; set; }
  64. /// <summary>
  65. /// 锚点内高度
  66. /// </summary>
  67. [JsonProperty(PropertyName = "temp_height", NullValueHandling = NullValueHandling.Ignore)]
  68. public int TemplateHeight { get; set; }
  69. /// <summary>
  70. /// 锚点宽度
  71. /// </summary>
  72. [JsonProperty(PropertyName = "anchor_width", NullValueHandling = NullValueHandling.Ignore)]
  73. public int AnchorWidth { get; set; }
  74. /// <summary>
  75. /// 锚点高度
  76. /// </summary>
  77. [JsonProperty(PropertyName = "anchor_height", NullValueHandling = NullValueHandling.Ignore)]
  78. public int AnchorHeight { get; set; }
  79. /// <summary>
  80. /// 版本
  81. /// </summary>
  82. [JsonProperty(PropertyName = "version", NullValueHandling = NullValueHandling.Ignore)]
  83. public string Version { get; set; }
  84. /// <summary>
  85. /// 阅卷方式
  86. /// </summary>
  87. [JsonProperty(PropertyName = "marking_mode", NullValueHandling = NullValueHandling.Ignore)]
  88. public int MarkingMode { get; set; }
  89. //[JsonProperty(PropertyName = "Version", NullValueHandling = NullValueHandling.Ignore), JsonConverter(typeof(StringEnumConverter))]
  90. /// <summary>
  91. /// 当前模版信息
  92. /// </summary>
  93. public TemplateVersion ParsedVersion
  94. {
  95. get
  96. {
  97. return string.Equals(Version, V2, System.StringComparison.OrdinalIgnoreCase) ? TemplateVersion.V2 : TemplateVersion.V1;
  98. }
  99. set
  100. {
  101. Version = value == TemplateVersion.V2 ? "v2" : "";
  102. }
  103. }
  104. /// <summary>
  105. /// 模版dpi
  106. /// </summary>
  107. public int Dpi { get; set; }
  108. [JsonProperty(PropertyName = "answer_sheet")]
  109. public TestAnswerSheet[] AnswerSheets { get; set; }
  110. /// <summary>
  111. /// 是否在线阅卷
  112. /// </summary>
  113. /// <returns></returns>
  114. public bool MarkingOnLine
  115. {
  116. get
  117. {
  118. return MarkingMode == 0;
  119. }
  120. }
  121. }
  122. }