mirror of
https://github.com/Crunchy-DL/Crunchy-Downloader.git
synced 2026-03-11 09:35:45 +00:00
Added **ability to switch between account profiles** [#372](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/372). Added option to **execute a file when the download queue finishes** [#392](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/392). Added **auto history refresh / auto add to queue** [#394](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/394). Changed **font loading** to also include fonts from the local fonts folder that are not available on Crunchyroll [#371](https://github.com/Crunchy-DL/Crunchy-Downloader/issues/371). Updated packages to latest versions Fixed **history not being saved** after it was updated via the calendar Fixed **Downloaded toggle in history** being slow for large seasons
55 lines
No EOL
1.7 KiB
C#
55 lines
No EOL
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Threading.Tasks;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CRD.Utils;
|
|
using CRD.Utils.Structs;
|
|
using CRD.Utils.UI;
|
|
using FluentAvalonia.UI.Controls;
|
|
|
|
namespace CRD.ViewModels.Utils;
|
|
|
|
public partial class ContentDialogMultiProfileSelectViewModel: ViewModelBase{
|
|
|
|
private readonly CustomContentDialog dialog;
|
|
|
|
[ObservableProperty]
|
|
private AccountProfile _selectedItem;
|
|
|
|
[ObservableProperty]
|
|
private ObservableCollection<AccountProfile> _profileList = [];
|
|
|
|
public ContentDialogMultiProfileSelectViewModel(CustomContentDialog contentDialog, List<AccountProfile> profiles){
|
|
ArgumentNullException.ThrowIfNull(contentDialog);
|
|
|
|
dialog = contentDialog;
|
|
dialog.Closed += DialogOnClosed;
|
|
dialog.PrimaryButtonClick += SaveButton;
|
|
|
|
try{
|
|
_ = LoadProfiles(profiles);
|
|
} catch (Exception e){
|
|
Console.WriteLine(e);
|
|
}
|
|
}
|
|
|
|
private async Task LoadProfiles(List<AccountProfile> profiles){
|
|
foreach (var accountProfile in profiles){
|
|
accountProfile.ProfileImage = await Helpers.LoadImage(accountProfile.AvatarUrl);
|
|
ProfileList.Add(accountProfile);
|
|
}
|
|
}
|
|
|
|
partial void OnSelectedItemChanged(AccountProfile value){
|
|
dialog.Hide(ContentDialogResult.Primary);
|
|
}
|
|
|
|
private void SaveButton(ContentDialog sender, ContentDialogButtonClickEventArgs args){
|
|
dialog.PrimaryButtonClick -= SaveButton;
|
|
}
|
|
|
|
private void DialogOnClosed(ContentDialog sender, ContentDialogClosedEventArgs args){
|
|
dialog.Closed -= DialogOnClosed;
|
|
}
|
|
} |