Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
MainViewModel.cs
1using System.Windows.Input;
2using CommunityToolkit.Mvvm.ComponentModel;
3using CommunityToolkit.Mvvm.Input;
8
10
14public class MainViewModel : ObservableObject
15{
19 public ushort CompetitionYear => _workspaceService?.Settings?.GetSettingValue<ushort>(WorkspaceSettings.GROUP_GENERAL, WorkspaceSettings.SETTING_GENERAL_COMPETITIONYEAR) ?? 0;
20
24 public ICommand WorkspaceCommand => _workspaceCommand ?? (_workspaceCommand = new RelayCommand(() => _navigationService.NavigateTo<WorkspaceViewModel>()));
25
29 public ICommand CompetitionCommand => _competitionCommand ?? (_competitionCommand = new RelayCommand(() => _navigationService.NavigateTo<CompetitionViewModel>(), () => _workspaceService.IsWorkspaceOpen));
30
34 public ICommand PeopleCommand => _peopleCommand ?? (_peopleCommand = new RelayCommand(() => _navigationService.NavigateTo<PeopleViewModel>(), () => _workspaceService.IsWorkspaceOpen));
35
39 public ICommand PrepareRacesCommand => _prepareRacesCommand ?? (_prepareRacesCommand = new RelayCommand(() => _navigationService.NavigateTo<PrepareRacesViewModel>(), () => _workspaceService.IsWorkspaceOpen));
40
44 public ICommand PrepareDocumentsCommand => _prepareDocumentsCommand ?? (_prepareDocumentsCommand = new RelayCommand(() => _navigationService.NavigateTo<CreateDocumentsViewModel>(), () => _workspaceService.IsWorkspaceOpen));
45
49 public ICommand TimeInputCommand => _timeInputCommand ?? (_timeInputCommand = new RelayCommand(() => _navigationService.NavigateTo<TimeInputViewModel>(), () => _workspaceService.IsWorkspaceOpen));
50
54 public ICommand ResultsCommand => _resultsCommand ?? (_resultsCommand = new RelayCommand(() => _navigationService.NavigateTo<ResultsViewModel>(), () => _workspaceService.IsWorkspaceOpen));
55
59 public ICommand AnalyticsCommand => _analyticsCommand ?? (_analyticsCommand = new RelayCommand(() => _navigationService.NavigateTo<AnalyticsViewModel>(), () => _workspaceService.IsWorkspaceOpen));
60
61
62 private readonly INavigationService _navigationService;
63 private ICommand _workspaceCommand;
64 private ICommand _competitionCommand;
65 private ICommand _peopleCommand;
66 private ICommand _prepareRacesCommand;
67 private ICommand _prepareDocumentsCommand;
68 private ICommand _timeInputCommand;
69 private ICommand _resultsCommand;
70 private ICommand _analyticsCommand;
71
72 private IWorkspaceService _workspaceService;
73
80 public MainViewModel(INavigationService navigationService, IWorkspaceService workspaceService, IScoreService scoreService)
81 {
82 _navigationService = navigationService;
83 _workspaceService = workspaceService;
84 _workspaceService.PropertyChanged += _workspaceService_PropertyChanged;
85 }
86
87 private void _workspaceService_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
88 {
89 switch (e.PropertyName)
90 {
91 case nameof(IWorkspaceService.Settings): OnPropertyChanged(nameof(CompetitionYear)); break;
93 {
94 ((RelayCommand)CompetitionCommand).NotifyCanExecuteChanged();
95 ((RelayCommand)PeopleCommand).NotifyCanExecuteChanged();
96 ((RelayCommand)PrepareRacesCommand).NotifyCanExecuteChanged();
97 ((RelayCommand)PrepareDocumentsCommand).NotifyCanExecuteChanged();
98 ((RelayCommand)TimeInputCommand).NotifyCanExecuteChanged();
99 ((RelayCommand)ResultsCommand).NotifyCanExecuteChanged();
100 ((RelayCommand)AnalyticsCommand).NotifyCanExecuteChanged();
101 break;
102 }
103 default: break;
104 }
105 }
106}
ViewModel for creating various types of documents such as certificates, overview.
ICommand PrepareDocumentsCommand
Command to navigate to the prepare documents view.
ICommand AnalyticsCommand
Command to navigate to the analytics view.
ushort CompetitionYear
Competition year setting value get from the workspace settings.
ICommand CompetitionCommand
Command to navigate to the competition view.
MainViewModel(INavigationService navigationService, IWorkspaceService workspaceService, IScoreService scoreService)
Constructor for the MainViewModel.
ICommand PrepareRacesCommand
Command to navigate to the prepare races view.
ICommand WorkspaceCommand
Command to navigate to the workspace view.
ICommand ResultsCommand
Command to navigate to the results view.
ICommand TimeInputCommand
Command to navigate to the time input view.
ICommand PeopleCommand
Command to navigate to the people view.
ViewModel for the person overview page.
ViewModel for the results page, showing the sorted persons based on their scores.
ViewModel for the workspace, managing the current workspace folder, settings, and commands to load,...
Interface for a service for handling navigation within the application.
Interface for a service used to calculate the scores for all persons.
Interface for a service used to manage a workspace.
WorkspaceSettings Settings
Settings for the current workspace.
bool IsWorkspaceOpen
If true, a workspace is loaded; if false, not workspace is loaded.