ready for display Modal

This commit is contained in:
Natlinux81
2022-08-13 03:55:31 +02:00
parent 29013ae275
commit 13f70e8c4b
9 changed files with 186 additions and 14 deletions

View File

@@ -15,17 +15,21 @@ namespace Apollon.WPF
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
private readonly ModalNavigationStore _modalNavigationStore;
private readonly SelectedTournamentStore _selectedTournamentStore; private readonly SelectedTournamentStore _selectedTournamentStore;
public App() public App()
{ {
_modalNavigationStore = new ModalNavigationStore();
_selectedTournamentStore = new SelectedTournamentStore(); _selectedTournamentStore = new SelectedTournamentStore();
} }
protected override void OnStartup(StartupEventArgs e) protected override void OnStartup(StartupEventArgs e)
{ {
OverviewViewModel overviewViewModel = new OverviewViewModel(_selectedTournamentStore);
MainWindow = new MainWindow() MainWindow = new MainWindow()
{ {
DataContext = new OverviewViewModel(_selectedTournamentStore) DataContext = new MainViewModel(_modalNavigationStore, overviewViewModel)
}; };
MainWindow.Show(); MainWindow.Show();

View File

@@ -16,15 +16,14 @@
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="35"> <RowDefinition Height="auto">
</RowDefinition> </RowDefinition>
<RowDefinition> <RowDefinition>
</RowDefinition> </RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<views:AddTournamentView Grid.RowSpan="2"></views:AddTournamentView > <views:OverviewView Grid.RowSpan="2" DataContext="{Binding OverviewViewModel}"/>
<!--<views:OverviewView Grid.RowSpan="2"/>
<Button Width="25" <Button Width="25"
Height="25" Height="25"
Padding="-4" Padding="-4"
@@ -67,7 +66,7 @@
HorizontalContentAlignment="Center" HorizontalContentAlignment="Center"
HorizontalAlignment="Right" Margin="0,2,104,8" HorizontalAlignment="Right" Margin="0,2,104,8"
Click="Button_Min" Click="Button_Min"
></Button>--> ></Button>
</Grid> </Grid>
</ScrollViewer> </ScrollViewer>

View File

@@ -0,0 +1,31 @@
using Apollon.WPF.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.WPF.Stores
{
public class ModalNavigationStore
{
private ViewModelBase _currentViewModel
;
public ViewModelBase CurrentViewModel
{
get
{
return _currentViewModel;
}
set
{
_currentViewModel = value;
CurrentViewModelChanged?.Invoke();
}
}
public bool IsOpen => CurrentViewModel != null;
public event Action CurrentViewModelChanged;
}
}

View File

@@ -3,10 +3,102 @@ 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
{ {
internal class AddEditDetailsViewModel public class AddEditDetailsViewModel : ViewModelBase
{ {
private string _organisation;
public string Organisation
{
get
{
return _organisation;
}
set
{
_organisation = value;
OnPropertyChanged(nameof(Organisation));
} }
} }
private string _tournamentname;
public string Tounamentname
{
get
{
return _tournamentname;
}
set
{
_tournamentname = value;
OnPropertyChanged(nameof(Tounamentname));
OnPropertyChanged(nameof(CanSubmit));
}
}
private string _category;
public string Category
{
get
{
return _category;
}
set
{
_category = value;
OnPropertyChanged(nameof(Category));
}
}
private string _startdate;
public string Startdate
{
get
{
return _startdate;
}
set
{
_startdate = value;
OnPropertyChanged(nameof(Startdate));
}
}
private string _enddate;
public string Enddate
{
get
{
return _enddate;
}
set
{
_enddate = value;
OnPropertyChanged(nameof(Enddate));
}
}
private string _location;
public string Location
{
get
{
return _location;
}
set
{
_location = value;
OnPropertyChanged(nameof(Location));
}
}
public bool CanSubmit => !string.IsNullOrEmpty(Tounamentname);
public ICommand SubmitCommand { get; }
public ICommand CancleCommand { get; }
}
}

View File

@@ -6,7 +6,14 @@ using System.Threading.Tasks;
namespace Apollon.WPF.ViewModels namespace Apollon.WPF.ViewModels
{ {
internal class AddTournametViewModel public class AddTournametViewModel : ViewModelBase
{ {
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
public AddTournametViewModel()
{
AddEditDetailsViewModel = new AddEditDetailsViewModel();
}
} }
} }

View File

@@ -0,0 +1,38 @@
using Apollon.WPF.Stores;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.WPF.ViewModels
{
public class MainViewModel : ViewModelBase
{
private readonly ModalNavigationStore _modalNavigationStore;
public ViewModelBase CurrentModalViewModel => _modalNavigationStore.CurrentViewModel;
public bool IsModalOpen => _modalNavigationStore.IsOpen;
public OverviewViewModel OverviewViewModel { get; }
public MainViewModel(ModalNavigationStore modalNavigationStore, OverviewViewModel overviewViewModel)
{
_modalNavigationStore = modalNavigationStore;
OverviewViewModel = overviewViewModel;
_modalNavigationStore.CurrentViewModelChanged += ModalNavigationStore_CurrentViewModelChanged;
}
protected override void Dispose()
{
_modalNavigationStore.CurrentViewModelChanged -= ModalNavigationStore_CurrentViewModelChanged;
base.Dispose();
}
private void ModalNavigationStore_CurrentViewModelChanged()
{
OnPropertyChanged(nameof(CurrentModalViewModel));
OnPropertyChanged(nameof(IsModalOpen));
}
}
}

View File

@@ -10,14 +10,14 @@ namespace Apollon.WPF.ViewModels
{ {
public class OverviewViewModel : ViewModelBase public class OverviewViewModel : ViewModelBase
{ {
public OverviewListingViewModel ApollonOverviewListingViewModel { get; } public OverviewListingViewModel OverviewListingViewModel { get; }
public OverviewDetailsViewModel ApollonOverviewDetailsViewModel{ get; } public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
public ICommand AddTournamentCommand { get; } public ICommand AddTournamentCommand { get; }
public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore) public OverviewViewModel(SelectedTournamentStore _selectedTournamentStore)
{ {
ApollonOverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore); OverviewListingViewModel = new OverviewListingViewModel(_selectedTournamentStore);
ApollonOverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore); OverviewDetailsViewModel = new OverviewDetailsViewModel(_selectedTournamentStore);
} }
} }
} }

