web UI
This commit is contained in:
71
VisionBuilder.UI.Blazor/Dialogs/ImagePreviewDialog.razor
Normal file
71
VisionBuilder.UI.Blazor/Dialogs/ImagePreviewDialog.razor
Normal file
@@ -0,0 +1,71 @@
|
||||
@using MudBlazor
|
||||
@implements IDisposable
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
@if (ViewModel != null)
|
||||
{
|
||||
<div class="image-preview-dialog">
|
||||
@{
|
||||
var imageUri = ViewModel.ImageAnalysis?.ToBase64DataUri();
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(imageUri))
|
||||
{
|
||||
<img src="@imageUri" alt="@ViewModel.ImageName" class="image-preview-img" />
|
||||
}
|
||||
<div class="image-preview-info">
|
||||
<MudText Typo="Typo.subtitle1">@ViewModel.ImageName</MudText>
|
||||
</div>
|
||||
<div class="image-preview-actions">
|
||||
<MudButton Variant="Variant.Outlined" Disabled="@(!ViewModel.IsPreviousImageEnabled)"
|
||||
OnClick="OnPrevious">Previous</MudButton>
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
OnClick="OnSwitchView">@(ViewModel.OriginalView ? "Analysis" : "Original")</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Disabled="@(!ViewModel.IsNextImageEnabled)"
|
||||
OnClick="OnNext">Next</MudButton>
|
||||
@if (ViewModel.LearnButtonVisible)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||
OnClick="OnLearn">Learn</MudButton>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Close">Close</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
[Parameter] public ErrorPreviewVM? ViewModel { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (ViewModel != null)
|
||||
ViewModel.PropertyChanged += OnPropertyChanged;
|
||||
}
|
||||
|
||||
private async void OnPropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private void OnPrevious() => ViewModel?.PreviousImageCommand.Execute(null);
|
||||
private void OnNext() => ViewModel?.NextImageCommand.Execute(null);
|
||||
private void OnSwitchView() => ViewModel?.SwitchViewCommand.Execute(null);
|
||||
private async Task OnLearn()
|
||||
{
|
||||
if (ViewModel != null)
|
||||
await ViewModel.Learn();
|
||||
}
|
||||
|
||||
private void Close() => MudDialog.Close();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (ViewModel != null)
|
||||
ViewModel.PropertyChanged -= OnPropertyChanged;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user