Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
@inherits MudComponentBase

<a href="@(Clickable ? Value : null)" target="@Target">
@{
@{
var content = GetCode();
}
@if (content != null)
{
<svg width="@Width" height="@Height" style="background-color:@BackgroundColor">
var viewBoxWidth = @content.ModuleSizeX * content.Columns;
var viewBoxHeight = @content.ModuleSizeY * content.Rows;

<svg width="@Width" height="@Height" style="background-color:@BackgroundColor" viewBox="0 0 @viewBoxWidth @viewBoxHeight">
@for (int y = 0; y < content.Rows; y++)
{
@for(int x = 0; x < content.Columns; x++)
@for (int x = 0; x < content.Columns; x++)
{
@if(content[x,y])
@if (content[x, y])
{
<rect class="d-flex align-center justify-center" width="@content.ModuleSizeX" height="@content.ModuleSizeY" style="@($"fill:{Color}; stroke-width:{StrokeWidth}px; stroke:{Color}")"
x="@(x * content.ModuleSizeX)" y="@(y * content.ModuleSizeY)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class MudBarcode : MudComponentBase
/// Increase the stroke width if readers can not read the barcode easily.
/// </summary>
[Parameter]
public int StrokeWidth { get; set; }
public double StrokeWidth { get; set; }

[Parameter]
public int Height { get; set; } = 200;
Expand Down Expand Up @@ -57,14 +57,9 @@ protected BarcodeResult GetCode()

try
{
var width = Width;
var height = Height;

var matrix = Encoder.encode(Value, BarcodeFormat, 0, 0);

var moduleSizeX = width / matrix.Width;
var moduleSizeY = height / matrix.Height;
var result = new BarcodeResult(matrix, moduleSizeX, moduleSizeY);
var result = new BarcodeResult(matrix, 1, 1);
ErrorText = null;
return result;
}
Expand Down