Add active navigation bar color

This commit is contained in:
trawzified 2023-12-23 15:44:54 +01:00
parent e3301407fd
commit f77b29ec08
13 changed files with 100 additions and 110 deletions

View File

@ -2,18 +2,19 @@ using ReactiveUI;
namespace Wabbajack.Messages;
public enum ScreenType
{
Home,
ModListGallery,
Installer,
Settings,
Compiler,
ModListContents,
WebBrowser
}
public class NavigateToGlobal
{
public enum ScreenType
{
Home,
ModListGallery,
Installer,
Settings,
Compiler,
ModListContents,
WebBrowser
}
public ScreenType Screen { get; }

View File

@ -1,18 +0,0 @@
using ReactiveUI;
using System.Windows.Input;
using Wabbajack.Messages;
namespace Wabbajack.Models;
public abstract class ANavigationItem : INavigationItem
{
public ICommand GoToCommand { get; }
public virtual NavigateToGlobal.ScreenType Screen { get; }
public virtual bool MainMenuItem { get; }
public ANavigationItem()
{
GoToCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(Screen));
}
}

View File

@ -1,11 +0,0 @@
using System.Windows.Input;
using Wabbajack.Messages;
namespace Wabbajack.Models;
public interface INavigationItem
{
public ICommand GoToCommand { get; }
public NavigateToGlobal.ScreenType Screen { get; }
public bool MainMenuItem { get; }
}

View File

@ -1,24 +0,0 @@
using Wabbajack.Messages;
namespace Wabbajack.Models;
public class HomeNI : ANavigationItem
{
public override NavigateToGlobal.ScreenType Screen => NavigateToGlobal.ScreenType.Home;
public override bool MainMenuItem => true;
}
public class ModlistGalleryNI : ANavigationItem
{
public override NavigateToGlobal.ScreenType Screen => NavigateToGlobal.ScreenType.ModListGallery;
public override bool MainMenuItem => true;
}
public class CompileNI : ANavigationItem
{
public override NavigateToGlobal.ScreenType Screen => NavigateToGlobal.ScreenType.Compiler;
public override bool MainMenuItem => true;
}
public class SettingsNI : ANavigationItem
{
public override NavigateToGlobal.ScreenType Screen => NavigateToGlobal.ScreenType.Settings;
public override bool MainMenuItem => true;
}

View File

@ -26,6 +26,7 @@
<!-- Colors -->
<Color x:Key="WindowBackgroundColor">#222531</Color>
<Color x:Key="WindowHoverBackgroundColor">#2A2B41</Color>
<Color x:Key="DarkBackgroundColor">#3c3652</Color>
<Color x:Key="DarkHoverBackgroundColor">#4e4571</Color>
<Color x:Key="LightBackgroundColor">#424242</Color>
@ -118,6 +119,7 @@
<SolidColorBrush x:Key="DimForegroundBrush" Color="{StaticResource DimForegroundColor}" />
<SolidColorBrush x:Key="MouseOverForegroundBrush" Color="{StaticResource DarkBackgroundColor}" />
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="{StaticResource WindowBackgroundColor}" />
<SolidColorBrush x:Key="WindowHoverBackgroundBrush" Color="{StaticResource WindowHoverBackgroundColor}" />
<SolidColorBrush x:Key="BorderInterestBrush" Color="{StaticResource HeatedBorderColor}" />
<SolidColorBrush x:Key="HeatedBorderBrush" Color="{StaticResource HeatedBorderColor}" />
@ -1196,8 +1198,8 @@
<Style.Resources>
<Style TargetType="ic:SymbolIcon">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Button, AncestorLevel=1}, Path=IsMouseOver}" Value="True">
<Setter Property="IsFilled" Value="True" />
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=IsMouseOver}" Value="True">
<Setter Property="IsFilled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
@ -1260,7 +1262,29 @@
</Style>
</Style.Resources>
</Style>
<Style BasedOn="{StaticResource MainButtonStyle}" TargetType="{x:Type Button}" />
<Style x:Key="MainNavButtonStyle" BasedOn="{StaticResource MainButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Style.Resources>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource DarkHoverBackgroundBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</Style.Resources>
</Style>
<Style x:Key="ActiveNavButtonStyle" BasedOn="{StaticResource MainButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Background" Value="{StaticResource WindowHoverBackgroundBrush}"/>
<Setter Property="Foreground" Value="{StaticResource PrimaryBrush}"/>
<Style.Resources>
<Style TargetType="ic:SymbolIcon">
<Setter Property="IsFilled" Value="True"/>
</Style>
</Style.Resources>
</Style>
<Style
x:Key="CircleButtonStyle"

