Added loading progress display for modlist images in gallery

This commit is contained in:
Justin Swanson 2020-01-16 23:18:35 -06:00
parent f8c640467f
commit 3ed80d1aba
3 changed files with 18 additions and 3 deletions

View File

@ -45,6 +45,9 @@ namespace Wabbajack
private readonly ObservableAsPropertyHelper<BitmapImage> _Image;
public BitmapImage Image => _Image.Value;
private readonly ObservableAsPropertyHelper<bool> _LoadingImage;
public bool LoadingImage => _LoadingImage.Value;
public ModListMetadataVM(ModListGalleryVM parent, ModlistMetadata metadata)
{
_parent = parent;
@ -121,9 +124,16 @@ namespace Wabbajack
})
.ToGuiProperty(this, nameof(Exists));
_Image = Observable.Return(Metadata.Links.ImageUri)
.DownloadBitmapImage((ex) => Utils.Log($"Error downloading modlist image {Metadata.Title}"))
var imageObs = Observable.Return(Metadata.Links.ImageUri)
.DownloadBitmapImage((ex) => Utils.Log($"Error downloading modlist image {Metadata.Title}"));
_Image = imageObs
.ToGuiProperty(this, nameof(Image));
_LoadingImage = imageObs
.Select(x => false)
.StartWith(true)
.ToGuiProperty(this, nameof(LoadingImage));
}
private Task Download()

View File

@ -86,6 +86,7 @@
BorderBrush="{StaticResource ButtonNormalBorder}"
BorderThickness="0,0,0,1">
<Grid ClipToBounds="True">
<mahapps:ProgressRing x:Name="LoadingProgress" />
<Viewbox
Height="340"
HorizontalAlignment="Center"
@ -119,7 +120,7 @@
<Ellipse.Style>
<Style TargetType="Ellipse">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type Button}}}" Value="True">
<DataTrigger Binding="{Binding IsMouseOver, ElementName=ModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>

View File

@ -54,6 +54,10 @@ namespace Wabbajack
this.WhenAny(x => x.ViewModel.Image)
.BindToStrict(this, x => x.ModListImage.Source)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.LoadingImage)
.Select(x => x ? Visibility.Visible : Visibility.Collapsed)
.BindToStrict(this, x => x.LoadingProgress.Visibility)
.DisposeWith(dispose);
});
}
}