-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathMudBarcode.razor
More file actions
36 lines (34 loc) · 1.51 KB
/
MudBarcode.razor
File metadata and controls
36 lines (34 loc) · 1.51 KB
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
32
33
34
35
36
@namespace MudExtensions
@inherits MudComponentBase
<div class="@OuterClass" style="@OuterStylename">
<a class="absolute mud-barcode-link" 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 Src="@EmptySrc" Height="Height" Width="Width" Class="@Class" Style="@Style" />
}
<div class="absolute mud-barcode-child" style="top:50%; left:50%; transform: translate(-50%, -50%)">
@ChildContent
</div>
</a>
</div>