0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-13 09:50:43 -05:00
loyvsc 441fb128fe Implement NotifyPropertyChangedBase, optimization (!66)
- NotifyPropertyChangedBase created and implemented in classes that inherit INotifyPropertyChangedBase
- Some optimization fixes in models (one of this - `Where(predicate).Count() == 0` to `All(invertedPredicate)`

Co-authored-by: Valery Varaksa <varaksav62@gmail.com>
Reviewed-on: SPT/Launcher#66
Co-authored-by: loyvsc <loyvsc@noreply.dev.sp-tarkov.com>
Co-committed-by: loyvsc <loyvsc@noreply.dev.sp-tarkov.com>
2024-09-02 07:53:58 +00:00

50 lines
1.3 KiB
C#

/* EditionCollection.cs
* License: NCSA Open Source License
*
* Copyright: SPT
* AUTHORS:
*/
using SPT.Launcher.Models.SPT;
using System.Collections.ObjectModel;
using System.ComponentModel;
using SPT.Launcher.Utilities;
namespace SPT.Launcher.Models.Launcher
{
public class EditionCollection : NotifyPropertyChangedBase
{
private bool _hasSelection;
public bool HasSelection
{
get => _hasSelection;
set => SetProperty(ref _hasSelection, value);
}
private int _selectedEditionIndex;
public int SelectedEditionIndex
{
get => _selectedEditionIndex;
set => SetProperty(ref _selectedEditionIndex, value);
}
private SPTEdition _selectedEdition;
public SPTEdition SelectedEdition
{
get => _selectedEdition;
set => SetProperty(ref _selectedEdition, value, () => HasSelection = _selectedEdition != null);
}
public ObservableCollection<SPTEdition> AvailableEditions { get; private set; } = [];
public EditionCollection()
{
SelectedEditionIndex = 0;
foreach(var edition in ServerManager.SelectedServer.editions)
{
AvailableEditions.Add(new SPTEdition(edition));
}
}
}
}