From b6a427ca299aa499ae9f45c50c8b564a42dffdbf Mon Sep 17 00:00:00 2001 From: Natlinux <97396587+Natlinux81@users.noreply.github.com> Date: Mon, 28 Nov 2022 00:42:42 +0100 Subject: [PATCH] first NavBar finish --- Apollon.WPF/App.xaml.cs | 44 +++++++++++++++++-- Apollon.WPF/Commands/AddTournamentCommand.cs | 2 +- Apollon.WPF/ViewModels/ArchersViewModel.cs | 7 ++- Apollon.WPF/ViewModels/ClassesViewModel.cs | 7 ++- Apollon.WPF/ViewModels/GroupsViewModel.cs | 8 ++-- .../ViewModels/NavBarPreparationViewModel.cs | 2 +- .../ViewModels/OverviewDetailsViewModel.cs | 5 +-- Apollon.WPF/ViewModels/OverviewViewModel.cs | 9 ++-- Apollon.WPF/Views/ClassesView.xaml | 2 +- 9 files changed, 65 insertions(+), 21 deletions(-) diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs index d9f9be3..7628f6d 100644 --- a/Apollon.WPF/App.xaml.cs +++ b/Apollon.WPF/App.xaml.cs @@ -4,6 +4,7 @@ using Apollon.Domain.Queries; using Apollon.EntityFramework; using Apollon.EntityFramework.Commands; using Apollon.EntityFramework.Queries; +using Apollon.WPF.Services; using Apollon.WPF.Stores; using Apollon.WPF.ViewModels; using Microsoft.EntityFrameworkCore; @@ -30,7 +31,8 @@ namespace Apollon.WPF private readonly IUpdateTournamentCommand _updateTournamentCommand; private readonly IDeleteTournamentCommand _deleteTournamentCommand; private readonly TournamentsStore _tournamentStore; - private readonly SelectedTournamentsStore _selectedTournamentStore; + private readonly SelectedTournamentsStore _selectedTournamentStore; + private readonly NavBarPreparationViewModel _navBarPreparationViewModel; public App() { @@ -46,7 +48,13 @@ namespace Apollon.WPF _deleteTournamentCommand = new DeleteTournamentCommand(_tournamentsDbContextFactory); _tournamentStore = new TournamentsStore(_getAllTournamentQuery, _createTournamentCommand, _updateTournamentCommand, _deleteTournamentCommand); _selectedTournamentStore = new SelectedTournamentsStore(_tournamentStore); - } + + _navBarPreparationViewModel = new NavBarPreparationViewModel(CreateOverviewNavigationService(), + CreateGroupsNavigationService(), + CreateClassesNavigationService(), + CreateArchersNavigationService()); + } + protected override void OnStartup(StartupEventArgs e) { using(ApplicationDbContext context = _tournamentsDbContextFactory.Create()) @@ -58,13 +66,17 @@ namespace Apollon.WPF _selectedTournamentStore, _modalNavigationStore, _tournamentStore, - _navigationStore); + _navigationStore, + CreateGroupsNavigationService()); _navigationStore.CurrentViewModel = OverviewViewModel.LoadViewModel( _selectedTournamentStore, _modalNavigationStore, _tournamentStore, - _navigationStore); + _navigationStore, + CreateGroupsNavigationService()); + + MainWindow = new MainWindow() { @@ -74,5 +86,29 @@ namespace Apollon.WPF base.OnStartup(e); } + + private NavigationService CreateOverviewNavigationService() + { + return new NavigationService( + _navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, _modalNavigationStore, _tournamentStore, _navigationStore, CreateGroupsNavigationService())); + } + + private NavigationService CreateGroupsNavigationService() + { + return new NavigationService( + _navigationStore, () => new GroupsViewModel( _navBarPreparationViewModel, _selectedTournamentStore, _navigationStore, _modalNavigationStore, _tournamentStore, CreateGroupsNavigationService())); + } + + private NavigationService CreateClassesNavigationService() + { + return new NavigationService( + _navigationStore, ()=> new ClassesViewModel(_navBarPreparationViewModel, _selectedTournamentStore)); + } + + private NavigationService CreateArchersNavigationService() + { + return new NavigationService( + _navigationStore, () => new ArchersViewModel(_navBarPreparationViewModel, _selectedTournamentStore)); + } } } diff --git a/Apollon.WPF/Commands/AddTournamentCommand.cs b/Apollon.WPF/Commands/AddTournamentCommand.cs index 79e8de9..3e3161a 100644 --- a/Apollon.WPF/Commands/AddTournamentCommand.cs +++ b/Apollon.WPF/Commands/AddTournamentCommand.cs @@ -52,7 +52,7 @@ namespace Apollon.WPF.Commands await _tournamentStore.Add(tournament); _modalNavigationStore.Close(); - _navigationStore.CurrentViewModel = new GroupsViewModel(_selectedTournamentsStore, _navigationStore, _modalNavigationStore, _tournamentStore); + //_navigationStore.CurrentViewModel = new GroupsViewModel(_selectedTournamentsStore, _navigationStore, _modalNavigationStore, _tournamentStore); } catch (Exception) diff --git a/Apollon.WPF/ViewModels/ArchersViewModel.cs b/Apollon.WPF/ViewModels/ArchersViewModel.cs index bcc6dc1..8fd4de6 100644 --- a/Apollon.WPF/ViewModels/ArchersViewModel.cs +++ b/Apollon.WPF/ViewModels/ArchersViewModel.cs @@ -1,4 +1,5 @@ -using System; +using Apollon.WPF.Stores; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,10 +9,12 @@ namespace Apollon.WPF.ViewModels { public class ArchersViewModel : ViewModelBase { + public TournamentDetailsViewModel TournamentDetailsViewModel { get; } public NavBarPreparationViewModel NavBarPreparationViewModel { get; } - public ArchersViewModel(NavBarPreparationViewModel navBarPreparationViewModel) + public ArchersViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentsStore) { + TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentsStore); NavBarPreparationViewModel = navBarPreparationViewModel; } } diff --git a/Apollon.WPF/ViewModels/ClassesViewModel.cs b/Apollon.WPF/ViewModels/ClassesViewModel.cs index ca180a9..fea2e3a 100644 --- a/Apollon.WPF/ViewModels/ClassesViewModel.cs +++ b/Apollon.WPF/ViewModels/ClassesViewModel.cs @@ -1,4 +1,5 @@ -using System; +using Apollon.WPF.Stores; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,10 +9,12 @@ namespace Apollon.WPF.ViewModels { public class ClassesViewModel : ViewModelBase { + public TournamentDetailsViewModel TournamentDetailsViewModel { get; } public NavBarPreparationViewModel NavBarPreparationViewModel { get; } - public ClassesViewModel(NavBarPreparationViewModel navBarPreparationViewModel) + public ClassesViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentsStore) { + TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentsStore); NavBarPreparationViewModel = navBarPreparationViewModel; } } diff --git a/Apollon.WPF/ViewModels/GroupsViewModel.cs b/Apollon.WPF/ViewModels/GroupsViewModel.cs index bbbb639..22a927b 100644 --- a/Apollon.WPF/ViewModels/GroupsViewModel.cs +++ b/Apollon.WPF/ViewModels/GroupsViewModel.cs @@ -18,11 +18,13 @@ namespace Apollon.WPF.ViewModels public NavBarPreparationViewModel NavBarPreparationViewModel { get; } public ICommand NavigateOverviewCommand { get; } - public GroupsViewModel(SelectedTournamentsStore selectedTournamentStore, NavigationStore navigationStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentsStore) + public GroupsViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentStore, NavigationStore navigationStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentsStore, NavigationService groupNavigationService) { TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentStore); - - NavigateOverviewCommand = new NavigateCommand(new NavigationService(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore))); + + NavBarPreparationViewModel = navBarPreparationViewModel; + + NavigateOverviewCommand = new NavigateCommand(new NavigationService(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore, groupNavigationService))); } } } diff --git a/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs b/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs index 7579e95..5f683b6 100644 --- a/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs +++ b/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs @@ -11,7 +11,7 @@ namespace Apollon.WPF.ViewModels { public class NavBarPreparationViewModel : ViewModelBase { - public ICommand NavigateOverviewCommand { get;} + public ICommand NavigateOverviewCommand { get; } public ICommand NavigateGroupsCommand { get;} public ICommand NavigateClassesCommand { get;} public ICommand NavigateArchersCommand { get;} diff --git a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs index d2e91c9..694a5a1 100644 --- a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs @@ -30,14 +30,13 @@ namespace Apollon.WPF.ViewModels public ICommand NavigatePreparationCommand { get; } - public OverviewDetailsViewModel(SelectedTournamentsStore selectedTournamentStore, NavigationStore navigationStore, ModalNavigationStore modalNavigationStore,TournamentsStore tournamentsStore) + public OverviewDetailsViewModel(SelectedTournamentsStore selectedTournamentStore, NavigationService groupNavigationService) { _selectedTournamentStore = selectedTournamentStore; _selectedTournamentStore.SelectedTournamentChanged += SelectedTournamentStore_SelectedTournamentChanged; - NavigatePreparationCommand = new NavigateCommand(new NavigationService ( - navigationStore, () => new GroupsViewModel( _selectedTournamentStore, navigationStore, modalNavigationStore, tournamentsStore))); + NavigatePreparationCommand = new NavigateCommand(groupNavigationService); } protected override void Dispose() diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs index f38afc2..5fe8e33 100644 --- a/Apollon.WPF/ViewModels/OverviewViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs @@ -46,10 +46,10 @@ namespace Apollon.WPF.ViewModels public ICommand NavigateNameListCommand { get; } public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore, - ModalNavigationStore modalNavigationStore, NavigationStore navigationStore) + ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, NavigationService groupNavigationService) { OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore); - OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore ,navigationStore, modalNavigationStore,tournamentStore); + OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore ,groupNavigationService); LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore); OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore, selectedTournamentStore); @@ -61,9 +61,10 @@ namespace Apollon.WPF.ViewModels public static OverviewViewModel LoadViewModel(SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentStore, - NavigationStore navigationStore) + NavigationStore navigationStore, + NavigationService groupNavigationService) { - OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore, navigationStore); + OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore, navigationStore, groupNavigationService); viewModel.LoadTournamentsCommand.Execute(null); diff --git a/Apollon.WPF/Views/ClassesView.xaml b/Apollon.WPF/Views/ClassesView.xaml index 1d5e42d..5d10218 100644 --- a/Apollon.WPF/Views/ClassesView.xaml +++ b/Apollon.WPF/Views/ClassesView.xaml @@ -7,7 +7,7 @@ xmlns:components="clr-namespace:Apollon.WPF.Views.Components" mc:Ignorable="d" d:DesignHeight="680" d:DesignWidth="1100"> - +