Added version display to main window

This commit is contained in:
Justin Swanson 2019-12-14 17:31:53 -06:00
parent ebd5e4183a
commit e6c98fc3eb
2 changed files with 33 additions and 0 deletions

View File

@ -3,11 +3,13 @@ using DynamicData.Binding;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.Diagnostics;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Wabbajack.Common;
using Wabbajack.Common.StatusFeed;
@ -38,6 +40,9 @@ namespace Wabbajack
public readonly UserInterventionHandlers UserInterventionHandlers;
public Dispatcher ViewDispatcher { get; set; }
public ICommand CopyVersionCommand { get; }
public string VersionDisplay { get; }
public MainWindowVM(MainWindow mainWindow, MainSettings settings)
{
MainWindow = mainWindow;
@ -79,6 +84,22 @@ namespace Wabbajack
// Start on mode selection
ActivePane = ModeSelectionVM;
}
try
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
VersionDisplay = $"v{fvi.FileVersion}";
}
catch (Exception ex)
{
Utils.Error(ex);
VersionDisplay = "ERROR";
}
CopyVersionCommand = ReactiveCommand.Create(() =>
{
Clipboard.SetText($"Wabbajack {VersionDisplay}\n{ThisAssembly.Git.Sha}");
});
}
private static bool IsStartingFromModlist(out string modlistPath)

View File

@ -38,4 +38,16 @@
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
<mahapps:MetroWindow.RightWindowCommands>
<mahapps:WindowCommands>
<Button Command="{Binding CopyVersionCommand}" Content="{Binding VersionDisplay}">
<Button.ToolTip>
<TextBlock>
Wabbajack Version<LineBreak />
Click to copy to clipboard</TextBlock>
</Button.ToolTip>
</Button>
</mahapps:WindowCommands>
</mahapps:MetroWindow.RightWindowCommands>
</mahapps:MetroWindow>