Fix progress bar updating in the Metadata VMs

This commit is contained in:
Timothy Baldridge 2019-11-29 16:01:17 -07:00
parent 70fead926f
commit 6f1d12a0e4
2 changed files with 26 additions and 6 deletions

View File

@ -64,11 +64,13 @@ namespace Wabbajack.View_Models
IsDownloading = true;
var queue = new WorkQueue(1);
var sub = queue.Status.Select(i => i.ProgressPercent).ToProperty(this, x => x.DownloadProgress);
DownloadStatusText = "Downloading";
var sub = queue.Status.Select(i => i.ProgressPercent).Subscribe(v => DownloadProgress = v);
queue.QueueTask(() =>
{
var downloader = DownloadDispatcher.ResolveArchive(Metadata.Links.Download);
downloader.Download(new Archive{ Name = Metadata.Title, Size = Metadata.DownloadMetadata?.Size ?? 0}, Location);
DownloadStatusText = "Hashing";
Location.FileHashCached();
IsDownloading = false;
sub.Dispose();
@ -108,6 +110,16 @@ namespace Wabbajack.View_Models
}
}
private string _downloadStatusText;
public string DownloadStatusText
{
get => _downloadStatusText;
private set
{
RaiseAndSetIfChanged(ref _downloadStatusText, value);
}
}
public DownloadStatus Status
{

View File

@ -43,7 +43,7 @@
<ColumnDefinition Width="300" />
<ColumnDefinition Width="20" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
@ -74,15 +74,21 @@
TextAlignment="Right" />
<TextBlock
Grid.Row="2"
Grid.Column="2"
Grid.Column="1"
Grid.ColumnSpan="3"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Text="{Binding Metadata.Description}"
TextWrapping="Wrap" />
<Button Grid.Row="3" Grid.ColumnSpan="5" Content="Download" Visibility="{Binding DownloadButtonVisibility}" Command="{Binding Click}" ></Button>
<Button Margin="5"
Grid.Row="3"
Grid.ColumnSpan="5"
Content="Download"
Visibility="{Binding DownloadButtonVisibility}"
Command="{Binding Click}" ></Button>
<mah:MetroProgressBar
Margin="5"
Grid.Row="3"
Grid.ColumnSpan="5"
Background="{StaticResource WindowBackgroundBrush}"
@ -92,6 +98,7 @@
Value="{Binding DownloadProgress, Mode=OneWay}"
Visibility="{Binding DownloadProgressVisibility}" />
<mah:MetroProgressBar
Margin="5"
Grid.Row="3"
Grid.ColumnSpan="5"
Background="Transparent"
@ -101,9 +108,10 @@
Opacity="{Binding DownloadProgress, Mode=OneWay}"
Value="{Binding DownloadProgress, Mode=OneWay}"
Visibility="{Binding DownloadProgressVisibility}" />
<Label Grid.Row="3"
<Label Margin="5"
Grid.Row="3"
Grid.ColumnSpan="5"
Content="Downloading..."
Content="{Binding DownloadStatusText}"
HorizontalContentAlignment="Center"
Visibility="{Binding DownloadProgressVisibility}" ></Label>