diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs index edf62a6..ee64d80 100644 --- a/Apollon.WPF/App.xaml.cs +++ b/Apollon.WPF/App.xaml.cs @@ -39,12 +39,8 @@ namespace Apollon.WPF _tournamentStore = new TournamentsStore(_getAllTournamentQuery, _createTournamentCommand, _updateTournamentCommand, _deleteTournamentCommand); _selectedTournamentStore = new SelectedTournamentsStore(_tournamentStore); - _navBarPreparationViewModel = new NavBarPreparationViewModel(CreateOverviewNavigationService(), - CreateGroupsNavigationService(), - CreateNamelistNavigationService(), - CreateClassesNavigationService(), - CreateArchersNavigationService()); - } + _navBarPreparationViewModel = CreateNavbarViewModel(); + } protected override void OnStartup(StartupEventArgs e) { @@ -56,11 +52,11 @@ namespace Apollon.WPF OverviewViewModel overviewViewModel = OverviewViewModel.LoadViewModel( _selectedTournamentStore, _modalNavigationStore, - _tournamentStore, - CreateGroupsNavigationService(), - CreateNamelistNavigationService()); + _tournamentStore, + CreateNamelistNavigationService(), + CreateGroupsNavigationService()); - NavigationService overvoewNavigationService = CreateOverviewNavigationService(); + INavigationService overvoewNavigationService = CreateOverviewNavigationService(); overvoewNavigationService.Navigate(); MainWindow = new MainWindow() @@ -72,34 +68,47 @@ namespace Apollon.WPF base.OnStartup(e); } - private NavigationService CreateOverviewNavigationService() + private INavigationService CreateOverviewNavigationService() { return new NavigationService( - _navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, _modalNavigationStore, _tournamentStore, CreateGroupsNavigationService(), CreateNamelistNavigationService())); + _navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, + _modalNavigationStore, + _tournamentStore, + CreateNamelistNavigationService(), + CreateGroupsNavigationService())); } - private NavigationService CreateGroupsNavigationService() + private NavBarPreparationViewModel CreateNavbarViewModel() { - return new NavigationService( - _navigationStore, () => new GroupsViewModel(_navBarPreparationViewModel, _selectedTournamentStore, CreateOverviewNavigationService())); + return new NavBarPreparationViewModel(CreateOverviewNavigationService(), + CreateGroupsNavigationService(), + CreateNamelistNavigationService(), + CreateClassesNavigationService(), + CreateArchersNavigationService()); } - private NavigationService CreateClassesNavigationService() + private INavigationService CreateGroupsNavigationService() { - return new NavigationService( - _navigationStore, ()=> new ClassesViewModel(_navBarPreparationViewModel, _selectedTournamentStore)); + return new LayoutNavigationService( + _navigationStore, () => new GroupsViewModel(CreateOverviewNavigationService()), CreateNavbarViewModel); } - private NavigationService CreateNamelistNavigationService() + private INavigationService CreateClassesNavigationService() { - return new NavigationService( - _navigationStore, () => new NameListViewModel()); + return new LayoutNavigationService( + _navigationStore, ()=> new ClassesViewModel(), CreateNavbarViewModel); } - private NavigationService CreateArchersNavigationService() + private INavigationService CreateNamelistNavigationService() { - return new NavigationService( - _navigationStore, () => new ArchersViewModel(_navBarPreparationViewModel, _selectedTournamentStore)); + return new LayoutNavigationService( + _navigationStore, () => new NameListViewModel(), CreateNavbarViewModel); + } + + private INavigationService CreateArchersNavigationService() + { + return new LayoutNavigationService( + _navigationStore, () => new ArchersViewModel(), CreateNavbarViewModel); } } } diff --git a/Apollon.WPF/Commands/AddTournamentCommand.cs b/Apollon.WPF/Commands/AddTournamentCommand.cs index d705f58..f2576b0 100644 --- a/Apollon.WPF/Commands/AddTournamentCommand.cs +++ b/Apollon.WPF/Commands/AddTournamentCommand.cs @@ -12,15 +12,14 @@ namespace Apollon.WPF.Commands private readonly TournamentsStore _tournamentStore; private readonly ModalNavigationStore _modalNavigationStore; private AddTournamentViewModel _addTournamentViewModel; - private readonly NavigationService _navigationService; + - public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationService navigationService) + public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { _addTournamentViewModel = addTournamentViewModel; _tournamentStore = tournamentStore; - _modalNavigationStore = modalNavigationStore; - _navigationService = navigationService; + _modalNavigationStore = modalNavigationStore; } public override async Task ExecuteAsync(object parameter) @@ -48,7 +47,7 @@ namespace Apollon.WPF.Commands await _tournamentStore.Add(tournament); _modalNavigationStore.Close(); - _navigationService.Navigate(); + } catch (Exception) { diff --git a/Apollon.WPF/Commands/NavigateCommand.cs b/Apollon.WPF/Commands/NavigateCommand.cs index 6a20234..3500e27 100644 --- a/Apollon.WPF/Commands/NavigateCommand.cs +++ b/Apollon.WPF/Commands/NavigateCommand.cs @@ -12,9 +12,9 @@ namespace Apollon.WPF.Commands public class NavigateCommand : CommandBase where TViewModel : ViewModelBase { - private readonly NavigationService _navigationService; + private readonly INavigationService _navigationService; - public NavigateCommand(NavigationService navigationService) + public NavigateCommand(INavigationService navigationService) { _navigationService = navigationService; } diff --git a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs index 21b9ab9..bef8e5d 100644 --- a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs +++ b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs @@ -12,19 +12,18 @@ namespace Apollon.WPF.Commands public class OpenAddTournamentCommand : CommandBase { private readonly TournamentsStore _tournamentStore; - private readonly ModalNavigationStore _modalNavigationStore; - private readonly NavigationService _navigationService; + private readonly ModalNavigationStore _modalNavigationStore; - public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationService navigationService) + public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { _tournamentStore = tournamentStore; _modalNavigationStore = modalNavigationStore; - _navigationService = navigationService; + ; } public override void Execute(object parameter) { - AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationService); + AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore); _modalNavigationStore.CurrentViewModel = addTournamentViewModel; } } diff --git a/Apollon.WPF/MainWindow.xaml b/Apollon.WPF/MainWindow.xaml index ba11e1c..3115db4 100644 --- a/Apollon.WPF/MainWindow.xaml +++ b/Apollon.WPF/MainWindow.xaml @@ -54,6 +54,9 @@ + + + diff --git a/Apollon.WPF/Services/INavigationService.cs b/Apollon.WPF/Services/INavigationService.cs new file mode 100644 index 0000000..86f0b37 --- /dev/null +++ b/Apollon.WPF/Services/INavigationService.cs @@ -0,0 +1,9 @@ +using Apollon.WPF.ViewModels; + +namespace Apollon.WPF.Services +{ + public interface INavigationService where TViewModel : ViewModelBase + { + void Navigate(); + } +} \ No newline at end of file diff --git a/Apollon.WPF/Services/LayoutNavigationService.cs b/Apollon.WPF/Services/LayoutNavigationService.cs new file mode 100644 index 0000000..e8cbe35 --- /dev/null +++ b/Apollon.WPF/Services/LayoutNavigationService.cs @@ -0,0 +1,29 @@ +using Apollon.WPF.Stores; +using Apollon.WPF.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Apollon.WPF.Services +{ + public class LayoutNavigationService : INavigationService where TViewModel : ViewModelBase + { + private readonly NavigationStore _navigationStore; + private readonly Func _createViewModel; + private readonly Func _createNavBarPreparationViewModel; + + public LayoutNavigationService(NavigationStore navigationStore, Func createViewModel, Func createNavBarPreparationViewModel) + { + _navigationStore = navigationStore; + _createViewModel = createViewModel; + _createNavBarPreparationViewModel = createNavBarPreparationViewModel; + } + + public void Navigate() + { + _navigationStore.CurrentViewModel = new LayoutViewModel(_createNavBarPreparationViewModel(), _createViewModel()); + } + } +} diff --git a/Apollon.WPF/Services/NavigationService.cs b/Apollon.WPF/Services/NavigationService.cs index 8154cbd..215fb06 100644 --- a/Apollon.WPF/Services/NavigationService.cs +++ b/Apollon.WPF/Services/NavigationService.cs @@ -8,8 +8,7 @@ using System.Threading.Tasks; namespace Apollon.WPF.Services { - public class NavigationService - where TViewModel : ViewModelBase + public class NavigationService : INavigationService where TViewModel : ViewModelBase { private readonly NavigationStore _navigationStore; private readonly Func _createViewModel; diff --git a/Apollon.WPF/ViewModels/AddTournametViewModel.cs b/Apollon.WPF/ViewModels/AddTournametViewModel.cs index 1a6798d..87fd1d6 100644 --- a/Apollon.WPF/ViewModels/AddTournametViewModel.cs +++ b/Apollon.WPF/ViewModels/AddTournametViewModel.cs @@ -14,9 +14,9 @@ namespace Apollon.WPF.ViewModels { public AddEditDetailsViewModel AddEditDetailsViewModel { get; } - public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationService navigationService) + public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore) { - ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore, navigationService); + ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore); ICommand cancelCommand = new CloseModalCommand(modalNavigationStore); AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand); } diff --git a/Apollon.WPF/ViewModels/ArchersViewModel.cs b/Apollon.WPF/ViewModels/ArchersViewModel.cs index 8fd4de6..648e441 100644 --- a/Apollon.WPF/ViewModels/ArchersViewModel.cs +++ b/Apollon.WPF/ViewModels/ArchersViewModel.cs @@ -9,13 +9,6 @@ namespace Apollon.WPF.ViewModels { public class ArchersViewModel : ViewModelBase { - public TournamentDetailsViewModel TournamentDetailsViewModel { get; } - public NavBarPreparationViewModel NavBarPreparationViewModel { get; } - - 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 fea2e3a..436f203 100644 --- a/Apollon.WPF/ViewModels/ClassesViewModel.cs +++ b/Apollon.WPF/ViewModels/ClassesViewModel.cs @@ -9,13 +9,6 @@ namespace Apollon.WPF.ViewModels { public class ClassesViewModel : ViewModelBase { - public TournamentDetailsViewModel TournamentDetailsViewModel { get; } - public NavBarPreparationViewModel NavBarPreparationViewModel { get; } - - 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 752c414..8707149 100644 --- a/Apollon.WPF/ViewModels/GroupsViewModel.cs +++ b/Apollon.WPF/ViewModels/GroupsViewModel.cs @@ -12,19 +12,12 @@ using System.Windows.Input; namespace Apollon.WPF.ViewModels { public class GroupsViewModel : ViewModelBase - { - - public TournamentDetailsViewModel TournamentDetailsViewModel { get; } - public NavBarPreparationViewModel NavBarPreparationViewModel { get; } + { public ICommand NavigateOverviewCommand { get; } - public GroupsViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentStore, NavigationService overviewNavigationService) - { - TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentStore); - - NavBarPreparationViewModel = navBarPreparationViewModel; - - NavigateOverviewCommand = new NavigateCommand(overviewNavigationService); + public GroupsViewModel(INavigationService overviewNavigationService) + { + //NavigateOverviewCommand = new NavigateCommand(overviewNavigationService); } } } diff --git a/Apollon.WPF/ViewModels/LayoutViewModel.cs b/Apollon.WPF/ViewModels/LayoutViewModel.cs new file mode 100644 index 0000000..2147fff --- /dev/null +++ b/Apollon.WPF/ViewModels/LayoutViewModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Apollon.WPF.ViewModels +{ + public class LayoutViewModel : ViewModelBase + { + public LayoutViewModel(NavBarPreparationViewModel navBarPreparationViewModel, ViewModelBase contentVieModel) + { + NavBarPreparationViewModel = navBarPreparationViewModel; + ContentVieModel = contentVieModel; + } + + public NavBarPreparationViewModel NavBarPreparationViewModel { get;} + public ViewModelBase ContentVieModel { get;} + } +} diff --git a/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs b/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs index 23bbd5b..87b8859 100644 --- a/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs +++ b/Apollon.WPF/ViewModels/NavBarPreparationViewModel.cs @@ -17,11 +17,11 @@ namespace Apollon.WPF.ViewModels public ICommand NavigateNamelistCommand { get;} public ICommand NavigateArchersCommand { get;} - public NavBarPreparationViewModel(NavigationService overviewNavigationService, - NavigationService groupNavigationService, - NavigationService namelistNavigationService, - NavigationService classNavigationService, - NavigationService archersNavigationService) + public NavBarPreparationViewModel(INavigationService overviewNavigationService, + INavigationService groupNavigationService, + INavigationService namelistNavigationService, + INavigationService classNavigationService, + INavigationService archersNavigationService) { NavigateOverviewCommand = new NavigateCommand(overviewNavigationService); NavigateGroupsCommand = new NavigateCommand(groupNavigationService); diff --git a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs index 533f65d..dcbf204 100644 --- a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs @@ -24,15 +24,17 @@ namespace Apollon.WPF.ViewModels public int Targets => SelectedTournament?.Targets ?? 0; public ICommand NavigatePreparationCommand { get; } + public SelectedTournamentsStore SelectedTournamentStore { get; } + - public OverviewDetailsViewModel(SelectedTournamentsStore selectedTournamentStore, NavigationService groupNavigationService) + public OverviewDetailsViewModel(SelectedTournamentsStore selectedTournamentStore, INavigationService groupNavigationService) { _selectedTournamentStore = selectedTournamentStore; _selectedTournamentStore.SelectedTournamentChanged += SelectedTournamentStore_SelectedTournamentChanged; NavigatePreparationCommand = new NavigateCommand(groupNavigationService); - } + } protected override void Dispose() { diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs index 58e6dca..7a132a2 100644 --- a/Apollon.WPF/ViewModels/OverviewViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs @@ -46,24 +46,24 @@ namespace Apollon.WPF.ViewModels public ICommand NavigateNameListCommand { get; } public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore, - ModalNavigationStore modalNavigationStore, NavigationService groupNavigationService, NavigationService NameListNavigationService) + ModalNavigationStore modalNavigationStore, INavigationService NameListNavigationService, INavigationService groupNavigationService) { OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore); - OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore ,groupNavigationService); + OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore, groupNavigationService); LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore); - OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, groupNavigationService); + OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore); NavigateNameListCommand = new NavigateCommand(NameListNavigationService); } public static OverviewViewModel LoadViewModel(SelectedTournamentsStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, - TournamentsStore tournamentStore, - NavigationService groupNavigationService, - NavigationService NameListNavigationService) + TournamentsStore tournamentStore, + INavigationService NameListNavigationService, + INavigationService groupNavigationService) { - OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore,groupNavigationService, NameListNavigationService); + OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore, NameListNavigationService, groupNavigationService); viewModel.LoadTournamentsCommand.Execute(null); diff --git a/Apollon.WPF/Views/ArchersView.xaml b/Apollon.WPF/Views/ArchersView.xaml index 2992830..07345a3 100644 --- a/Apollon.WPF/Views/ArchersView.xaml +++ b/Apollon.WPF/Views/ArchersView.xaml @@ -6,22 +6,7 @@ xmlns:local="clr-namespace:Apollon.WPF.Views" xmlns:components="clr-namespace:Apollon.WPF.Views.Components" mc:Ignorable="d" d:DesignHeight="680" d:DesignWidth="1100"> - - - - - - - - - - - - - - - + + diff --git a/Apollon.WPF/Views/ClassesView.xaml b/Apollon.WPF/Views/ClassesView.xaml index 5d10218..a2f1955 100644 --- a/Apollon.WPF/Views/ClassesView.xaml +++ b/Apollon.WPF/Views/ClassesView.xaml @@ -7,23 +7,8 @@ xmlns:components="clr-namespace:Apollon.WPF.Views.Components" mc:Ignorable="d" d:DesignHeight="680" d:DesignWidth="1100"> - - - - - - - - - - - - - - - + + diff --git a/Apollon.WPF/Views/Components/Layout.xaml b/Apollon.WPF/Views/Components/Layout.xaml new file mode 100644 index 0000000..505bd4a --- /dev/null +++ b/Apollon.WPF/Views/Components/Layout.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Apollon.WPF/Views/Components/Layout.xaml.cs b/Apollon.WPF/Views/Components/Layout.xaml.cs new file mode 100644 index 0000000..8319ed9 --- /dev/null +++ b/Apollon.WPF/Views/Components/Layout.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Apollon.WPF.Views.Components +{ + /// + /// Interaction logic for Layout.xaml + /// + public partial class Layout : UserControl + { + public Layout() + { + InitializeComponent(); + } + } +} diff --git a/Apollon.WPF/Views/Components/TournamentDetails.xaml b/Apollon.WPF/Views/Components/TournamentDetails.xaml index ec5e921..f43534e 100644 --- a/Apollon.WPF/Views/Components/TournamentDetails.xaml +++ b/Apollon.WPF/Views/Components/TournamentDetails.xaml @@ -5,8 +5,8 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Apollon.WPF.Views.Components" mc:Ignorable="d" - d:DesignHeight="680" d:DesignWidth="1100"> - + d:DesignHeight="80" d:DesignWidth="1100"> + diff --git a/Apollon.WPF/Views/GroupsView.xaml b/Apollon.WPF/Views/GroupsView.xaml index 84b0275..75f5f3b 100644 --- a/Apollon.WPF/Views/GroupsView.xaml +++ b/Apollon.WPF/Views/GroupsView.xaml @@ -5,23 +5,8 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:components="clr-namespace:Apollon.WPF.Views.Components" mc:Ignorable="d" - d:DesignHeight="680" d:DesignWidth="1100"> - - - - - - - - - - - - - - - + d:DesignHeight="6800" d:DesignWidth="200"> + + diff --git a/Apollon.WPF/Views/OverviewView.xaml b/Apollon.WPF/Views/OverviewView.xaml index 7433400..f568b41 100644 --- a/Apollon.WPF/Views/OverviewView.xaml +++ b/Apollon.WPF/Views/OverviewView.xaml @@ -49,7 +49,7 @@