Browse Source

Add progress ring before image update

pull/5/head
Ionite 2 years ago
parent
commit
7660dba406
No known key found for this signature in database
  1. 12
      StabilityMatrix/TextToImagePage.xaml
  2. 16
      StabilityMatrix/ViewModels/TextToImageViewModel.cs

12
StabilityMatrix/TextToImagePage.xaml

@ -107,9 +107,21 @@
Width="500" />
</StackPanel>
<Grid Background="{DynamicResource ApplicationBackgroundBrush}" Grid.Row="1">
<ui:ProgressRing
Background="DarkRed"
Grid.Row="0"
Height="72"
HorizontalAlignment="Center"
IsIndeterminate="True"
Margin="8"
VerticalAlignment="Center"
Visibility="{Binding ProgressRingVisibility, FallbackValue=Collapsed}"
Width="72"
x:Name="ImageProgressRing" />
<Image
Margin="8"
Source="{Binding ImagePreview}"
Visibility="{Binding ImagePreviewVisibility, FallbackValue=Visible}"
d:DesignHeight="512"
d:DesignWidth="512" />
</Grid>

16
StabilityMatrix/ViewModels/TextToImageViewModel.cs

@ -23,6 +23,15 @@ public partial class TextToImageViewModel : ObservableObject
[ObservableProperty]
private bool isGenerating;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ProgressRingVisibility))]
[NotifyPropertyChangedFor(nameof(ImagePreviewVisibility))]
private bool isProgressRingActive;
public Visibility ProgressRingVisibility => IsProgressRingActive ? Visibility.Visible : Visibility.Collapsed;
public Visibility ImagePreviewVisibility => IsProgressRingActive ? Visibility.Collapsed : Visibility.Visible;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(ProgressBarVisibility))]
private int progressValue;
@ -63,6 +72,7 @@ public partial class TextToImageViewModel : ObservableObject
private void StopProgressTracking()
{
IsProgressRingActive = false;
ProgressValue = 0;
progressQueryTimer?.Stop();
}
@ -86,6 +96,9 @@ public partial class TextToImageViewModel : ObservableObject
var result = response.CurrentImage;
if (result != null)
{
// Stop indeterminate progress ring
IsProgressRingActive = false;
// Set preview image
var bitmap = Base64ToBitmap(result);
ImagePreview = bitmap;
}
@ -109,6 +122,9 @@ public partial class TextToImageViewModel : ObservableObject
[RelayCommand]
private async void TextToImageGenerate()
{
// Start indeterminate progress ring
IsProgressRingActive = true;
var request = new TextToImageRequest
{
Prompt = PositivePromptText,

Loading…
Cancel
Save