Rename View_Models to ViewModels, busy restructuring NavigationItems

This commit is contained in:
trawzified 2023-12-23 11:36:22 +01:00
parent 240e643567
commit e3301407fd
47 changed files with 270 additions and 49 deletions

12
; Normal file
View File

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

View File

@ -168,7 +168,7 @@ namespace Wabbajack
services.AddTransient<CompilerVM>();
services.AddTransient<InstallerVM>();
services.AddTransient<ModeSelectionVM>();
services.AddTransient<HomeVM>();
services.AddTransient<ModListGalleryVM>();
services.AddTransient<CompilerVM>();
services.AddTransient<InstallerVM>();

View File

@ -6,7 +6,7 @@ public class NavigateToGlobal
{
public enum ScreenType
{
ModeSelectionView,
Home,
ModListGallery,
Installer,
Settings,

View File

@ -0,0 +1,18 @@
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

@ -0,0 +1,11 @@
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

@ -0,0 +1,24 @@
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;
}

File diff suppressed because one or more lines are too long

View File

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

View File

@ -1,13 +1,13 @@
<reactiveUi:ReactiveUserControl x:Class="Wabbajack.View_Models.Controls.RemovableItemView"
<reactiveUi:ReactiveUserControl x:Class="Wabbajack.ViewModels.Controls.RemovableItemView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wabbajack.View_Models.Controls"
xmlns:local="clr-namespace:Wabbajack.ViewModels.Controls"
x:TypeArguments="controls:RemovableItemViewModel"
xmlns:reactiveUi="http://reactiveui.net"
xmlns:controls="clr-namespace:Wabbajack.View_Models.Controls"
xmlns:controls="clr-namespace:Wabbajack.ViewModels.Controls"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
mc:Ignorable="d"
d:DesignHeight="28" d:DesignWidth="300">

View File

@ -2,7 +2,7 @@ using System.Reactive.Disposables;
using System.Windows.Controls;
using ReactiveUI;
namespace Wabbajack.View_Models.Controls;
namespace Wabbajack.ViewModels.Controls;
public partial class RemovableItemView : ReactiveUserControl<RemovableItemViewModel>
{

View File

@ -1,7 +1,7 @@
using System;
using ReactiveUI.Fody.Helpers;
namespace Wabbajack.View_Models.Controls;
namespace Wabbajack.ViewModels.Controls;
public class RemovableItemViewModel : ViewModel
{

View File

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

View File

@ -19,14 +19,15 @@ using System.Diagnostics;
namespace Wabbajack
{
public class ModeSelectionVM : ViewModel
public class HomeVM : ViewModel
{
private readonly ILogger<ModeSelectionVM> _logger;
private readonly ILogger<HomeVM> _logger;
private readonly Client _wjClient;
public ModeSelectionVM(Client wjClient)
public HomeVM(Client wjClient)
{
_wjClient = wjClient;
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModListGallery));
VisitModlistWizardCommand = ReactiveCommand.Create(() =>
{
ProcessStartInfo processStartInfo = new(Consts.WabbajackModlistWizardUri.ToString())
@ -48,6 +49,7 @@ namespace Wabbajack
});
}
public ICommand VisitModlistWizardCommand { get; }
public ICommand BrowseCommand { get; }
public ReactiveCommand<Unit, Unit> UpdateCommand { get; }
[Reactive]

View File

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

View File

@ -24,7 +24,7 @@ using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
using Wabbajack.UserIntervention;
using Wabbajack.View_Models;
using Wabbajack.ViewModels;
namespace Wabbajack
{
@ -48,7 +48,7 @@ namespace Wabbajack
public readonly InstallerVM Installer;
public readonly SettingsVM SettingsPane;
public readonly ModListGalleryVM Gallery;
public readonly ModeSelectionVM ModeSelectionVM;
public readonly HomeVM HomeVM;
public readonly WebBrowserVM WebBrowserVM;
public readonly Lazy<ModListContentsVM> ModListContentsVM;
public readonly UserInterventionHandlers UserInterventionHandlers;
@ -77,7 +77,7 @@ namespace Wabbajack
public bool UpdateAvailable { get; private set; }
public MainWindowVM(ILogger<MainWindowVM> logger, Client wjClient,
IServiceProvider serviceProvider, ModeSelectionVM modeSelectionVM, ModListGalleryVM modListGalleryVM, ResourceMonitor resourceMonitor,
IServiceProvider serviceProvider, HomeVM homeVM, ModListGalleryVM modListGalleryVM, ResourceMonitor resourceMonitor,
InstallerVM installer, CompilerVM compilerVM, SettingsVM settingsVM, WebBrowserVM webBrowserVM, NavigationVM navigationVM)
{
_logger = logger;
@ -89,7 +89,7 @@ namespace Wabbajack
Compiler = compilerVM;
SettingsPane = settingsVM;
Gallery = modListGalleryVM;
ModeSelectionVM = modeSelectionVM;
HomeVM = homeVM;
WebBrowserVM = webBrowserVM;
NavigationVM = navigationVM;
ModListContentsVM = new Lazy<ModListContentsVM>(() => new ModListContentsVM(serviceProvider.GetRequiredService<ILogger<ModListContentsVM>>(), this));
@ -126,7 +126,7 @@ namespace Wabbajack
else
{
// Start on mode selection
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView);
NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home);
}
try
@ -140,7 +140,7 @@ namespace Wabbajack
var fvi = FileVersionInfo.GetVersionInfo(string.IsNullOrWhiteSpace(assemblyLocation) ? processLocation : assemblyLocation);
Consts.CurrentMinimumWabbajackVersion = Version.Parse(fvi.FileVersion);
WindowTitle = $"{Consts.AppName}";
WindowTitle = Consts.AppName;
_logger.LogInformation("Wabbajack Version: {FileVersion}", fvi.FileVersion);
Task.Run(() => _wjClient.SendMetric("started_wabbajack", fvi.FileVersion)).FireAndForget();
@ -193,7 +193,6 @@ namespace Wabbajack
private void HandleNavigateTo(ViewModel objViewModel)
{
ActivePane = objViewModel;
}
@ -231,7 +230,7 @@ namespace Wabbajack
ActivePane = s switch
{
NavigateToGlobal.ScreenType.ModeSelectionView => ModeSelectionVM,
NavigateToGlobal.ScreenType.Home => HomeVM,
NavigateToGlobal.ScreenType.ModListGallery => Gallery,
NavigateToGlobal.ScreenType.Installer => Installer,
NavigateToGlobal.ScreenType.Compiler => Compiler,

View File

@ -11,7 +11,7 @@ using Wabbajack.Common;
using Wabbajack.DTOs;
using Wabbajack.DTOs.ServerResponses;
namespace Wabbajack.View_Models
namespace Wabbajack.ViewModels
{
public class ModListContentsVM : BackNavigatingVM
{

View File

@ -17,16 +17,22 @@ using Microsoft.Extensions.Logging;
using System.Reactive.Disposables;
using System.Diagnostics;
using System.Reflection;
using System.Collections.Generic;
using Wabbajack.Models;
namespace Wabbajack
{
public class NavigationVM : ViewModel
{
private readonly ILogger<NavigationVM> _logger;
[Reactive]
public NavigateToGlobal.ScreenType ActiveScreen { get; set; }
[Reactive]
public List<INavigationItem> NavigationItems { get; set; }
public NavigationVM(ILogger<NavigationVM> logger)
{
_logger = logger;
HomeCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModeSelectionView));
HomeCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Home));
BrowseCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.ModListGallery));
InstallCommand = ReactiveCommand.Create(() =>
{
@ -40,6 +46,16 @@ namespace Wabbajack
.Select(active => !object.ReferenceEquals(active, SettingsPane)),
*/
execute: () => NavigateToGlobal.Send(NavigateToGlobal.ScreenType.Settings));
MessageBus.Current.Listen<NavigateToGlobal>()
.Subscribe(x => ActiveScreen = x.Screen);
/*
this.WhenActivated(dispose =>
{
this.WhenAny(x => x.ActiveScreen)
.
})
*/
var processLocation = Process.GetCurrentProcess().MainModule?.FileName ?? throw new Exception("Process location is unavailable!");
var assembly = Assembly.GetExecutingAssembly();
var assemblyLocation = assembly.Location;

View File

@ -11,7 +11,7 @@ using Wabbajack;
using Wabbajack.Networking.WabbajackClientApi;
using Wabbajack.Services.OSIntegrated.TokenProviders;
namespace Wabbajack.View_Models.Settings
namespace Wabbajack.ViewModels.Settings
{
public class AuthorFilesVM : BackNavigatingVM
{

View File

@ -17,7 +17,7 @@ using Wabbajack.RateLimiter;
using Wabbajack.Services.OSIntegrated;
using Wabbajack.Services.OSIntegrated.TokenProviders;
using Wabbajack.Util;
using Wabbajack.View_Models.Settings;
using Wabbajack.ViewModels.Settings;
namespace Wabbajack
{

View File

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:Wabbajack"
xmlns:mahapps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
xmlns:viewModels="clr-namespace:Wabbajack.ViewModels"
xmlns:wpf="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
ShowTitleBar="False"
Title="Browser Window"

View File

@ -10,7 +10,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="http://reactiveui.net"
xmlns:wabbacommon="clr-namespace:Wabbajack.Common;assembly=Wabbajack.Common"
xmlns:controls1="clr-namespace:Wabbajack.View_Models.Controls"
xmlns:controls1="clr-namespace:Wabbajack.ViewModels.Controls"
d:DataContext="{d:DesignInstance local:CompilerVM}"
d:DesignHeight="450"
d:DesignWidth="800"

View File

@ -13,7 +13,7 @@ using Microsoft.WindowsAPICodePack.Dialogs;
using Wabbajack.Common;
using Wabbajack.Paths;
using Wabbajack.Paths.IO;
using Wabbajack.View_Models.Controls;
using Wabbajack.ViewModels.Controls;
namespace Wabbajack
{

View File

@ -1,5 +1,5 @@
<rxui:ReactiveUserControl
x:Class="Wabbajack.ModeSelectionView"
x:Class="Wabbajack.HomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -10,7 +10,7 @@
xmlns:ic="clr-namespace:FluentIcons.WPF;assembly=FluentIcons.WPF"
d:DesignHeight="700"
d:DesignWidth="1000"
x:TypeArguments="local:ModeSelectionVM"
x:TypeArguments="local:HomeVM"
mc:Ignorable="d">
<Grid Grid.Row="0" Grid.Column="0" VerticalAlignment="Stretch">
<Grid.RowDefinitions>

View File

@ -22,9 +22,9 @@ namespace Wabbajack
/// <summary>
/// Interaction logic for ModeSelectionView.xaml
/// </summary>
public partial class ModeSelectionView : ReactiveUserControl<ModeSelectionVM>
public partial class HomeView : ReactiveUserControl<HomeVM>
{
public ModeSelectionView()
public HomeView()
{
InitializeComponent();
var vm = ViewModel;

View File

@ -7,7 +7,7 @@
xmlns:local="clr-namespace:Wabbajack"
xmlns:mahapps="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
xmlns:viewModels="clr-namespace:Wabbajack.ViewModels"
xmlns:views="clr-namespace:Wabbajack.Views"
xmlns:ic="clr-namespace:FluentIcons.WPF;assembly=FluentIcons.WPF"
ShowTitleBar="False"
@ -36,21 +36,25 @@
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontSize="16" Padding="8, 8" Name="AppName"></TextBlock>
<TextBlock Grid.Column="1" FontSize="16" Padding="8, 8" Name="ResourceUsage" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<Button Grid.Column="2" Style="{StaticResource IconBareButtonStyle}" Name="MinimizeButton" Padding="12, 8">
<Border BorderThickness="0" Margin="10, 0, 5, 0" >
<Image Grid.Column="0" Width="18" Height="18" Source="{StaticResource WabbajackLogo}"/>
</Border>
<TextBlock Grid.Column="1" FontSize="16" Padding="8, 8" Name="AppName"></TextBlock>
<TextBlock Grid.Column="2" FontSize="16" Padding="8, 8" Name="ResourceUsage" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
<Button Grid.Column="3" Style="{StaticResource IconBareButtonStyle}" Name="MinimizeButton" Padding="12, 8">
<ic:SymbolIcon Symbol="Subtract"/>
</Button>
<Button Grid.Column="3" Style="{StaticResource IconBareButtonStyle}" Name="MaximizeButton" Padding="12, 8">
<Button Grid.Column="4" Style="{StaticResource IconBareButtonStyle}" Name="MaximizeButton" Padding="12, 8">
<ic:SymbolIcon Symbol="Maximize"/>
</Button>
<Button Grid.Column="4" Style="{StaticResource IconBareButtonStyle}" Name="CloseButton" Padding="12, 8">
<Button Grid.Column="5" Style="{StaticResource IconBareButtonStyle}" Name="CloseButton" Padding="12, 8">
<ic:SymbolIcon Symbol="ArrowExit"/>
</Button>
</Grid>
@ -69,8 +73,8 @@
<DataTemplate DataType="{x:Type local:InstallerVM}">
<local:InstallationView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:ModeSelectionVM}">
<local:ModeSelectionView ViewModel="{Binding}" />
<DataTemplate DataType="{x:Type local:HomeVM}">
<local:HomeView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:ModListGalleryVM}">
<local:ModListGalleryView ViewModel="{Binding}" />

View File

@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wabbajack"
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
xmlns:viewModels="clr-namespace:Wabbajack.ViewModels"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">

View File

@ -7,7 +7,7 @@
xmlns:local="clr-namespace:Wabbajack"
xmlns:rxui="http://reactiveui.net"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
xmlns:viewModels="clr-namespace:Wabbajack.ViewModels"
x:TypeArguments="viewModels:ModListContentsVM"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">

View File

@ -58,7 +58,7 @@
</TextBlock>
</Grid>
</Button>
<Button x:Name="SettingsButton" Grid.Row="6" Margin="0, 0, 0, 10">
<Button x:Name="SettingsButton" Grid.Row="6">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
@ -70,7 +70,7 @@
</TextBlock>
</Grid>
</Button>
<TextBlock x:Name="VersionTextBlock" Grid.Row="7" FontSize="12" HorizontalAlignment="Center" Margin="0, 0, 0, 10" Foreground="{StaticResource ForegroundBrush}" Opacity="0.66"/>
<TextBlock x:Name="VersionTextBlock" Grid.Row="7" FontSize="12" HorizontalAlignment="Center" Margin="0, 10, 0, 10" Foreground="{StaticResource ForegroundBrush}" Opacity="0.66"/>
</Grid>
</Border>
</rxui:ReactiveUserControl>

View File

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:Wabbajack"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:rxui="http://reactiveui.net"
xmlns:settings="clr-namespace:Wabbajack.View_Models.Settings"
xmlns:settings="clr-namespace:Wabbajack.ViewModels.Settings"
d:DesignHeight="450"
d:DesignWidth="800"
x:TypeArguments="settings:AuthorFilesVM"

View File

@ -1,6 +1,6 @@
using System.Windows.Controls;
using ReactiveUI;
using Wabbajack.View_Models.Settings;
using Wabbajack.ViewModels.Settings;
namespace Wabbajack
{

View File

@ -67,8 +67,8 @@
<None Remove="Resources\Wabba_Mouth.png" />
<None Remove="Resources\Wabba_Mouth_No_Text.png" />
<None Remove="Resources\Wabba_Mouth_Small.png" />
<Compile Remove="View Models\Compilers\VortexCompilerVM.cs" />
<Compile Remove="View Models\Installers\VortexInstallerVM.cs" />
<Compile Remove="ViewModels\Compilers\VortexCompilerVM.cs" />
<Compile Remove="ViewModels\Installers\VortexInstallerVM.cs" />
<None Update="VerbRegistration.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>VerbRegistration.cs</LastGenOutput>