EncodingOptions.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright 2012 ZXing.Net authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. namespace FastReport.Barcode.Aztec
  20. {
  21. /// <summary>
  22. /// Defines an container for encoder options
  23. /// </summary>
  24. [Serializable]
  25. internal class EncodingOptions
  26. {
  27. IDictionary<EncodeHintType, object> hints;
  28. /// <summary>
  29. /// Gets the data container for all options
  30. /// </summary>
  31. [Browsable(false)]
  32. public IDictionary<EncodeHintType, object> Hints
  33. {
  34. get { return hints; }
  35. }
  36. /// <summary>
  37. /// Specifies the height of the barcode image
  38. /// </summary>
  39. public int Height
  40. {
  41. get
  42. {
  43. if (Hints.ContainsKey(EncodeHintType.HEIGHT))
  44. {
  45. return (int)Hints[EncodeHintType.HEIGHT];
  46. }
  47. return 0;
  48. }
  49. set
  50. {
  51. Hints[EncodeHintType.HEIGHT] = value;
  52. }
  53. }
  54. /// <summary>
  55. /// Specifies the width of the barcode image
  56. /// </summary>
  57. public int Width
  58. {
  59. get
  60. {
  61. if (Hints.ContainsKey(EncodeHintType.WIDTH))
  62. {
  63. return (int)Hints[EncodeHintType.WIDTH];
  64. }
  65. return 0;
  66. }
  67. set
  68. {
  69. Hints[EncodeHintType.WIDTH] = value;
  70. }
  71. }
  72. /// <summary>
  73. /// Don't put the content string into the output image.
  74. /// </summary>
  75. public bool PureBarcode
  76. {
  77. get
  78. {
  79. if (Hints.ContainsKey(EncodeHintType.PURE_BARCODE))
  80. {
  81. return (bool)Hints[EncodeHintType.PURE_BARCODE];
  82. }
  83. return false;
  84. }
  85. set
  86. {
  87. Hints[EncodeHintType.PURE_BARCODE] = value;
  88. }
  89. }
  90. /// <summary>
  91. /// Specifies margin, in pixels, to use when generating the barcode. The meaning can vary
  92. /// by format; for example it controls margin before and after the barcode horizontally for
  93. /// most 1D formats.
  94. /// </summary>
  95. public int Margin
  96. {
  97. get
  98. {
  99. if (Hints.ContainsKey(EncodeHintType.MARGIN))
  100. {
  101. return (int) Hints[EncodeHintType.MARGIN];
  102. }
  103. return 0;
  104. }
  105. set
  106. {
  107. Hints[EncodeHintType.MARGIN] = value;
  108. }
  109. }
  110. /// <summary>
  111. /// Initializes a new instance of the <see cref="EncodingOptions"/> class.
  112. /// </summary>
  113. public EncodingOptions()
  114. {
  115. hints = new Dictionary<EncodeHintType, object>();
  116. }
  117. }
  118. }