Skip to content

Commit 93fb6c9

Browse files
committed
Add XML comments on all public members where missing
1 parent 434e7be commit 93fb6c9

14 files changed

+927
-18
lines changed

QRCoder.Xaml/XamlQRCode.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,75 @@
55

66
namespace QRCoder.Xaml;
77

8+
/// <summary>
9+
/// Represents a QR code generator that outputs QR codes as XAML DrawingImage objects.
10+
/// </summary>
811
public class XamlQRCode : AbstractQRCode, IDisposable
912
{
1013
/// <summary>
1114
/// Constructor without params to be used in COM Objects connections
1215
/// </summary>
1316
public XamlQRCode() { }
1417

18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="XamlQRCode"/> class with the specified <see cref="QRCodeData"/>.
20+
/// </summary>
21+
/// <param name="data"><see cref="QRCodeData"/> generated by the QRCodeGenerator.</param>
1522
public XamlQRCode(QRCodeData data) : base(data) { }
1623

24+
/// <summary>
25+
/// Returns a XAML DrawingImage that contains the resulting QR code.
26+
/// </summary>
27+
/// <param name="pixelsPerModule">The number of pixels each dark/light module of the QR code will occupy in the final QR code image.</param>
28+
/// <returns>Returns the QR code graphic as a XAML DrawingImage.</returns>
1729
public DrawingImage GetGraphic(int pixelsPerModule)
1830
=> GetGraphic(pixelsPerModule, true);
1931

32+
/// <summary>
33+
/// Returns a XAML DrawingImage that contains the resulting QR code.
34+
/// </summary>
35+
/// <param name="pixelsPerModule">The number of pixels each dark/light module of the QR code will occupy in the final QR code image.</param>
36+
/// <param name="drawQuietZones">Indicates if quiet zones around the QR code should be drawn.</param>
37+
/// <returns>Returns the QR code graphic as a XAML DrawingImage.</returns>
2038
public DrawingImage GetGraphic(int pixelsPerModule, bool drawQuietZones)
2139
{
2240
var drawableModulesCount = GetDrawableModulesCount(drawQuietZones);
2341
var viewBox = new Size(pixelsPerModule * drawableModulesCount, pixelsPerModule * drawableModulesCount);
2442
return GetGraphic(viewBox, new SolidColorBrush(Colors.Black), new SolidColorBrush(Colors.White), drawQuietZones);
2543
}
2644

45+
/// <summary>
46+
/// Returns a XAML DrawingImage that contains the resulting QR code.
47+
/// </summary>
48+
/// <param name="viewBox">The size of the view box for the QR code.</param>
49+
/// <param name="drawQuietZones">Indicates if quiet zones around the QR code should be drawn.</param>
50+
/// <returns>Returns the QR code graphic as a XAML DrawingImage.</returns>
2751
public DrawingImage GetGraphic(Size viewBox, bool drawQuietZones = true)
2852
=> GetGraphic(viewBox, new SolidColorBrush(Colors.Black), new SolidColorBrush(Colors.White), drawQuietZones);
2953

54+
/// <summary>
55+
/// Returns a XAML DrawingImage that contains the resulting QR code with specified colors.
56+
/// </summary>
57+
/// <param name="pixelsPerModule">The number of pixels each dark/light module of the QR code will occupy in the final QR code image.</param>
58+
/// <param name="darkColorHex">The color of the dark modules in hexadecimal format.</param>
59+
/// <param name="lightColorHex">The color of the light modules in hexadecimal format.</param>
60+
/// <param name="drawQuietZones">Indicates if quiet zones around the QR code should be drawn.</param>
61+
/// <returns>Returns the QR code graphic as a XAML DrawingImage.</returns>
3062
public DrawingImage GetGraphic(int pixelsPerModule, string darkColorHex, string lightColorHex, bool drawQuietZones = true)
3163
{
3264
var drawableModulesCount = GetDrawableModulesCount(drawQuietZones);
3365
var viewBox = new Size(pixelsPerModule * drawableModulesCount, pixelsPerModule * drawableModulesCount);
3466
return GetGraphic(viewBox, new SolidColorBrush((Color)ColorConverter.ConvertFromString(darkColorHex)), new SolidColorBrush((Color)ColorConverter.ConvertFromString(lightColorHex)), drawQuietZones);
3567
}
3668

69+
/// <summary>
70+
/// Returns a XAML DrawingImage that contains the resulting QR code with specified brushes.
71+
/// </summary>
72+
/// <param name="viewBox">The size of the view box for the QR code.</param>
73+
/// <param name="darkBrush">The brush for the dark modules.</param>
74+
/// <param name="lightBrush">The brush for the light modules.</param>
75+
/// <param name="drawQuietZones">Indicates if quiet zones around the QR code should be drawn.</param>
76+
/// <returns>Returns the QR code graphic as a XAML DrawingImage.</returns>
3777
public DrawingImage GetGraphic(Size viewBox, Brush darkBrush, Brush lightBrush, bool drawQuietZones = true)
3878
{
3979
var drawableModulesCount = GetDrawableModulesCount(drawQuietZones);
@@ -67,6 +107,12 @@ public DrawingImage GetGraphic(Size viewBox, Brush darkBrush, Brush lightBrush,
67107
private int GetDrawableModulesCount(bool drawQuietZones = true)
68108
=> QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8);
69109

110+
/// <summary>
111+
/// Calculates the number of units per module for the given view box size.
112+
/// </summary>
113+
/// <param name="viewBox">The size of the view box for the QR code.</param>
114+
/// <param name="drawQuietZones">Indicates if quiet zones around the QR code should be drawn.</param>
115+
/// <returns>Returns the number of units per module.</returns>
70116
public double GetUnitsPerModule(Size viewBox, bool drawQuietZones = true)
71117
{
72118
var drawableModulesCount = GetDrawableModulesCount(drawQuietZones);
@@ -75,8 +121,25 @@ public double GetUnitsPerModule(Size viewBox, bool drawQuietZones = true)
75121
}
76122
}
77123

124+
/// <summary>
125+
/// Provides static methods for creating XAML DrawingImage QR codes.
126+
/// </summary>
78127
public static class XamlQRCodeHelper
79128
{
129+
/// <summary>
130+
/// Creates a XAML DrawingImage QR code with a single function call.
131+
/// </summary>
132+
/// <param name="plainText">The text or payload to be encoded inside the QR code.</param>
133+
/// <param name="pixelsPerModule">The number of pixels each dark/light module of the QR code will occupy in the final QR code image.</param>
134+
/// <param name="darkColorHex">The color of the dark modules in hexadecimal format.</param>
135+
/// <param name="lightColorHex">The color of the light modules in hexadecimal format.</param>
136+
/// <param name="eccLevel">The level of error correction data.</param>
137+
/// <param name="forceUtf8">Specifies whether the generator should be forced to work in UTF-8 mode.</param>
138+
/// <param name="utf8BOM">Specifies whether the byte-order-mark should be used.</param>
139+
/// <param name="eciMode">Specifies which ECI mode should be used.</param>
140+
/// <param name="requestedVersion">Sets the fixed QR code target version.</param>
141+
/// <param name="drawQuietZones">Indicates if quiet zones around the QR code should be drawn.</param>
142+
/// <returns>Returns the QR code graphic as a XAML DrawingImage.</returns>
80143
public static DrawingImage GetQRCode(string plainText, int pixelsPerModule, string darkColorHex, string lightColorHex, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, bool drawQuietZones = true)
81144
{
82145
using var qrGenerator = new QRCodeGenerator();

QRCoder/ASCIIQRCode.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public class AsciiQRCode : AbstractQRCode, IDisposable
1515
/// </summary>
1616
public AsciiQRCode() { }
1717

18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="AsciiQRCode"/> class with the specified <see cref="QRCodeData"/>.
20+
/// </summary>
21+
/// <param name="data">The QR code data generated by the <see cref="QRCodeGenerator"/>.</param>
1822
public AsciiQRCode(QRCodeData data) : base(data) { }
1923

2024

@@ -132,6 +136,21 @@ public string GetGraphicSmall(bool drawQuietZones = true, bool invert = false, s
132136
/// </summary>
133137
public static class AsciiQRCodeHelper
134138
{
139+
/// <summary>
140+
/// Generates an ASCII QR code graphic with specified parameters.
141+
/// </summary>
142+
/// <param name="plainText">The text to be encoded in the QR code.</param>
143+
/// <param name="pixelsPerModule">Number of repeated characters per module.</param>
144+
/// <param name="darkColorString">String representing dark modules.</param>
145+
/// <param name="whiteSpaceString">String representing light modules.</param>
146+
/// <param name="eccLevel">Error correction level for the QR code.</param>
147+
/// <param name="forceUtf8">Force UTF-8 encoding.</param>
148+
/// <param name="utf8BOM">Include UTF-8 byte order mark.</param>
149+
/// <param name="eciMode">Extended Channel Interpretation mode.</param>
150+
/// <param name="requestedVersion">Specific QR code version to use.</param>
151+
/// <param name="endOfLine">End of line separator.</param>
152+
/// <param name="drawQuietZones">Include quiet zones around the QR code.</param>
153+
/// <returns>ASCII representation of the QR code.</returns>
135154
public static string GetQRCode(string plainText, int pixelsPerModule, string darkColorString, string whiteSpaceString, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, string endOfLine = "\n", bool drawQuietZones = true)
136155
{
137156
using var qrGenerator = new QRCodeGenerator();
@@ -140,6 +159,19 @@ public static string GetQRCode(string plainText, int pixelsPerModule, string dar
140159
return qrCode.GetGraphic(pixelsPerModule, darkColorString, whiteSpaceString, drawQuietZones, endOfLine);
141160
}
142161

162+
/// <summary>
163+
/// Generates a small ASCII QR code graphic with specified parameters.
164+
/// </summary>
165+
/// <param name="plainText">The text to be encoded in the QR code.</param>
166+
/// <param name="eccLevel">Error correction level for the QR code.</param>
167+
/// <param name="forceUtf8">Force UTF-8 encoding.</param>
168+
/// <param name="utf8BOM">Include UTF-8 byte order mark.</param>
169+
/// <param name="eciMode">Extended Channel Interpretation mode.</param>
170+
/// <param name="requestedVersion">Specific QR code version to use.</param>
171+
/// <param name="endOfLine">End of line separator.</param>
172+
/// <param name="drawQuietZones">Include quiet zones around the QR code.</param>
173+
/// <param name="invert">Invert dark and light colors.</param>
174+
/// <returns>Minified ASCII representation of the QR code.</returns>
143175
public static string GetQRCode(string plainText, ECCLevel eccLevel, bool forceUtf8 = false, bool utf8BOM = false, EciMode eciMode = EciMode.Default, int requestedVersion = -1, string endOfLine = "\n", bool drawQuietZones = true, bool invert = true)
144176
{
145177
using var qrGenerator = new QRCodeGenerator();

QRCoder/ArtQRCode.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,14 @@ private Bitmap Resize(Bitmap image, int newSize)
236236
/// </summary>
237237
public enum QuietZoneStyle
238238
{
239+
/// <summary>
240+
/// Quiet zones are rendered with dotted modules.
241+
/// </summary>
239242
Dotted,
243+
244+
/// <summary>
245+
/// Quiet zones are rendered with flat, solid modules.
246+
/// </summary>
240247
Flat
241248
}
242249

@@ -245,7 +252,14 @@ public enum QuietZoneStyle
245252
/// </summary>
246253
public enum BackgroundImageStyle
247254
{
255+
/// <summary>
256+
/// Background image spans the complete graphic.
257+
/// </summary>
248258
Fill,
259+
260+
/// <summary>
261+
/// Background image is only painted in the data area, excluding the quiet zone.
262+
/// </summary>
249263
DataAreaOnly
250264
}
251265
}

QRCoder/Base64QRCode.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,22 +163,22 @@ private string BitmapToBase64(Bitmap bmp, ImageType imgType)
163163
/// </summary>
164164
public enum ImageType
165165
{
166+
/// <summary>
167+
/// Graphics Interchange Format (GIF) image format, a bitmap image format with limited color support
168+
/// </summary>
166169
#if NET6_0_OR_GREATER
167170
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
168171
#endif
172+
Gif,
169173
/// <summary>
170-
/// GIF image format.
174+
/// Joint Photographic Experts Group (JPEG) image format, a lossy compressed image format
171175
/// </summary>
172-
Gif,
173176
#if NET6_0_OR_GREATER
174177
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
175178
#endif
176-
/// <summary>
177-
/// JPEG image format.
178-
/// </summary>
179179
Jpeg,
180180
/// <summary>
181-
/// PNG image format.
181+
/// Portable Network Graphics (PNG) image format, a lossless raster graphics format
182182
/// </summary>
183183
Png
184184
}

0 commit comments

Comments
 (0)