1using System.Collections.ObjectModel;
2using System.Windows.Input;
3using CommunityToolkit.Mvvm.ComponentModel;
4using CommunityToolkit.Mvvm.Input;
5using MahApps.Metro.Controls.Dialogs;
20 #region Calculated Races
25 public ObservableCollection<RacesVariant>
AllRacesVariants => _raceService?.AllRacesVariants;
73 get => _currentRacesVariant;
78 _currentRacesVariant?.UpdateNotAssignedStarts(_personService.GetAllPersonStarts());
93 int newVariantID = _raceService?.RecalculateVariantIDs(currentID) ?? -1;
114 item.IsPersistent =
false;
116 CurrentRacesVariant.IsPersistent = value;
126 #region Highlight Feature
134 get => _highlightPersonStartMode;
137 if (SetProperty(ref _highlightPersonStartMode, value))
149 public List<Person>
AvailablePersons => _personService?.GetPersons().OrderBy(p => p.Name).ToList();
151 private Person _highlightedPerson;
157 get => _highlightedPerson;
160 if (SetProperty(ref _highlightedPerson, value))
181 get => _highlightedSwimmingStyle;
184 if (SetProperty(ref _highlightedSwimmingStyle, value))
193 private Genders _highlightedGender;
199 get => _highlightedGender;
202 if (SetProperty(ref _highlightedGender, value))
211 private ushort _highlightedDistance;
217 get => _highlightedDistance;
220 if (SetProperty(ref _highlightedDistance, value))
234 List<PersonStart> personStarts = _personService.GetAllPersonStarts();
244 default: personStart.IsHighlighted =
false;
break;
256 private IDialogCoordinator _dialogCoordinator;
269 _raceService = raceService;
270 _workspaceService = workspaceService;
271 _personService = personService;
272 _dialogCoordinator = dialogCoordinator;
275 _raceService.PropertyChanged += (sender, e) =>
277 switch (e.PropertyName)
291 _raceService.AllRacesVariants.CollectionChanged += (sender, e) =>
302 #region Calculate Races Variants Command
304 private ICommand _calculateRacesVariantsCommand;
314 _progressDialog.ProgressNumberDecimals = 1;
316 double nextProgressLevelIteration = 0.0;
319 if (progress >= nextProgressLevelIteration)
321 nextProgressLevelIteration += 0.1;
322 _progressDialog.Progress1 = progress;
325 double nextProgressLevelSolution = 0.0;
328 if (progress >= nextProgressLevelSolution)
330 nextProgressLevelSolution += 0.5;
331 _progressDialog.Progress2 = progress;
335 CancellationTokenSource cancellationTokenSource =
new CancellationTokenSource();
336 _progressDialog.OnCanceled += (sender, e) => cancellationTokenSource.Cancel();
337 await _dialogCoordinator.ShowMetroDialogAsync(_shellVM, _progressDialog);
341 await _raceService.CalculateRacesVariants(cancellationTokenSource.Token, onProgressIteration, onProgressSolution);
344 await _dialogCoordinator.HideMetroDialogAsync(_shellVM, _progressDialog);
347 ushort numberRequestedVariants = _workspaceService?.Settings?.GetSettingValue<ushort>(
WorkspaceSettings.GROUP_RACE_CALCULATION,
WorkspaceSettings.SETTING_RACE_CALCULATION_NUM_RACE_VARIANTS_AFTER_CALCULATION) ?? 0;
348 if (numberVariants < numberRequestedVariants)
354 catch (OperationCanceledException)
356 await _dialogCoordinator.HideMetroDialogAsync(_shellVM, _progressDialog);
360 await _dialogCoordinator.HideMetroDialogAsync(_shellVM, _progressDialog);
368 #region Other Commands
370 private ICommand _addNewRaceCommand;
374 public ICommand
AddNewRaceCommand => _addNewRaceCommand ?? (_addNewRaceCommand =
new RelayCommand(() =>
384 private ICommand _cleanupRacesCommand;
388 public ICommand
CleanupRacesCommand => _cleanupRacesCommand ?? (_cleanupRacesCommand =
new RelayCommand(() =>
390 _raceService?.CleanupRacesVariants();
395 private ICommand _addNewRaceVariantCommand;
402 _raceService?.AddRacesVariant(newVariant);
412 private ICommand _removeRaceVariantCommand;
421 MessageDialogStyle.AffirmativeAndNegative,
424 if (result == MessageDialogResult.Affirmative)
443 private ICommand _copyRaceVariantCommand;
450 _raceService?.AddRacesVariant(copyVariant);
460 private ICommand _reorderRaceVariantsCommand;
466 _raceService?.SortVariantsByScore();
477 _raceService.CleanupRacesVariants(
false);
478 _raceService.RecalculateVariantIDs();
480 ushort numSwimLanes = _workspaceService?.Settings?.GetSettingValue<ushort>(
WorkspaceSettings.GROUP_RACE_CALCULATION,
WorkspaceSettings.SETTING_RACE_CALCULATION_NUMBER_OF_SWIM_LANES) ?? 0;
481 DropAllowedHandler.Instance.MaxItemsInTargetCollection = numSwimLanes;
Interaktionslogik für DoubleProgressDialog.xaml.
ushort Distance
Distance in meters for this competition (e.g.
Class describing a start of a person.
Competition CompetitionObj
Reference to the competition object to which the start belongs.
override bool Equals(object obj)
Compare if two PersonStarts are equal.
Class that represents a single race.
Comparer that only uses most properties of a RacesVariant to determine equality:
Class that represents a combination variant of all single races.
Service used to manage Race and RacesVariant objects.
ObservableCollection< RacesVariant > AllRacesVariants
List with all RacesVariant (including the loaded and calculated ones)
RacesVariant PersistedRacesVariant
RacesVariant object that is persisted (saved/loaded to/from a file).
Class holding all workspace settings.
Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
static string SolutionProgressString
Sucht eine lokalisierte Zeichenfolge, die Solution Progress ähnelt.
static string CalculationWarningTooLessVariantsString
Sucht eine lokalisierte Zeichenfolge, die Less variants than requested were calculated ({0}...
static string IterationProgressString
Sucht eine lokalisierte Zeichenfolge, die Iteration Progress ähnelt.
static string CancelString
Sucht eine lokalisierte Zeichenfolge, die Cancel ähnelt.
static string CalculateRacesVariantsString
Sucht eine lokalisierte Zeichenfolge, die Calculate Races Variants ähnelt.
static string DeleteConfirmationTitleString
Sucht eine lokalisierte Zeichenfolge, die Really delete?
static string DeleteRaceVariantConfirmationString
Sucht eine lokalisierte Zeichenfolge, die Really delete the selected variant?
static string ErrorString
Sucht eine lokalisierte Zeichenfolge, die Error ähnelt.
static string RemoveRaceVariantString
Sucht eine lokalisierte Zeichenfolge, die Remove Variant ähnelt.
ICommand AddNewRaceVariantCommand
Add a new RacesVariant element to the RaceService.AllRacesVariants
bool CurrentRacesVariantIsPersistent
Property wrapper for the RacesVariant.IsPersistent property of the CurrentRacesVariant.
bool AreFriendGroupsAvailable
True, if there are friend groups available in the IPersonService
bool AreRacesVariantsAvailable
True, if there is at least one element in AllRacesVariants
ICommand AddNewRaceCommand
Command to add a new Race to the CurrentRacesVariant
void recalculateVariantIDs()
Recalculate the variant IDs for all elements in AllRacesVariants
void recalculateHighlightedPersonStarts()
Recalculate the PersonStart.IsHighlighted property for all PersonStart objects depending on the Highl...
void OnNavigatedFrom()
OnNavigatedFrom method to handle navigation away from this object.
ICommand ReorderRaceVariantsCommand
Reorder the RacesVariant variants by score and then recalculate the variant IDs.
ICommand CleanupRacesCommand
Command to cleanup all RacesVariant in RaceService.AllRacesVariants
Genders HighlightedGender
All PersonStart elements that match this Genders will be highlighted if the HighlightPersonStartMode ...
Person HighlightedPerson
All PersonStart elements that match this Person will be highlighted if the HighlightPersonStartMode i...
PrepareRacesViewModel(IRaceService raceService, IWorkspaceService workspaceService, IPersonService personService, IDialogCoordinator dialogCoordinator, ShellViewModel shellVM)
Constructor of the prepare races view model.
ICommand CalculateRacesVariantsCommand
Command to calculate new RacesVariant variants.
int CurrentVariantID
RacesVariant.VariantID of the CurrentRacesVariant Use 0 to select the RaceService....
SwimmingStyles HighlightedSwimmingStyle
All PersonStart elements that match this SwimmingStyles will be highlighted if the HighlightPersonSta...
List< Person > AvailablePersons
List with all available Person objects.
RacesVariant CurrentRacesVariant
RacesVariant that is currently displayed on the view
ICommand CopyRaceVariantCommand
Copy the CurrentRacesVariant and add it as new variant to RaceService.AllRacesVariants
List< SwimmingStyles > AvailableSwimmingStyles
List with all available SwimmingStyles
ObservableCollection< RacesVariant > AllRacesVariants
List with all RacesVariant
HighlightPersonStartModes HighlightPersonStartMode
Currently active highlight mode.
ICommand RemoveRaceVariantCommand
Remove the CurrentRacesVariant from the RaceService.AllRacesVariants
void OnNavigatedTo(object parameter)
OnNavigatedTo method to handle navigation to this object.
ushort HighlightedDistance
All PersonStart elements that match this distance will be highlighted if the HighlightPersonStartMode...
ViewModel for the main shell of the application.
Interface for objects that need to handle navigation events.
Interface for a service used to get and store a list of Person objects.
Interface for a service used to manage Race and RacesVariant objects.
Interface for a service used to manage a workspace.
delegate void ProgressDelegate(object sender, float progress, string currentStep="")
Delegate void for progress changes.
SwimmingStyles
Available swimming styles.
Genders
Available genders for a person.
HighlightPersonStartModes
Enum to define the different modes to highlight a PersonStart
@ Person
Highlight all PersonStart objects that have the same Person object.
@ Enum
Display an editor for an enumeration value.