View File

@ -124,7 +124,7 @@ namespace Wabbajack
ReactiveCommand.CreateFromTask(async () =>
{
await SaveSettingsFile();
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home);
NavigateToGlobal.Send(ScreenType.Home);
});
SubCompilerVM = new MO2CompilerVM(this);

View File

@ -106,7 +106,7 @@ namespace Wabbajack
BackCommand = ReactiveCommand.Create(
() =>
{
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home);
NavigateToGlobal.Send(ScreenType.Home);
});

View File

@ -148,7 +148,7 @@ namespace Wabbajack
if (await _maintainer.HaveModList(Metadata))
{
LoadModlistForInstalling.Send(_maintainer.ModListPath(Metadata), Metadata);
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
NavigateToGlobal.Send(ScreenType.Installer);
}
else
{

View File

@ -27,7 +27,7 @@ namespace Wabbajack
public HomeVM(Client wjClient)
{
_wjClient = wjClient;
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModListGallery));
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.ModListGallery));
VisitModlistWizardCommand = ReactiveCommand.Create(() =>
{
ProcessStartInfo processStartInfo = new(Consts.WabbajackModlistWizardUri.ToString())

View File

@ -172,7 +172,7 @@ public class InstallerVM : BackNavigatingVM, IBackNavigatingVM, ICpuStatusVM
Installer = new MO2InstallerVM(this);
BackCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home));
BackCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.Home));
BeginCommand = ReactiveCommand.Create(() => BeginInstall().FireAndForget());

View File

