Open/Close AddTournamentModal
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Apollon.WPF
|
|||||||
}
|
}
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore);
|
OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore, _modalNavigationStore);
|
||||||
|
|
||||||
MainWindow = new MainWindow()
|
MainWindow = new MainWindow()
|
||||||
{
|
{
|
||||||
|
|||||||
24
Apollon.WPF/Commands/CloseModalCommand.cs
Normal file
24
Apollon.WPF/Commands/CloseModalCommand.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Apollon.WPF/Commands/CommandBase.cs
Normal file
26
Apollon.WPF/Commands/CommandBase.cs
Normal file
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Apollon.WPF/Commands/OpenAddTournamentCommand.cs
Normal file
26
Apollon.WPF/Commands/OpenAddTournamentCommand.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,5 +27,10 @@ namespace Apollon.WPF.Stores
|
|||||||
public bool IsOpen => CurrentViewModel != null;
|
public bool IsOpen => CurrentViewModel != null;
|
||||||
|
|
||||||
public event Action CurrentViewModelChanged;
|
public event Action CurrentViewModelChanged;
|
||||||
|
|
||||||
|
internal void Close()
|
||||||
|
{
|
||||||
|
CurrentViewModel = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,15 @@ namespace Apollon.WPF.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool CanSubmit => !string.IsNullOrEmpty(Tournamentname);
|
public bool CanSubmit => !string.IsNullOrEmpty(Tournamentname);
|
||||||
|
|
||||||
public ICommand SubmitCommand { get; }
|
public ICommand SubmitCommand { get; }
|
||||||
public ICommand CancelCommand { get; }
|
public ICommand CancelCommand { get; }
|
||||||
|
|
||||||
|
public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand)
|
||||||
|
{
|
||||||
|
SubmitCommand = submitCommand;
|
||||||
|
CancelCommand = cancelCommand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
using System;
|
using Apollon.WPF.Commands;
|
||||||
|
using Apollon.WPF.Stores;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Apollon.WPF.ViewModels
|
namespace Apollon.WPF.ViewModels
|
||||||
{
|
{
|
||||||
@@ -10,9 +13,10 @@ namespace Apollon.WPF.ViewModels
|
|||||||
{
|
{
|
||||||
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
||||||
|
|
||||||
public AddTournametViewModel()
|
public AddTournametViewModel(ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
AddEditDetailsViewModel = new AddEditDetailsViewModel();
|
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
||||||
|
AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
using System;
|
using Apollon.WPF.Commands;
|
||||||
|
using Apollon.WPF.Stores;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Apollon.WPF.ViewModels
|
namespace Apollon.WPF.ViewModels
|
||||||
{
|
{
|
||||||
public class EditTournamentViewModel : ViewModelBase
|
public class EditTournamentViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
|
||||||
public EditTournamentViewModel()
|
|
||||||
|
public EditTournamentViewModel(ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
AddEditDetailsViewModel = new AddEditDetailsViewModel();
|
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
|
||||||
|
AddEditDetailsViewModel = new AddEditDetailsViewModel(null, cancelCommand); ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Apollon.WPF.Stores;
|
using Apollon.WPF.Commands;
|
||||||
|
using Apollon.WPF.Stores;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -12,12 +13,15 @@ namespace Apollon.WPF.ViewModels
|
|||||||
{
|
{
|
||||||
public OverviewListingViewModel OverviewListingViewModel { get; }
|
public OverviewListingViewModel OverviewListingViewModel { get; }
|
||||||
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
|
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
|
||||||
|
|
||||||
public ICommand AddTournamentCommand { get; }
|
public ICommand AddTournamentCommand { get; }
|
||||||
|
|
||||||
public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore)
|
public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore, ModalNavigationStore modalNavigationStore)
|
||||||
{
|
{
|
||||||
OverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore);
|
OverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore);
|
||||||
OverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
|
OverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
|
||||||
|
|
||||||
|
AddTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
FontSize="25"
|
FontSize="25"
|
||||||
Foreground="#0000a0"/>
|
Foreground="#0000a0"/>
|
||||||
<components:AddEditDetails Margin="0 50 0 0"/>
|
<components:AddEditDetails Margin="0 50 0 0"
|
||||||
|
DataContext="{Binding AddEditDetailsViewModel}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
VerticalContentAlignment="Center"/>
|
VerticalContentAlignment="Center"/>
|
||||||
<TextBox Grid.Row="1"
|
<TextBox Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Text="{Binding Tournamentname}"
|
Text="{Binding Tournamentname, UpdateSourceTrigger=PropertyChanged}"
|
||||||
FontFamily="Arial"
|
FontFamily="Arial"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Height="30"
|
Height="30"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
FontSize="25"
|
FontSize="25"
|
||||||
Foreground="#0000a0"/>
|
Foreground="#0000a0"/>
|
||||||
<components:AddEditDetails Margin="0 50 0 0"/>
|
<components:AddEditDetails Margin="0 50 0 0"
|
||||||
|
DataContext="{Binding AddEditDetailsViewModel}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user