mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add task bar status
This commit is contained in:
parent
87e0a59371
commit
8782aeca94
@ -14,4 +14,7 @@
|
||||
</blazor:BlazorWebView.RootComponents>
|
||||
</blazor:BlazorWebView>
|
||||
</Grid>
|
||||
<Window.TaskbarItemInfo>
|
||||
<TaskbarItemInfo x:Name="TaskBarItem"/>
|
||||
</Window.TaskbarItemInfo>
|
||||
</Window>
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.App.Blazor.Models;
|
||||
using Wabbajack.App.Blazor.State;
|
||||
using Wabbajack.App.Blazor.Utility;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Installer;
|
||||
@ -13,13 +14,25 @@ public partial class MainWindow
|
||||
private readonly ILogger<MainWindow> _logger;
|
||||
private readonly LoggerProvider _loggerProvider;
|
||||
private readonly SystemParametersConstructor _systemParams;
|
||||
private readonly GlobalState _globalState;
|
||||
|
||||
public MainWindow(ILogger<MainWindow> logger, IServiceProvider serviceProvider, LoggerProvider loggerProvider,
|
||||
SystemParametersConstructor systemParams)
|
||||
SystemParametersConstructor systemParams, GlobalState globalState)
|
||||
{
|
||||
_logger = logger;
|
||||
_loggerProvider = loggerProvider;
|
||||
_systemParams = systemParams;
|
||||
_globalState = globalState;
|
||||
|
||||
_globalState.OnTaskBarStateChange += state =>
|
||||
{
|
||||
Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
TaskBarItem.Description = state.Description;
|
||||
TaskBarItem.ProgressState = state.State;
|
||||
TaskBarItem.ProgressValue = state.ProgressValue;
|
||||
});
|
||||
};
|
||||
|
||||
InitializeComponent();
|
||||
BlazorWebView.Services = serviceProvider;
|
||||
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Shell;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Wabbajack.App.Blazor.State;
|
||||
@ -68,11 +69,20 @@ public partial class Gallery
|
||||
try
|
||||
{
|
||||
(IObservable<Percent> progress, Task task) = _maintainer.DownloadModlist(metadata);
|
||||
IDisposable dispose = progress.Subscribe(p => DownloadProgress = p);
|
||||
|
||||
GlobalState.SetTaskBarState(TaskbarItemProgressState.Indeterminate,$"Downloading {metadata.Title}");
|
||||
|
||||
var dispose = progress.Subscribe(p =>
|
||||
{
|
||||
DownloadProgress = p;
|
||||
GlobalState.SetTaskBarState(TaskbarItemProgressState.Indeterminate,$"Downloading {metadata.Title}", p.Value);
|
||||
});
|
||||
|
||||
await task;
|
||||
//await _wjClient.SendMetric("downloading", Metadata.Title);
|
||||
dispose.Dispose();
|
||||
GlobalState.SetTaskBarState();
|
||||
|
||||
|
||||
AbsolutePath path = KnownFolders.EntryPoint.Combine("downloaded_mod_lists", metadata.Links.MachineURL).WithExtension(Ext.Wabbajack);
|
||||
GlobalState.ModListPath = path;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Windows.Shell;
|
||||
using Wabbajack.DTOs;
|
||||
using Wabbajack.Paths;
|
||||
|
||||
@ -34,6 +35,18 @@ public class GlobalState
|
||||
public event Action OnModListChange;
|
||||
public event Action OnInstallStateChange;
|
||||
|
||||
public event Action<TaskBarState> OnTaskBarStateChange;
|
||||
|
||||
public void SetTaskBarState(TaskbarItemProgressState state = TaskbarItemProgressState.None, string description="", double progress = 0)
|
||||
{
|
||||
OnTaskBarStateChange?.Invoke(new TaskBarState
|
||||
{
|
||||
State = state,
|
||||
ProgressValue = progress,
|
||||
Description = description
|
||||
});
|
||||
}
|
||||
|
||||
public AbsolutePath ModListPath
|
||||
{
|
||||
get => _modListPath;
|
||||
|
10
Wabbajack.App.Blazor/State/TaskBarState.cs
Normal file
10
Wabbajack.App.Blazor/State/TaskBarState.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Windows.Shell;
|
||||
|
||||
namespace Wabbajack.App.Blazor.State;
|
||||
|
||||
public class TaskBarState
|
||||
{
|
||||
public string Description { get; set; }
|
||||
public double ProgressValue { get; set; }
|
||||
public TaskbarItemProgressState State { get; set; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user