From fa278fc24514c87db77911b21f3bbc0d5603919d Mon Sep 17 00:00:00 2001
From: Natlinux81 <97396587+Natlinux81@users.noreply.github.com>
Date: Sat, 27 Aug 2022 02:23:07 +0200
Subject: [PATCH] implement NavigateCommand
---
Apollon.WPF/App.xaml | 1 +
Apollon.WPF/App.xaml.cs | 15 ++++++++---
Apollon.WPF/Commands/NavigatCommand.cs | 29 +++++++++++++++++++++
Apollon.WPF/MainWindow.xaml | 28 +++++++++++++++-----
Apollon.WPF/Stores/ModalNavigationStore.cs | 3 +--
Apollon.WPF/Stores/NavigationStore.cs | 28 ++++++++++++++++++++
Apollon.WPF/Themes/Common.xaml | 17 ++++++++++++
Apollon.WPF/ViewModels/MainViewModel.cs | 17 ++++++++++--
Apollon.WPF/ViewModels/NavBarViewModel.cs | 16 ++++++++++++
Apollon.WPF/ViewModels/OverviewViewModel.cs | 9 ++++---
Apollon.WPF/Views/Layout.xaml | 23 ++++++++++++++++
Apollon.WPF/Views/Layout.xaml.cs | 28 ++++++++++++++++++++
Apollon.WPF/Views/NavBarView.xaml | 14 ++++++++++
Apollon.WPF/Views/NavBarView.xaml.cs | 28 ++++++++++++++++++++
Apollon.WPF/Views/OverviewView.xaml | 19 +++++++-------
15 files changed, 250 insertions(+), 25 deletions(-)
create mode 100644 Apollon.WPF/Commands/NavigatCommand.cs
create mode 100644 Apollon.WPF/Stores/NavigationStore.cs
create mode 100644 Apollon.WPF/Themes/Common.xaml
create mode 100644 Apollon.WPF/ViewModels/NavBarViewModel.cs
create mode 100644 Apollon.WPF/Views/Layout.xaml
create mode 100644 Apollon.WPF/Views/Layout.xaml.cs
create mode 100644 Apollon.WPF/Views/NavBarView.xaml
create mode 100644 Apollon.WPF/Views/NavBarView.xaml.cs
diff --git a/Apollon.WPF/App.xaml b/Apollon.WPF/App.xaml
index d4263ba..88905b4 100644
--- a/Apollon.WPF/App.xaml
+++ b/Apollon.WPF/App.xaml
@@ -7,6 +7,7 @@
+
diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs
index e2b5ffa..8bc3dff 100644
--- a/Apollon.WPF/App.xaml.cs
+++ b/Apollon.WPF/App.xaml.cs
@@ -22,6 +22,7 @@ namespace Apollon.WPF
///
public partial class App : Application
{
+ private readonly NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly TournamentsDbContextFactory _tournamentsDbContextFactory;
private readonly IGetAllTournamentsQuery _getAllTournamentQuery;
@@ -36,6 +37,7 @@ namespace Apollon.WPF
{
string connectionString = "Server=NATHALIE-PC\\NATLINUXDB;Database=Apollon;Trusted_Connection=True;MultipleActiveResultSets=true";
+ _navigationStore = new NavigationStore();
_modalNavigationStore = new ModalNavigationStore();
_tournamentsDbContextFactory = new TournamentsDbContextFactory(
new DbContextOptionsBuilder().UseSqlServer(connectionString).Options);
@@ -52,15 +54,22 @@ namespace Apollon.WPF
{
context.Database.Migrate();
}
-
+
OverviewViewModel overviewViewModel = new OverviewViewModel(
_tournamentStore,
_selectedTournamentStore,
- _modalNavigationStore);
+ _modalNavigationStore,
+ _navigationStore);
+
+ _navigationStore.CurrentViewModel = new OverviewViewModel(
+ _tournamentStore,
+ _selectedTournamentStore,
+ _modalNavigationStore,
+ _navigationStore);
MainWindow = new MainWindow()
{
- DataContext = new MainViewModel(_modalNavigationStore, overviewViewModel)
+ DataContext = new MainViewModel(_modalNavigationStore, overviewViewModel,_navigationStore)
};
MainWindow.Show();
diff --git a/Apollon.WPF/Commands/NavigatCommand.cs b/Apollon.WPF/Commands/NavigatCommand.cs
new file mode 100644
index 0000000..d2a16b4
--- /dev/null
+++ b/Apollon.WPF/Commands/NavigatCommand.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.Commands
+{
+ public class NavigatCommand : CommandBase
+ where TViewModel : ViewModelBase
+ {
+ private readonly NavigationStore _navigationStore;
+ private readonly Func _createViewModel;
+
+ public NavigatCommand(NavigationStore navigationStore, Func createViewModel)
+ {
+ _navigationStore = navigationStore;
+ _createViewModel = createViewModel;
+ }
+
+ public override void Execute(object parameter)
+ {
+
+ _navigationStore.CurrentViewModel = _createViewModel();
+ }
+ }
+}
diff --git a/Apollon.WPF/MainWindow.xaml b/Apollon.WPF/MainWindow.xaml
index e0fdb7e..fca424f 100644
--- a/Apollon.WPF/MainWindow.xaml
+++ b/Apollon.WPF/MainWindow.xaml
@@ -15,7 +15,8 @@
Background="Transparent"
AllowsTransparency="True"
WindowStyle="None"
- ResizeMode="NoResize">
+ ResizeMode="NoResize"
+ MouseDown="Window_MouseDown">
@@ -26,6 +27,12 @@
+
+
+
+
+
+
@@ -37,12 +44,21 @@
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+