-
Notifications
You must be signed in to change notification settings - Fork 61
/
MudBarcode.razor
31 lines (29 loc) · 1.14 KB
/
MudBarcode.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@namespace MudExtensions
@inherits MudComponentBase
<a href="@(Clickable ? Value : null)" target="@Target">
@{
var content = GetCode();
}
@if (content != null)
{
var viewBoxWidth = @content.ModuleSizeX * content.Columns;
var viewBoxHeight = @content.ModuleSizeY * content.Rows;
<svg width="@Width" height="@Height" class="@Class" style="background-color:@BackgroundColor; @Style" viewBox="0 0 @viewBoxWidth @viewBoxHeight">
@for (int y = 0; y < content.Rows; y++)
{
@for (int x = 0; x < content.Columns; x++)
{
@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)" />
}
}
}
</svg>
}
else
{
<MudImage Height="Height" Width="Width" Class="@Class" Style="@Style" />
}
</a>