You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

QrCodeEncodingOptions.cs 3.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 ZXing.Common;
  18. using ZXing.QrCode.Internal;
  19. namespace ZXing.QrCode
  20. {
  21. /// <summary>
  22. /// The class holds the available options for the QrCodeWriter
  23. /// </summary>
  24. [Serializable]
  25. public class QrCodeEncodingOptions : EncodingOptions
  26. {
  27. /// <summary>
  28. /// Specifies what degree of error correction to use, for example in QR Codes.
  29. /// Type depends on the encoder. For example for QR codes it's type
  30. /// {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
  31. /// </summary>
  32. public ErrorCorrectionLevel ErrorCorrection
  33. {
  34. get
  35. {
  36. if (Hints.ContainsKey(EncodeHintType.ERROR_CORRECTION))
  37. {
  38. return (ErrorCorrectionLevel) Hints[EncodeHintType.ERROR_CORRECTION];
  39. }
  40. return null;
  41. }
  42. set
  43. {
  44. if (value == null)
  45. {
  46. if (Hints.ContainsKey(EncodeHintType.ERROR_CORRECTION))
  47. Hints.Remove(EncodeHintType.ERROR_CORRECTION);
  48. }
  49. else
  50. {
  51. Hints[EncodeHintType.ERROR_CORRECTION] = value;
  52. }
  53. }
  54. }
  55. /// <summary>
  56. /// Specifies what character encoding to use where applicable (type {@link String})
  57. /// </summary>
  58. public string CharacterSet
  59. {
  60. get
  61. {
  62. if (Hints.ContainsKey(EncodeHintType.CHARACTER_SET))
  63. {
  64. return (string) Hints[EncodeHintType.CHARACTER_SET];
  65. }
  66. return null;
  67. }
  68. set
  69. {
  70. if (value == null)
  71. {
  72. if (Hints.ContainsKey(EncodeHintType.CHARACTER_SET))
  73. Hints.Remove(EncodeHintType.CHARACTER_SET);
  74. }
  75. else
  76. {
  77. Hints[EncodeHintType.CHARACTER_SET] = value;
  78. }
  79. }
  80. }
  81. /// <summary>
  82. /// Explicitly disables ECI segment when generating QR Code
  83. /// That is against the specification of QR Code but some
  84. /// readers have problems if the charset is switched from
  85. /// ISO-8859-1 (default) to UTF-8 with the necessary ECI segment.
  86. /// If you set the property to true you can use UTF-8 encoding
  87. /// and the ECI segment is omitted.
  88. /// </summary>
  89. public bool DisableECI
  90. {
  91. get
  92. {
  93. if (Hints.ContainsKey(EncodeHintType.DISABLE_ECI))
  94. {
  95. return (bool)Hints[EncodeHintType.DISABLE_ECI];
  96. }
  97. return false;
  98. }
  99. set
  100. {
  101. Hints[EncodeHintType.DISABLE_ECI] = value;
  102. }
  103. }
  104. }
  105. }