@ -121,12 +121,12 @@ namespace Wabbajack
if (IsStartingFromModlist(out var path))
{
LoadModlistForInstalling.Send(path, null);
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
NavigateToGlobal.Send(ScreenType.Installer);
}
else
{
// Start on mode selection
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home);
NavigateToGlobal.Send(ScreenType.Home);
}
try
@ -223,18 +223,18 @@ namespace Wabbajack
window.Show();
}
private void HandleNavigateTo(NavigateToGlobal.ScreenType s)
private void HandleNavigateTo(ScreenType s)
{
if (s is NavigateToGlobal.ScreenType.Settings)
if (s is ScreenType.Settings)
PreviousPanes.Add(ActivePane);
ActivePane = s switch
{
NavigateToGlobal.ScreenType.Home => HomeVM,
NavigateToGlobal.ScreenType.ModListGallery => Gallery,
NavigateToGlobal.ScreenType.Installer => Installer,
NavigateToGlobal.ScreenType.Compiler => Compiler,
NavigateToGlobal.ScreenType.Settings => SettingsPane,
ScreenType.Home => HomeVM,
ScreenType.ModListGallery => Gallery,
ScreenType.Installer => Installer,
ScreenType.Compiler => Compiler,
ScreenType.Settings => SettingsPane,
_ => ActivePane
};
}
@ -271,20 +271,6 @@ namespace Wabbajack
}
}
/*
public void NavigateTo(ViewModel vm)
{
ActivePane = vm;
}*/
/*
public void NavigateTo<T>(T vm)
where T : ViewModel, IBackNavigatingVM
{
vm.NavigateBackTarget = ActivePane;
ActivePane = vm;
}*/
public async Task ShutdownApplication()
{
/*

View File

@ -26,35 +26,27 @@ namespace Wabbajack
{
private readonly ILogger<NavigationVM> _logger;
[Reactive]
public NavigateToGlobal.ScreenType ActiveScreen { get; set; }
[Reactive]
public List<INavigationItem> NavigationItems { get; set; }
public ScreenType ActiveScreen { get; set; }
public NavigationVM(ILogger<NavigationVM> logger)
{
_logger = logger;
HomeCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home));
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModListGallery));
HomeCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.Home));
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.ModListGallery));
InstallCommand = ReactiveCommand.Create(() =>
{
LoadLastLoadedModlist.Send();
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Installer);
NavigateToGlobal.Send(ScreenType.Installer);
});
CompileCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Compiler));
CompileCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.Compiler));
SettingsCommand = ReactiveCommand.Create(
/*
canExecute: this.WhenAny(x => x.ActivePane)
.Select(active => !object.ReferenceEquals(active, SettingsPane)),
*/
execute: () => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Settings));
execute: () => NavigateToGlobal.Send(ScreenType.Settings));
MessageBus.Current.Listen<NavigateToGlobal>()
.Subscribe(x => ActiveScreen = x.Screen);
/*
this.WhenActivated(dispose =>
{
this.WhenAny(x => x.ActiveScreen)
.
})
*/
.Subscribe(x => ActiveScreen = x.Screen)
.DisposeWith(CompositeDisposable);
var processLocation = Process.GetCurrentProcess().MainModule?.FileName ?? throw new Exception("Process location is unavailable!");
var assembly = Assembly.GetExecutingAssembly();
@ -62,6 +54,7 @@ namespace Wabbajack
var fvi = FileVersionInfo.GetVersionInfo(string.IsNullOrWhiteSpace(assemblyLocation) ? processLocation : assemblyLocation);
Version = $"{fvi.FileVersion}";
}
public ICommand HomeCommand { get; }
public ICommand BrowseCommand { get; }
public ICommand InstallCommand { get; }

View File

@ -1,5 +1,6 @@
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reactive.Disposables;
using System.Reactive.Linq;
@ -15,9 +16,16 @@ namespace Wabbajack
/// </summary>
public partial class NavigationView : ReactiveUserControl<NavigationVM>
{
public Dictionary<ScreenType, Button> ScreenButtonDictionary { get; set; }
public NavigationView()
{
InitializeComponent();
ScreenButtonDictionary = new() {
{ ScreenType.Home, HomeButton },
{ ScreenType.ModListGallery, BrowseButton },
{ ScreenType.Compiler, CompileButton },
{ ScreenType.Settings, SettingsButton },
};
this.WhenActivated(dispose =>
{
this.BindCommand(ViewModel, vm => vm.BrowseCommand, v => v.BrowseButton)
@ -33,6 +41,12 @@ namespace Wabbajack
.Select(version => $"v{version}")
.BindToStrict(this, v => v.VersionTextBlock.Text)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.ActiveScreen)
.Subscribe(x => SetActiveScreen(x))
.DisposeWith(dispose);
/*
this.WhenAny(x => x.ViewModel.InstallCommand)
.BindToStrict(this, x => x.InstallButton.Command)
@ -43,5 +57,30 @@ namespace Wabbajack
*/
});
}
private void SetActiveScreen(ScreenType activeScreen)
{
var activeButtonStyle = (Style)Application.Current.Resources["ActiveNavButtonStyle"];
var mainButtonStyle = (Style)Application.Current.Resources["MainNavButtonStyle"];
foreach(var (screen, button) in ScreenButtonDictionary)
{
if (screen == activeScreen)
button.Style = activeButtonStyle;
else
button.Style = mainButtonStyle;
}
}
/*
{
var activeStyle = (Style)Application.Current.Resources["ActiveButton"];
switch(x)
{
case ScreenType.Home:
HomeButton.Style = activeStyle;
default:
return;
}
}
*/
}
}