diff --git a/Apollon.WPF/Apollon.WPF.csproj b/Apollon.WPF/Apollon.WPF.csproj index d4e24f0..9ed4feb 100644 --- a/Apollon.WPF/Apollon.WPF.csproj +++ b/Apollon.WPF/Apollon.WPF.csproj @@ -3,7 +3,7 @@ WinExe net6.0-windows - enable + disable true diff --git a/Apollon.WPF/App.xaml.cs b/Apollon.WPF/App.xaml.cs index 698b254..fce5914 100644 --- a/Apollon.WPF/App.xaml.cs +++ b/Apollon.WPF/App.xaml.cs @@ -1,4 +1,5 @@ -using Apollon.WPF.ViewModels; +using Apollon.WPF.Stores; +using Apollon.WPF.ViewModels; using System; using System.Collections.Generic; using System.Configuration; @@ -14,11 +15,17 @@ namespace Apollon.WPF /// public partial class App : Application { + private readonly SelectedTournamentStore _selectedTournamentStore; + + public App() + { + _selectedTournamentStore = new SelectedTournamentStore(); + } protected override void OnStartup(StartupEventArgs e) { MainWindow = new MainWindow() { - DataContext = new ApollonOverviewViewModel() + DataContext = new ApollonOverviewViewModel(_selectedTournamentStore) }; MainWindow.Show(); diff --git a/Apollon.WPF/Models/Tournament.cs b/Apollon.WPF/Models/Tournament.cs new file mode 100644 index 0000000..ad6e739 --- /dev/null +++ b/Apollon.WPF/Models/Tournament.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Apollon.WPF.Models +{ + public class Tournament + { + public Tournament(string organisation, string tournamentname, string category, DateTime datetime, string location) + { + Organisation = organisation; + Tournamentname = tournamentname; + Category = category; + Datetime = datetime; + Location = location; + } + + public string Organisation { get; } + public string Tournamentname { get; } + public string Category { get; } + public DateTime Datetime { get; } + public string Location { get; } + } +} diff --git a/Apollon.WPF/Stores/SelectedApollonStore.cs b/Apollon.WPF/Stores/SelectedApollonStore.cs deleted file mode 100644 index 4b1afe7..0000000 --- a/Apollon.WPF/Stores/SelectedApollonStore.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Apollon.WPF.Stores -{ - public class SelectedApollonStore - { - public int MyProperty { get; set; } - } -} diff --git a/Apollon.WPF/Stores/SelectedTournamentStore.cs b/Apollon.WPF/Stores/SelectedTournamentStore.cs new file mode 100644 index 0000000..8222f53 --- /dev/null +++ b/Apollon.WPF/Stores/SelectedTournamentStore.cs @@ -0,0 +1,29 @@ +using Apollon.WPF.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Apollon.WPF.Stores +{ + public class SelectedTournamentStore + { + private Tournament _selectedTournament; + + public Tournament SelectedTournament + { + get + { + return _selectedTournament; + } + set + { + _selectedTournament = value; + SelectedTournamentChanged?.Invoke(); + } + } + + public event Action SelectedTournamentChanged; + } +} diff --git a/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs index 05b2367..9c7d663 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewDetailsViewModel.cs @@ -1,4 +1,6 @@ -using System; +using Apollon.WPF.Models; +using Apollon.WPF.Stores; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,19 +10,20 @@ namespace Apollon.WPF.ViewModels { public class ApollonOverviewDetailsViewModel : ViewModelBase { - public string Organisation { get; } - public string Tournamentname { get; } - public string Category { get; } - public DateTime Datetime { get; } - public string Location { get; } + private readonly SelectedTournamentStore _selectedTournamentStore; - public ApollonOverviewDetailsViewModel() + private Tournament _selectedTournament => _selectedTournamentStore.SelectedTournament; + + public bool hasSelectedTournament => _selectedTournament != null; + public string Organisation => _selectedTournament?.Organisation ?? "keine Organisation"; + public string Tournamentname => _selectedTournament?.Tournamentname ?? "kein Name"; + public string Category => _selectedTournament?.Category ?? "keine Kategorie"; + //public DateTime Datetime => _selectedTournament + public string Location => _selectedTournament?.Location ?? "kein Ort"; + + public ApollonOverviewDetailsViewModel(SelectedTournamentStore selectedTournamentStore) { - Organisation = "Deutscher Schützenbund"; - Tournamentname = "Deutsche Meisterschaft 2021"; - Category = "Bogenschießen im Freien"; - Datetime = DateTime.Now; - Location = "Wiesbaden"; + _selectedTournamentStore = selectedTournamentStore; } } } diff --git a/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs index 6b93d94..1fdcb13 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewListingItemViewModel.cs @@ -14,7 +14,8 @@ namespace Apollon.WPF.ViewModels public ApollonOverviewListingItemViewModel(string tournamentname) { - Tournamentname = tournamentname; + Tournamentname = tournamentname; + } } } diff --git a/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs index 95b0605..352fe9b 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewListingViewModel.cs @@ -1,4 +1,5 @@ -using System; +using Apollon.WPF.Stores; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -12,7 +13,7 @@ namespace Apollon.WPF.ViewModels private readonly ObservableCollection _apollonOverviewListingItemViewModels; public IEnumerable ApollonOverviewListingItemViewModels => _apollonOverviewListingItemViewModels; - public ApollonOverviewListingViewModel() + public ApollonOverviewListingViewModel(SelectedTournamentStore _selectedTournamentStore) { _apollonOverviewListingItemViewModels = new ObservableCollection(); diff --git a/Apollon.WPF/ViewModels/ApollonOverviewViewModel.cs b/Apollon.WPF/ViewModels/ApollonOverviewViewModel.cs index ca8bf60..994cf94 100644 --- a/Apollon.WPF/ViewModels/ApollonOverviewViewModel.cs +++ b/Apollon.WPF/ViewModels/ApollonOverviewViewModel.cs @@ -1,4 +1,5 @@ -using System; +using Apollon.WPF.Stores; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -13,10 +14,10 @@ namespace Apollon.WPF.ViewModels public ApollonOverviewDetailsViewModel ApollonOverviewDetailsViewModel{ get; } public ICommand AddTournamentCommand { get; } - public ApollonOverviewViewModel() + public ApollonOverviewViewModel(SelectedTournamentStore _selectedTournamentStore) { - ApollonOverviewListingViewModel = new ApollonOverviewListingViewModel(); - ApollonOverviewDetailsViewModel = new ApollonOverviewDetailsViewModel(); + ApollonOverviewListingViewModel = new ApollonOverviewListingViewModel(_selectedTournamentStore); + ApollonOverviewDetailsViewModel = new ApollonOverviewDetailsViewModel(_selectedTournamentStore); } } } diff --git a/Apollon.WPF/ViewModels/ViewModelBase.cs b/Apollon.WPF/ViewModels/ViewModelBase.cs index 070a8f6..ecce3c5 100644 --- a/Apollon.WPF/ViewModels/ViewModelBase.cs +++ b/Apollon.WPF/ViewModels/ViewModelBase.cs @@ -8,12 +8,12 @@ using System.Threading.Tasks; namespace Apollon.WPF.ViewModels { public class ViewModelBase : INotifyPropertyChanged - { + { public event PropertyChangedEventHandler PropertyChanged; - protected virtual void OnPrpertyChanged(string properyName = null) + protected virtual void OnPropertyChanged(string propertyName = null) { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(properyName)); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } }