From a655efdc8c75f45d2ca45887e3c1e6e35e27ef5d Mon Sep 17 00:00:00 2001 From: Natlinux81 <97396587+Natlinux81@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:46:22 +0200 Subject: [PATCH] Renavigate --- Apollon.WPF/Commands/AddTournamentCommand.cs | 13 +++++-------- .../{NavigatCommand.cs => NavigateCommand.cs} | 7 +++---- Apollon.WPF/Commands/OpenAddTournamentCommand.cs | 6 ++++-- Apollon.WPF/MainWindow.xaml | 5 +---- Apollon.WPF/ViewModels/AddTournametViewModel.cs | 4 ++-- Apollon.WPF/ViewModels/OverviewViewModel.cs | 4 ++-- 6 files changed, 17 insertions(+), 22 deletions(-) rename Apollon.WPF/Commands/{NavigatCommand.cs => NavigateCommand.cs} (77%) diff --git a/Apollon.WPF/Commands/AddTournamentCommand.cs b/Apollon.WPF/Commands/AddTournamentCommand.cs index b64f879..600996a 100644 --- a/Apollon.WPF/Commands/AddTournamentCommand.cs +++ b/Apollon.WPF/Commands/AddTournamentCommand.cs @@ -12,20 +12,16 @@ namespace Apollon.WPF.Commands public class AddTournamentCommand : AsyncCommandBase { private readonly TournamentsStore _tournamentStore; + private readonly NavigationStore _navigationStore; private readonly ModalNavigationStore _modalNavigationStore; - private AddTournamentViewModel _addTournamentViewModel; + private AddTournamentViewModel _addTournamentViewModel; - public AddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) - { - _tournamentStore = tournamentStore; - _modalNavigationStore = modalNavigationStore; - } - - public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) + public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore) { _addTournamentViewModel = addTournamentViewModel; _tournamentStore = tournamentStore; _modalNavigationStore = modalNavigationStore; + _navigationStore = navigationStore; } public override async Task ExecuteAsync(object parameter) @@ -50,6 +46,7 @@ namespace Apollon.WPF.Commands await _tournamentStore.Add(tournament); _modalNavigationStore.Close(); + _navigationStore.CurrentViewModel = new NavBarViewModel(_navigationStore); } catch (Exception) diff --git a/Apollon.WPF/Commands/NavigatCommand.cs b/Apollon.WPF/Commands/NavigateCommand.cs similarity index 77% rename from Apollon.WPF/Commands/NavigatCommand.cs rename to Apollon.WPF/Commands/NavigateCommand.cs index d2a16b4..30dc6ec 100644 --- a/Apollon.WPF/Commands/NavigatCommand.cs +++ b/Apollon.WPF/Commands/NavigateCommand.cs @@ -8,21 +8,20 @@ using System.Threading.Tasks; namespace Apollon.WPF.Commands { - public class NavigatCommand : CommandBase + public class NavigateCommand : CommandBase where TViewModel : ViewModelBase { private readonly NavigationStore _navigationStore; private readonly Func _createViewModel; - public NavigatCommand(NavigationStore navigationStore, Func createViewModel) + public NavigateCommand(NavigationStore navigationStore, Func createViewModel) { _navigationStore = navigationStore; _createViewModel = createViewModel; } public override void Execute(object parameter) - { - + { _navigationStore.CurrentViewModel = _createViewModel(); } } diff --git a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs index 1281450..2502bd2 100644 --- a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs +++ b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs @@ -11,17 +11,19 @@ namespace Apollon.WPF.Commands public class OpenAddTournamentCommand : CommandBase { private readonly TournamentsStore _tournamentStore; + private readonly NavigationStore _navigationStore; private readonly ModalNavigationStore _modalNavigationStore; - public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) + public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore) { _tournamentStore = tournamentStore; + _navigationStore = navigationStore; _modalNavigationStore = modalNavigationStore; } public override void Execute(object parameter) { - AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore); + AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationStore); _modalNavigationStore.CurrentViewModel = addTournamentViewModel; } } diff --git a/Apollon.WPF/MainWindow.xaml b/Apollon.WPF/MainWindow.xaml index fca424f..ac0ad97 100644 --- a/Apollon.WPF/MainWindow.xaml +++ b/Apollon.WPF/MainWindow.xaml @@ -26,10 +26,7 @@ - - - - + diff --git a/Apollon.WPF/ViewModels/AddTournametViewModel.cs b/Apollon.WPF/ViewModels/AddTournametViewModel.cs index 253f83e..c9480c8 100644 --- a/Apollon.WPF/ViewModels/AddTournametViewModel.cs +++ b/Apollon.WPF/ViewModels/AddTournametViewModel.cs @@ -13,9 +13,9 @@ namespace Apollon.WPF.ViewModels { public AddEditDetailsViewModel AddEditDetailsViewModel { get; } - public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) + public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore) { - ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore); + ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore); ICommand cancelCommand = new CloseModalCommand(modalNavigationStore); AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand); } diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs index 7689172..78542e8 100644 --- a/Apollon.WPF/ViewModels/OverviewViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs @@ -40,8 +40,8 @@ namespace Apollon.WPF.ViewModels OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore); LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore); - AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore); - NavigateNavBarCommand = new NavigatCommand(navigationStore, () => new NavBarViewModel(navigationStore)); + AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore); + NavigateNavBarCommand = new NavigateCommand(navigationStore, () => new NavBarViewModel(navigationStore)); }