View File

@@ -75,7 +75,8 @@
Height="25" Height="25"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="0 0 80 0" Margin="0 0 80 0"
IsEnabled="False"/> IsEnabled="{Binding CanSubmit}">
</Button>
<Button Content="Abbrechen" <Button Content="Abbrechen"
Command="{Binding CancelCommand}" Command="{Binding CancelCommand}"
Style="{StaticResource ModernButton}" Style="{StaticResource ModernButton}"

View File

@@ -81,7 +81,7 @@
Foreground="#0000a0"> Foreground="#0000a0">
</TextBlock> </TextBlock>
<components:OverViewListing Height="400" <components:OverViewListing Height="400"
DataContext="{Binding ApollonOverviewListingViewModel}"/> DataContext="{Binding OverviewListingViewModel}"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" <StackPanel Grid.Column="2"
@@ -96,7 +96,7 @@
FontSize="16" FontSize="16"
Foreground="#0000a0"/> Foreground="#0000a0"/>
<components:OverviewDetails Width="320" <components:OverviewDetails Width="320"
DataContext="{Binding ApollonOverviewDetailsViewModel}"/> DataContext="{Binding OverviewDetailsViewModel}"/>
<Button Style="{StaticResource ModernButton}" <Button Style="{StaticResource ModernButton}"
Content="Turnier bearbeiten" Content="Turnier bearbeiten"
FontSize="16" FontSize="16"