diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs
index d8e0ca4..053c480 100644
--- a/Apollon.WPF/App.xaml.cs
+++ b/Apollon.WPF/App.xaml.cs
@@ -25,7 +25,7 @@ namespace Apollon.WPF
}
protected override void OnStartup(StartupEventArgs e)
{
- OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore);
+ OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore, _modalNavigationStore);
MainWindow = new MainWindow()
{
diff --git a/Apollon.WPF/Commands/CloseModalCommand.cs b/Apollon.WPF/Commands/CloseModalCommand.cs
new file mode 100644
index 0000000..af1d750
--- /dev/null
+++ b/Apollon.WPF/Commands/CloseModalCommand.cs
@@ -0,0 +1,24 @@
+using Apollon.WPF.Stores;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Apollon.WPF.Commands
+{
+ public class CloseModalCommand : CommandBase
+ {
+ private readonly ModalNavigationStore _modalNavigationStore;
+
+ public CloseModalCommand(ModalNavigationStore modalNavigationStore)
+ {
+ _modalNavigationStore = modalNavigationStore;
+ }
+
+ public override void Execute(object parameter)
+ {
+ _modalNavigationStore.Close();
+ }
+ }
+}
diff --git a/Apollon.WPF/Commands/CommandBase.cs b/Apollon.WPF/Commands/CommandBase.cs
new file mode 100644
index 0000000..d5f4000
--- /dev/null
+++ b/Apollon.WPF/Commands/CommandBase.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace Apollon.WPF.Commands
+{
+ public abstract class CommandBase : ICommand
+ {
+ public event EventHandler CanExecuteChanged;
+
+ public virtual bool CanExecute(object parameter)
+ {
+ return true;
+ }
+
+ public abstract void Execute(object parameter);
+
+ protected virtual void OnCanExecutedChanged()
+ {
+ CanExecuteChanged?.Invoke(this, new EventArgs());
+ }
+ }
+}
diff --git a/Apollon.WPF/Commands/OpenAddTournamentCommand.cs b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs
new file mode 100644
index 0000000..ca914bc
--- /dev/null
+++ b/Apollon.WPF/Commands/OpenAddTournamentCommand.cs
@@ -0,0 +1,26 @@
+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
+{
+ internal class OpenAddTournamentCommand : CommandBase
+ {
+ private readonly ModalNavigationStore _modalNavigationStore;
+
+ public OpenAddTournamentCommand(ModalNavigationStore modalNavigationStore)
+ {
+ _modalNavigationStore = modalNavigationStore;
+ }
+
+ public override void Execute(object parameter)
+ {
+ AddTournametViewModel addTournametViewModel = new AddTournametViewModel(_modalNavigationStore);
+ _modalNavigationStore.CurrentViewModel = addTournametViewModel;
+ }
+ }
+}
diff --git a/Apollon.WPF/Stores/ModalNavigationStore.cs b/Apollon.WPF/Stores/ModalNavigationStore.cs
index 908a6ab..9baa686 100644
--- a/Apollon.WPF/Stores/ModalNavigationStore.cs
+++ b/Apollon.WPF/Stores/ModalNavigationStore.cs
@@ -27,5 +27,10 @@ namespace Apollon.WPF.Stores
public bool IsOpen => CurrentViewModel != null;
public event Action CurrentViewModelChanged;
- }
+
+ internal void Close()
+ {
+ CurrentViewModel = null;
+ }
+ }
}
diff --git a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs
index d4b6552..0ccd17d 100644
--- a/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs
+++ b/Apollon.WPF/ViewModels/AddEditDetailsViewModel.cs
@@ -95,8 +95,15 @@ namespace Apollon.WPF.ViewModels
}
public bool CanSubmit => !string.IsNullOrEmpty(Tournamentname);
+
public ICommand SubmitCommand { get; }
public ICommand CancelCommand { get; }
+
+ public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand)
+ {
+ SubmitCommand = submitCommand;
+ CancelCommand = cancelCommand;
+ }
}
diff --git a/Apollon.WPF/ViewModels/AddTournametViewModel.cs b/Apollon.WPF/ViewModels/AddTournametViewModel.cs
index 7d6c537..e87f693 100644
--- a/Apollon.WPF/ViewModels/AddTournametViewModel.cs
+++ b/Apollon.WPF/ViewModels/AddTournametViewModel.cs
@@ -1,8 +1,11 @@
-using System;
+using Apollon.WPF.Commands;
+using Apollon.WPF.Stores;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
namespace Apollon.WPF.ViewModels
{
@@ -10,9 +13,10 @@ namespace Apollon.WPF.ViewModels
{
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
- public AddTournametViewModel()
+ public AddTournametViewModel(ModalNavigationStore modalNavigationStore)
{
- AddEditDetailsViewModel = new AddEditDetailsViewModel();
+ ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
+ AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand);
}
}
diff --git a/Apollon.WPF/ViewModels/EditTournamentViewModel.cs b/Apollon.WPF/ViewModels/EditTournamentViewModel.cs
index ba57c62..7cc36d3 100644
--- a/Apollon.WPF/ViewModels/EditTournamentViewModel.cs
+++ b/Apollon.WPF/ViewModels/EditTournamentViewModel.cs
@@ -1,17 +1,22 @@
-using System;
+using Apollon.WPF.Commands;
+using Apollon.WPF.Stores;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
namespace Apollon.WPF.ViewModels
{
public class EditTournamentViewModel : ViewModelBase
{
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
- public EditTournamentViewModel()
+
+ public EditTournamentViewModel(ModalNavigationStore modalNavigationStore)
{
- AddEditDetailsViewModel = new AddEditDetailsViewModel();
+ ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
+ AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand); ;
}
}
}
diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs
index 4659c40..b127493 100644
--- a/Apollon.WPF/ViewModels/OverviewViewModel.cs
+++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs
@@ -1,4 +1,5 @@
-using Apollon.WPF.Stores;
+using Apollon.WPF.Commands;
+using Apollon.WPF.Stores;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,12 +13,15 @@ namespace Apollon.WPF.ViewModels
{
public OverviewListingViewModel OverviewListingViewModel { get; }
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
+
public ICommand AddTournamentCommand { get; }
- public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore)
+ public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore, ModalNavigationStore modalNavigationStore)
{
OverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore);
OverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
+
+ AddTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
}
}
}
diff --git a/Apollon.WPF/Views/AddTournamentView.xaml b/Apollon.WPF/Views/AddTournamentView.xaml
index 5c67bdb..5c9cb79 100644
--- a/Apollon.WPF/Views/AddTournamentView.xaml
+++ b/Apollon.WPF/Views/AddTournamentView.xaml
@@ -13,6 +13,7 @@
FontWeight="Bold"
FontSize="25"
Foreground="#0000a0"/>
-
+
diff --git a/Apollon.WPF/Views/Components/AddEditDetails.xaml b/Apollon.WPF/Views/Components/AddEditDetails.xaml
index 2750de6..1d47a5a 100644
--- a/Apollon.WPF/Views/Components/AddEditDetails.xaml
+++ b/Apollon.WPF/Views/Components/AddEditDetails.xaml
@@ -47,7 +47,7 @@
VerticalContentAlignment="Center"/>
-
+