Sizing of buttons in game details has been adjusted. The button status now properly changes based on current item's state in queue.
80 lines
2.3 KiB
Text
80 lines
2.3 KiB
Text
@using LANCommander.Client.Models
|
|
@using System.Diagnostics
|
|
@inject DownloadService DownloadService
|
|
@inject SDK.Client Client
|
|
|
|
<footer>
|
|
<Space Direction="DirectionVHType.Horizontal" Style="width: 100%">
|
|
<SpaceItem Class="downloader" Style="flex-grow: 1">
|
|
@if (CurrentQueueItem != null)
|
|
{
|
|
<div>@CurrentQueueItem.Title</div>
|
|
<div>@CurrentQueueItem.Version</div>
|
|
<Progress Percent="(CurrentQueueItem.Progress * 100)" />
|
|
}
|
|
else
|
|
{
|
|
<div>Fallout 3</div>
|
|
<div>v1.0.0</div>
|
|
<Progress Percent="56" />
|
|
}
|
|
</SpaceItem>
|
|
|
|
<SpaceItem>
|
|
<Button Type="@ButtonType.Primary" OnClick="() => ShowDownloadQueue()">^</Button>
|
|
</SpaceItem>
|
|
</Space>
|
|
</footer>
|
|
|
|
<DownloadQueue @bind-Visible="@DownloadQueueVisible" />
|
|
|
|
@code {
|
|
IDownloadQueueItem CurrentQueueItem = null;
|
|
|
|
bool DownloadQueueVisible = false;
|
|
|
|
Stopwatch Stopwatch = new Stopwatch();
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
Client.Games.OnArchiveExtractionProgress += (long position, long length, SDK.Models.Game game) =>
|
|
{
|
|
if (!Stopwatch.IsRunning)
|
|
Stopwatch.Start();
|
|
|
|
if (Stopwatch.ElapsedMilliseconds > 500)
|
|
{
|
|
CurrentQueueItem = DownloadService.Queue.OrderByDescending(qi => qi.QueuedOn).FirstOrDefault(qi => qi.State);
|
|
|
|
CurrentQueueItem.BytesDownloaded = position;
|
|
CurrentQueueItem.TotalBytes = length;
|
|
|
|
InvokeAsync(StateHasChanged);
|
|
|
|
Stopwatch.Reset();
|
|
}
|
|
};
|
|
|
|
Client.Games.OnArchiveEntryExtractionProgress += (object sender, SDK.ArchiveEntryExtractionProgressArgs e) =>
|
|
{
|
|
// InvokeAsync(StateHasChanged);
|
|
};
|
|
|
|
DownloadService.OnInstallComplete += async () =>
|
|
{
|
|
Stopwatch.Stop();
|
|
};
|
|
|
|
DownloadService.OnQueueChanged += async () =>
|
|
{
|
|
CurrentQueueItem = DownloadService.Queue.OrderByDescending(qi => qi.QueuedOn).FirstOrDefault(qi => qi.State);
|
|
|
|
InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
|
|
async Task ShowDownloadQueue()
|
|
{
|
|
DownloadQueueVisible = true;
|
|
}
|
|
}
|