diff --git a/Wabbajack.App.Blazor/MainWindow.xaml b/Wabbajack.App.Blazor/MainWindow.xaml index 9d2a54c3..182bad5c 100644 --- a/Wabbajack.App.Blazor/MainWindow.xaml +++ b/Wabbajack.App.Blazor/MainWindow.xaml @@ -14,4 +14,7 @@ + + + diff --git a/Wabbajack.App.Blazor/MainWindow.xaml.cs b/Wabbajack.App.Blazor/MainWindow.xaml.cs index fe4315dc..4640cf57 100644 --- a/Wabbajack.App.Blazor/MainWindow.xaml.cs +++ b/Wabbajack.App.Blazor/MainWindow.xaml.cs @@ -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 _logger; private readonly LoggerProvider _loggerProvider; private readonly SystemParametersConstructor _systemParams; + private readonly GlobalState _globalState; public MainWindow(ILogger 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; diff --git a/Wabbajack.App.Blazor/Pages/Gallery.razor.cs b/Wabbajack.App.Blazor/Pages/Gallery.razor.cs index 9a432941..3802bcd6 100644 --- a/Wabbajack.App.Blazor/Pages/Gallery.razor.cs +++ b/Wabbajack.App.Blazor/Pages/Gallery.razor.cs @@ -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 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; diff --git a/Wabbajack.App.Blazor/State/GlobalState.cs b/Wabbajack.App.Blazor/State/GlobalState.cs index 3eaf32c5..f90985f1 100644 --- a/Wabbajack.App.Blazor/State/GlobalState.cs +++ b/Wabbajack.App.Blazor/State/GlobalState.cs @@ -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 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; diff --git a/Wabbajack.App.Blazor/State/TaskBarState.cs b/Wabbajack.App.Blazor/State/TaskBarState.cs new file mode 100644 index 00000000..02cc4ffb --- /dev/null +++ b/Wabbajack.App.Blazor/State/TaskBarState.cs @@ -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; } +}