2023-11-02 01:24:42 -05:00
|
|
|
<div class="image-picker">
|
|
|
|
|
<div class="image-picker-images">
|
|
|
|
|
@foreach (var image in Images)
|
|
|
|
|
{
|
2024-01-12 02:25:41 -06:00
|
|
|
var id = Guid.NewGuid();
|
|
|
|
|
|
2023-11-02 19:27:50 -05:00
|
|
|
<div class="image-picker-image" style="width: @(Size)px; max-height: @(Size)px">
|
2024-01-12 02:25:41 -06:00
|
|
|
<input type="radio" id="image-picker-image-@id" checked="@(Value == image.Key)" name="SelectedResult" @onchange="@(() => SelectionChanged(image.Key))" />
|
2025-02-12 21:38:18 -06:00
|
|
|
<label for="image-picker-image-@id" @ondblclick="@(() => Pick(image.Key))"></label>
|
2023-11-02 01:24:42 -05:00
|
|
|
<img src="@image.Value" />
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter] public double Size { get; set; }
|
|
|
|
|
[Parameter] public string Value { get; set; }
|
|
|
|
|
[Parameter] public EventCallback<string> ValueChanged { get; set; }
|
2025-02-12 21:38:18 -06:00
|
|
|
[Parameter] public EventCallback<string> OnPicked { get; set; }
|
2023-11-02 01:24:42 -05:00
|
|
|
[Parameter] public Dictionary<string, string> Images { get; set; }
|
|
|
|
|
|
|
|
|
|
async Task SelectionChanged(string key)
|
|
|
|
|
{
|
|
|
|
|
Value = key;
|
|
|
|
|
|
|
|
|
|
if (ValueChanged.HasDelegate)
|
|
|
|
|
await ValueChanged.InvokeAsync(key);
|
|
|
|
|
}
|
2025-02-12 21:38:18 -06:00
|
|
|
|
|
|
|
|
async Task Pick(string key)
|
|
|
|
|
{
|
|
|
|
|
Value = key;
|
|
|
|
|
|
|
|
|
|
if (OnPicked.HasDelegate)
|
|
|
|
|
await OnPicked.InvokeAsync(key);
|
|
|
|
|
}
|
2023-11-02 01:24:42 -05:00
|
|
|
}
|