Skip to content

Commit d74db00

Browse files
authored
Barcode Add ForceHeight (#406)
1 parent cf8111e commit d74db00

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExample1.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
<MudGrid>
55
<MudItem xs="12" sm="8" Class="d-flex justify-center">
6-
<MudBarcode @ref="_barcode" @bind-Value="_qrValue" Width="_width" Height="_height" BarcodeFormat="_barcodeFormat" Clickable="_clickable" Color="@_color" BackgroundColor="@_backgroundColor" StrokeWidth="_strokeWidth" />
6+
<MudBarcode @ref="_barcode" @bind-Value="_qrValue" Width="_width" Height="_height" ForceHeight="_forceHeight" BarcodeFormat="_barcodeFormat" Clickable="_clickable" Color="@_color" BackgroundColor="@_backgroundColor" StrokeWidth="_strokeWidth" />
77
</MudItem>
88

99
<MudItem xs="12" sm="4">
10-
<MudStack Spacing="4">
10+
<MudStack Spacing="3">
1111
<MudTextField T="string" @bind-Value="_qrValue" Label="Value" Variant="Variant.Outlined" Immediate="true" Margin="Margin.Dense" />
1212
<MudNumericField @bind-Value="_width" Label="Width" Variant="Variant.Outlined" Margin="Margin.Dense" />
1313
<MudNumericField @bind-Value="_height" Label="Height" Variant="Variant.Outlined" Margin="Margin.Dense" />
14+
<MudNumericField @bind-Value="_forceHeight" Label="ForceHeight" Variant="Variant.Outlined" Margin="Margin.Dense" />
1415
<MudSelectExtended ItemCollection="@(Enum.GetValues<BarcodeFormat>())" @bind-Value="_barcodeFormat" Label="Barcode Format" Variant="Variant.Outlined" Margin="Margin.Dense" Dense="true" />
1516
<MudText Color="Color.Error">@(_barcode?.ErrorText == null ? null : "Error: " + _barcode.ErrorText)</MudText>
1617
<MudSwitchM3 @bind-Value="_clickable" Color="Color.Secondary" Label="Clickable" />
@@ -26,6 +27,7 @@
2627
string? _qrValue;
2728
int _width = 200;
2829
int _height = 200;
30+
int _forceHeight = 1;
2931
BarcodeFormat _barcodeFormat = BarcodeFormat.QR_CODE;
3032
bool _clickable = false;
3133
string _color = "black";

CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExampleIntro.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
<MudGrid>
44
<MudAlert Class="mud-width-full" Severity="Severity.Success"><b>If you feel barcode readers response slowly, increase the <CodeBlock>StrokeWidth</CodeBlock> value for a better read performance.</b></MudAlert>
5-
<MudAlert Class="mud-width-full" Severity="Severity.Success"><b>You can independently set height and width, but for some barcode formats like QR, the component have to has same width and height (square sized).</b></MudAlert>
5+
<MudAlert Class="mud-width-full" Severity="Severity.Success"><b>You can independently set height and width, but for some barcode formats like QR, the component have to has same width and height (square sized). Use <CodeBlock>ForceHeight</CodeBlock> to set height for some barcode types like UPC_A and UPC_E.</b></MudAlert>
66
<MudAlert Class="mud-width-full" Severity="Severity.Success"><b>Remember that although you can freely specify colors, can get the best results with the highest contrast.</b></MudAlert>
77
</MudGrid>

CodeBeam.MudBlazor.Extensions/Components/Barcode/MudBarcode.razor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ public partial class MudBarcode : MudComponentBase
4141
[Parameter]
4242
public int Height { get; set; } = 200;
4343

44+
/// <summary>
45+
/// Use this value on not square sized barcode formats like UPC_A and UPC_E.
46+
/// </summary>
47+
[Parameter]
48+
public int ForceHeight { get; set; } = 1;
49+
4450
/// <summary>
4551
/// Increase the stroke width if readers can not read the barcode easily.
4652
/// </summary>
@@ -92,7 +98,7 @@ public partial class MudBarcode : MudComponentBase
9298
{
9399
var matrix = Encoder.encode(Value, BarcodeFormat, 0, 0);
94100

95-
var result = new BarcodeResult(matrix, 1, 1);
101+
var result = new BarcodeResult(matrix, 1, ForceHeight);
96102
ErrorText = null;
97103
return result;
98104
}

0 commit comments

Comments
 (0)