Add Task Bar updates

This commit is contained in:
Timothy Baldridge 2021-12-31 16:58:09 -07:00
parent b9e44101aa
commit 3e8fbf0540
4 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,22 @@
using System.Windows.Shell;
using ReactiveUI;
namespace Wabbajack.Messages;
public class TaskBarUpdate
{
public string Description { get; init; }
public double ProgressValue { get; init; }
public TaskbarItemProgressState State { get; init; }
public static void Send(string description, TaskbarItemProgressState state = TaskbarItemProgressState.None,
double progressValue = 0)
{
MessageBus.Current.SendMessage(new TaskBarUpdate()
{
Description = description,
ProgressValue = progressValue,
State = state
});
}
}

View File

@ -11,6 +11,7 @@ using System.Reactive;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Shell;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.WindowsAPICodePack.Dialogs;
@ -203,6 +204,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
ModListImage = BitmapFrame.Create(await StandardInstaller.ModListImageStream(path));
StatusText = $"Install configuration for {ModList.Name}";
TaskBarUpdate.Send($"Loaded {ModList.Name}", TaskbarItemProgressState.Normal);
var hex = (await ModListLocation.TargetPath.ToString().Hash()).ToHex();
var prevSettings = await _settingsManager.Load<SavedInstallSettings>(InstallSettingsPrefix + hex);
@ -258,13 +260,17 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM
StatusText = update.StatusText;
StatusProgress = update.StepsProgress;
TaskBarUpdate.Send(update.StatusText, TaskbarItemProgressState.Indeterminate, update.StepsProgress.Value);
};
await installer.Begin(CancellationToken.None);
TaskBarUpdate.Send($"Finished install of {ModList.Name}", TaskbarItemProgressState.Normal);
InstallState = InstallState.Success;
}
catch (Exception ex)
{
TaskBarUpdate.Send($"Error during install of {ModList.Name}", TaskbarItemProgressState.Error);
InstallState = InstallState.Failure;
}

View File

@ -78,4 +78,7 @@
</Button>
</mahapps:WindowCommands>
</mahapps:MetroWindow.RightWindowCommands>
<Window.TaskbarItemInfo>
<TaskbarItemInfo x:Name="TaskbarItemInfo"></TaskbarItemInfo>
</Window.TaskbarItemInfo>
</mahapps:MetroWindow>

View File

@ -9,6 +9,7 @@ using ReactiveUI;
using Wabbajack.Common;
using Wabbajack;
using Wabbajack.LibCefHelpers;
using Wabbajack.Messages;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
using Wabbajack.Util;
@ -43,6 +44,14 @@ namespace Wabbajack
Environment.Exit(-1);
};
MessageBus.Current.Listen<TaskBarUpdate>()
.Subscribe(u =>
{
TaskbarItemInfo.Description = u.Description;
TaskbarItemInfo.ProgressValue = u.ProgressValue;
TaskbarItemInfo.ProgressState = u.State;
});
_logger.LogInformation("Wabbajack Build - {Sha}",ThisAssembly.Git.Sha);
_logger.LogInformation("Running in {EntryPoint}", KnownFolders.EntryPoint);