TestTemplate.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. //[JsonProperty(PropertyName = "Version", NullValueHandling = NullValueHandling.Ignore), JsonConverter(typeof(StringEnumConverter))]
  85. /// <summary>
  86. /// 当前模版信息
  87. /// </summary>
  88. public TemplateVersion ParsedVersion
  89. {
  90. get
  91. {
  92. return string.Equals(Version, V2, System.StringComparison.OrdinalIgnoreCase) ? TemplateVersion.V2 : TemplateVersion.V1;
  93. }
  94. set
  95. {
  96. Version = value == TemplateVersion.V2 ? "v2" : "";
  97. }
  98. }
  99. /// <summary>
  100. /// 模版dpi
  101. /// </summary>
  102. public int Dpi { get; set; }
  103. [JsonProperty(PropertyName = "answer_sheet")]
  104. public TestAnswerSheet[] AnswerSheets { get; set; }
  105. }
  106. }