diff options
| author | TSR Berry <20988865+TSRBerry@users.noreply.github.com> | 2023-04-08 01:22:00 +0200 |
|---|---|---|
| committer | Mary <thog@protonmail.com> | 2023-04-27 23:51:14 +0200 |
| commit | cee712105850ac3385cd0091a923438167433f9f (patch) | |
| tree | 4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs | |
| parent | cd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff) | |
Move solution and projects to src
Diffstat (limited to 'Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs')
| -rw-r--r-- | Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs b/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs deleted file mode 100644 index 097634a8..00000000 --- a/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs +++ /dev/null @@ -1,120 +0,0 @@ -using DynamicData; -using DynamicData.Binding; -using Ryujinx.Ava.Common.Locale; -using Ryujinx.Ava.UI.Models; -using Ryujinx.HLE.HOS.Services.Account.Acc; -using System.Collections.Generic; -using System.Collections.ObjectModel; - -namespace Ryujinx.Ava.UI.ViewModels -{ - public class UserSaveManagerViewModel : BaseModel - { - private int _sortIndex; - private int _orderIndex; - private string _search; - private ObservableCollection<SaveModel> _saves = new(); - private ObservableCollection<SaveModel> _views = new(); - private AccountManager _accountManager; - - public string SaveManagerHeading => LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.SaveManagerHeading, _accountManager.LastOpenedUser.Name, _accountManager.LastOpenedUser.UserId); - - public int SortIndex - { - get => _sortIndex; - set - { - _sortIndex = value; - OnPropertyChanged(); - Sort(); - } - } - - public int OrderIndex - { - get => _orderIndex; - set - { - _orderIndex = value; - OnPropertyChanged(); - Sort(); - } - } - - public string Search - { - get => _search; - set - { - _search = value; - OnPropertyChanged(); - Sort(); - } - } - - public ObservableCollection<SaveModel> Saves - { - get => _saves; - set - { - _saves = value; - OnPropertyChanged(); - Sort(); - } - } - - public ObservableCollection<SaveModel> Views - { - get => _views; - set - { - _views = value; - OnPropertyChanged(); - } - } - - public UserSaveManagerViewModel(AccountManager accountManager) - { - _accountManager = accountManager; - } - - public void Sort() - { - Saves.AsObservableChangeSet() - .Filter(Filter) - .Sort(GetComparer()) - .Bind(out var view).AsObservableList(); - - _views.Clear(); - _views.AddRange(view); - OnPropertyChanged(nameof(Views)); - } - - private bool Filter(object arg) - { - if (arg is SaveModel save) - { - return string.IsNullOrWhiteSpace(_search) || save.Title.ToLower().Contains(_search.ToLower()); - } - - return false; - } - - private IComparer<SaveModel> GetComparer() - { - switch (SortIndex) - { - case 0: - return OrderIndex == 0 - ? SortExpressionComparer<SaveModel>.Ascending(save => save.Title) - : SortExpressionComparer<SaveModel>.Descending(save => save.Title); - case 1: - return OrderIndex == 0 - ? SortExpressionComparer<SaveModel>.Ascending(save => save.Size) - : SortExpressionComparer<SaveModel>.Descending(save => save.Size); - default: - return null; - } - } - } -}
\ No newline at end of file |
