diff --git a/Core/TableTopCrucible.Core.Wpf.Engine/Services/NavigationService.cs b/Core/TableTopCrucible.Core.Wpf.Engine/Services/NavigationService.cs index 7227eeea..6446e600 100644 --- a/Core/TableTopCrucible.Core.Wpf.Engine/Services/NavigationService.cs +++ b/Core/TableTopCrucible.Core.Wpf.Engine/Services/NavigationService.cs @@ -33,7 +33,6 @@ public NavigationService() _pages.AddRange( DependencyInjectionHelper.GetServicesByType().Where(s=>s != null)// filter vm utilities ); - CurrentPage = _pages.Items.OrderBy(m=>m.Position.Value).First(); } } } diff --git a/Domain/TableTopCrucible.Domain.Library.Wpf/Pages/ViewModels/LibraryPageVm.cs b/Domain/TableTopCrucible.Domain.Library.Wpf/Pages/ViewModels/LibraryPageVm.cs index 840b4545..a1f98a3d 100644 --- a/Domain/TableTopCrucible.Domain.Library.Wpf/Pages/ViewModels/LibraryPageVm.cs +++ b/Domain/TableTopCrucible.Domain.Library.Wpf/Pages/ViewModels/LibraryPageVm.cs @@ -13,11 +13,11 @@ namespace TableTopCrucible.Domain.Library.Wpf.Pages.ViewModels { [Singleton(typeof(LibraryPageVm))] - public interface ILibraryPage + public interface ILibraryPage: INavigationPage { } - public class LibraryPageVm:ReactiveObject, IActivatableViewModel, ILibraryPage, INavigationPage + public class LibraryPageVm:ReactiveObject, IActivatableViewModel, ILibraryPage { public ViewModelActivator Activator { get; } = new(); public PackIconKind? Icon => PackIconKind.Bookshelf; diff --git a/Domain/TableTopCrucible.Domain.Settings.Wpf/Pages/ViewModels/DirectorySetupPageVm.cs b/Domain/TableTopCrucible.Domain.Settings.Wpf/Pages/ViewModels/DirectorySetupPageVm.cs index 7c2b5f26..75840bf9 100644 --- a/Domain/TableTopCrucible.Domain.Settings.Wpf/Pages/ViewModels/DirectorySetupPageVm.cs +++ b/Domain/TableTopCrucible.Domain.Settings.Wpf/Pages/ViewModels/DirectorySetupPageVm.cs @@ -11,7 +11,7 @@ namespace TableTopCrucible.Domain.Settings.Wpf.PageViewModels { - [Transient(typeof(DirectorySetupPageVm))] + [Singleton(typeof(DirectorySetupPageVm))] public interface IDirectorySetupPage : INavigationPage { diff --git a/Infrastructure/TableTopCrucible.Infrastructure.Repositories/Models/Entities/DirectorySetup.cs b/Infrastructure/TableTopCrucible.Infrastructure.Repositories/Models/Entities/DirectorySetup.cs index 92e9c633..d85482d9 100644 --- a/Infrastructure/TableTopCrucible.Infrastructure.Repositories/Models/Entities/DirectorySetup.cs +++ b/Infrastructure/TableTopCrucible.Infrastructure.Repositories/Models/Entities/DirectorySetup.cs @@ -20,9 +20,8 @@ public int CompareTo(DirectorySetup other) public DirectorySetup(string name, string path, DirectorySetupId Id = null):this(vtName.From(name), DirectorySetupPath.From(path), Id) { } - public DirectorySetup(vtName name, DirectorySetupPath path, DirectorySetupId Id = null) + public DirectorySetup(vtName name, DirectorySetupPath path, DirectorySetupId Id = null):base(Id??DirectorySetupId.New()) { - this.Id = Id ?? DirectorySetupId.New(); this.Name = name; this.Path = path; } diff --git a/TableTopCrucible.Starter/MainWindow.xaml.cs b/TableTopCrucible.Starter/MainWindow.xaml.cs index a6d38532..87723ee2 100644 --- a/TableTopCrucible.Starter/MainWindow.xaml.cs +++ b/TableTopCrucible.Starter/MainWindow.xaml.cs @@ -1,8 +1,13 @@ -using Splat; +using System.Reactive.Linq; +using Splat; using System.Windows; using TableTopCrucible.Core.Wpf.Engine.Pages.ViewModels; +using TableTopCrucible.Core.Wpf.Engine.Services; +using TableTopCrucible.Domain.Library.Wpf.Pages.ViewModels; +using TableTopCrucible.Domain.Settings.Wpf.PageViewModels; +using TableTopCrucible.Infrastructure.Repositories; namespace TableTopCrucible.Starter { @@ -16,6 +21,14 @@ public MainWindow() InitializeComponent(); this.MainPageContainer.ViewModel = Locator.Current.GetService(); + + var navigationService = Locator.Current.GetService(); + var directorySetupRepository = Locator.Current.GetService(); + + if (directorySetupRepository.Data.Count == 0) + navigationService.CurrentPage = Locator.Current.GetService(); + else + navigationService.CurrentPage = Locator.Current.GetService(); } } }