From 4dd87dcec52b2829e1ddc03a16bc0d53f9bfcd35 Mon Sep 17 00:00:00 2001 From: mckaragoz <78308169+mckaragoz@users.noreply.github.com> Date: Wed, 22 May 2024 16:11:22 +0300 Subject: [PATCH] Barcode Add ForceHeight --- .../Components/Barcode/Examples/BarcodeExample1.razor | 6 ++++-- .../Components/Barcode/Examples/BarcodeExampleIntro.razor | 2 +- .../Components/Barcode/MudBarcode.razor.cs | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExample1.razor b/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExample1.razor index 67ad73fa..7df6e275 100644 --- a/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExample1.razor +++ b/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExample1.razor @@ -3,14 +3,15 @@ - + - + + @(_barcode?.ErrorText == null ? null : "Error: " + _barcode.ErrorText) @@ -26,6 +27,7 @@ string? _qrValue; int _width = 200; int _height = 200; + int _forceHeight = 1; BarcodeFormat _barcodeFormat = BarcodeFormat.QR_CODE; bool _clickable = false; string _color = "black"; diff --git a/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExampleIntro.razor b/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExampleIntro.razor index 1a202930..2bd39565 100644 --- a/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExampleIntro.razor +++ b/CodeBeam.MudBlazor.Extensions.Docs/Pages/Components/Barcode/Examples/BarcodeExampleIntro.razor @@ -2,6 +2,6 @@ If you feel barcode readers response slowly, increase the StrokeWidth value for a better read performance. - 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). + 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 ForceHeight to set height for some barcode types like UPC_A and UPC_E. Remember that although you can freely specify colors, can get the best results with the highest contrast. diff --git a/CodeBeam.MudBlazor.Extensions/Components/Barcode/MudBarcode.razor.cs b/CodeBeam.MudBlazor.Extensions/Components/Barcode/MudBarcode.razor.cs index d7e9ed47..add4dcbd 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/Barcode/MudBarcode.razor.cs +++ b/CodeBeam.MudBlazor.Extensions/Components/Barcode/MudBarcode.razor.cs @@ -41,6 +41,12 @@ public partial class MudBarcode : MudComponentBase [Parameter] public int Height { get; set; } = 200; + /// + /// Use this value on not square sized barcode formats like UPC_A and UPC_E. + /// + [Parameter] + public int ForceHeight { get; set; } = 1; + /// /// Increase the stroke width if readers can not read the barcode easily. /// @@ -92,7 +98,7 @@ public partial class MudBarcode : MudComponentBase { var matrix = Encoder.encode(Value, BarcodeFormat, 0, 0); - var result = new BarcodeResult(matrix, 1, 1); + var result = new BarcodeResult(matrix, 1, ForceHeight); ErrorText = null; return result; }