diff --git a/Apollon.WPF/Models/Tournament.cs b/Apollon.WPF/Models/Tournament.cs index 500c594..2bfbfcb 100644 --- a/Apollon.WPF/Models/Tournament.cs +++ b/Apollon.WPF/Models/Tournament.cs @@ -8,21 +8,21 @@ namespace Apollon.WPF.Models { public class Tournament { - public Tournament(string organisation, string tournamentname, string category, DateTime startdate, DateTime enddate, string location) + public Tournament(string organisation, string tournamentname, string category, string location) { Organisation = organisation; Tournamentname = tournamentname; Category = category; - Startdate = startdate; - Enddate = enddate; + //Startdate = startdate; + //Enddate = enddate; Location = location; - } + } public string Organisation { get; } public string Tournamentname { get; } public string Category { get; } - public DateTime Startdate { get; } - public DateTime Enddate { get; } + //public DateTime Startdate { get; } + //public DateTime Enddate { get; } public string Location { get; } } } diff --git a/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs index df24240..958d36d 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs @@ -18,13 +18,30 @@ namespace Apollon.WPF.ViewModels public string Organisation => _selectedTournament?.Organisation ?? "keine Organisation"; public string Tournamentname => _selectedTournament?.Tournamentname ?? "kein Name"; public string Category => _selectedTournament?.Category ?? "keine Kategorie"; - public DateTime Startdate => _selectedTournament?.Startdate ?? DateTime.MinValue; - public DateTime Enddate => _selectedTournament?.Enddate ?? DateTime.MinValue; + //public DateTime Startdate => _selectedTournament?.Startdate ?? DateTime.MinValue; + //public DateTime Enddate => _selectedTournament?.Enddate ?? DateTime.MinValue; public string Location => _selectedTournament?.Location ?? "kein Ort"; public ApollonOverviewDetailsViewModel(SelectedTournamentStore selectedTournamentStore) { _selectedTournamentStore = selectedTournamentStore; + + _selectedTournamentStore.SelectedTournamentChanged += SelectedTournamentStore_SelectedTournamentChanged; + } + + protected override void Dispose() + { + _selectedTournamentStore.SelectedTournamentChanged -= SelectedTournamentStore_SelectedTournamentChanged; + base.Dispose(); + } + + private void SelectedTournamentStore_SelectedTournamentChanged() + { + OnPropertyChanged(nameof(hasSelectedTournament)); + OnPropertyChanged(nameof(Organisation)); + OnPropertyChanged(nameof(Tournamentname)); + OnPropertyChanged(nameof(Category)); + OnPropertyChanged(nameof(Location)); } } } diff --git a/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs index 1fdcb13..e0ac067 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs @@ -1,4 +1,5 @@ -using System; +using Apollon.WPF.Models; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,13 +10,14 @@ namespace Apollon.WPF.ViewModels { public class ApollonOverviewListingItemViewModel : ViewModelBase { - public string Tournamentname { get; } - public ICommand DeleteCommand { get; } + public Tournament Tournament { get;} - public ApollonOverviewListingItemViewModel(string tournamentname) + public string Tournamentname => Tournament.Tournamentname; + public ICommand DeleteCommand { get; } + + public ApollonOverviewListingItemViewModel(Tournament tournament) { - Tournamentname = tournamentname; - + Tournament = tournament; } } } diff --git a/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs index 352fe9b..a2292cc 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs @@ -1,4 +1,5 @@ -using Apollon.WPF.Stores; +using Apollon.WPF.Models; +using Apollon.WPF.Stores; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -11,15 +12,37 @@ namespace Apollon.WPF.ViewModels public class ApollonOverviewListingViewModel : ViewModelBase { private readonly ObservableCollection _apollonOverviewListingItemViewModels; + private readonly SelectedTournamentStore _selectedTournamentStore; + public IEnumerable ApollonOverviewListingItemViewModels => _apollonOverviewListingItemViewModels; - public ApollonOverviewListingViewModel(SelectedTournamentStore _selectedTournamentStore) + private ApollonOverviewListingItemViewModel _selectedOverviewListingItemViewModel; + + public ApollonOverviewListingItemViewModel SelectedOverviewListingItemViewModel { + get + { + return _selectedOverviewListingItemViewModel; + } + set + { + _selectedOverviewListingItemViewModel = value; + OnPropertyChanged(nameof(SelectedOverviewListingItemViewModel)); + + _selectedTournamentStore.SelectedTournament = _selectedOverviewListingItemViewModel.Tournament; + } + } + + public ApollonOverviewListingViewModel(SelectedTournamentStore selectedTournamentStore) + { + + _selectedTournamentStore = selectedTournamentStore; _apollonOverviewListingItemViewModels = new ObservableCollection(); - _apollonOverviewListingItemViewModels.Add(new ApollonOverviewListingItemViewModel("Testmeisterschaft1")); - _apollonOverviewListingItemViewModels.Add(new ApollonOverviewListingItemViewModel("Testmeisterschaft2")); - _apollonOverviewListingItemViewModels.Add(new ApollonOverviewListingItemViewModel("Testmeisterschaft3")); + _apollonOverviewListingItemViewModels.Add(new ApollonOverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft1", "Halle", "Wiesbaden"))); + _apollonOverviewListingItemViewModels.Add(new ApollonOverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft2", "im Freien", "Berlin"))); + _apollonOverviewListingItemViewModels.Add(new ApollonOverviewListingItemViewModel(new Tournament("DSB", "Deutschemeisterschaft3", "Halle", "Bruchsal"))); + } } } diff --git a/Apollon.WPF/ViewModels/ViewModelBase.cs b/Apollon.WPF/ViewModels/ViewModelBase.cs index ecce3c5..b9e8f40 100644 --- a/Apollon.WPF/ViewModels/ViewModelBase.cs +++ b/Apollon.WPF/ViewModels/ViewModelBase.cs @@ -15,5 +15,7 @@ namespace Apollon.WPF.ViewModels { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } + + protected virtual void Dispose() { } } } diff --git a/Apollon.WPF/Views/Components/ApollonOverViewListing.xaml b/Apollon.WPF/Views/Components/ApollonOverViewListing.xaml index 2b6e2a9..c710603 100644 --- a/Apollon.WPF/Views/Components/ApollonOverViewListing.xaml +++ b/Apollon.WPF/Views/Components/ApollonOverViewListing.xaml @@ -18,7 +18,8 @@ Background="Transparent" BorderBrush="Transparent" Padding="20" - ItemsSource="{Binding ApollonOverviewListingItemViewModels}"> + ItemsSource="{Binding ApollonOverviewListingItemViewModels}" + SelectedItem="{Binding SelectedOverviewListingItemViewModel}">