Skip to content

QrCodeExtensions

Namespace: Hex1b

Assembly: Hex1b.dll

Extension methods for creating and configuring instances using the fluent API.

csharp
public static class QrCodeExtensions

Inheritance

ObjectQrCodeExtensions

Methods

QrCode<TParent>(WidgetContext<TParent>, string)

Creates a with the specified data to encode.

Parameters:

  • ctx (WidgetContext<<TParent>>): The widget context.
  • data (String): The data to encode in the QR code (typically a URL).

Returns: QrCodeWidget

A new with a default quiet zone of 1.

csharp
public static QrCodeWidget QrCode<TParent>(this WidgetContext<TParent> ctx, string data) where TParent : Hex1bWidget

WithQuietZone(QrCodeWidget, int)

Sets the quiet zone (border) size for the QR code.

Parameters:

  • widget (QrCodeWidget): The QR code widget to configure.
  • quietZone (Int32): The number of module widths to use as a border. Use 0 to disable.

Returns: QrCodeWidget

A new with the specified quiet zone.

csharp
public static QrCodeWidget WithQuietZone(this QrCodeWidget widget, int quietZone)

Remarks

These methods enable concise QR code widget creation within widget builder callbacks. The primary use case is encoding URLs for display in terminal applications.

Examples

Using QrCode within a VStack:

csharp
ctx.VStack(v => [
    v.Text("Scan to visit:"),
    v.QrCode("https://github.com/mitchdenny/hex1b"),
    v.Text("GitHub Repository")
])

Released under the MIT License.