mirror of
https://github.com/Crunchy-DL/Crunchy-Downloader.git
synced 2026-04-22 01:11:58 +00:00
Add - Added a download subs button to the history Chg - Changed CDM error message to include a GitHub wiki link Chg - Changed the style of settings tabs Chg - Changed the date format in the seasons tab Fix - Fixed Crunchyroll seasons numbering issue (e.g., Blue Exorcist) Fix - Fixed window slightly moving on startup Fix - Fixed a bug in the upcoming episodes display for the next week
55 lines
No EOL
1.8 KiB
C#
55 lines
No EOL
1.8 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Layout;
|
|
using Avalonia.Media;
|
|
using Avalonia.Media.Imaging;
|
|
using CRD.Downloader.Crunchyroll.ViewModels;
|
|
using CRD.Downloader.Crunchyroll.Views;
|
|
using CRD.ViewModels.Utils;
|
|
using CRD.Views.Utils;
|
|
using FluentAvalonia.UI.Controls;
|
|
using Image = Avalonia.Controls.Image;
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
namespace CRD.ViewModels;
|
|
|
|
public partial class SettingsPageViewModel : ViewModelBase{
|
|
|
|
public ObservableCollection<TabViewItem> Tabs{ get; } = new();
|
|
|
|
private TabViewItem CreateTab(string header, string iconPath, UserControl content, object viewModel){
|
|
content.DataContext = viewModel;
|
|
|
|
Bitmap bitmap = null;
|
|
try{
|
|
// Load the image using AssetLoader.Open
|
|
bitmap = new Bitmap(Avalonia.Platform.AssetLoader.Open(new Uri(iconPath)));
|
|
} catch (Exception ex){
|
|
Console.WriteLine($"Error loading image: {ex.Message}");
|
|
}
|
|
|
|
return new TabViewItem{
|
|
Header = new StackPanel{
|
|
Orientation = Orientation.Horizontal,
|
|
Spacing = 5,
|
|
Children ={
|
|
new Image{ Source = bitmap, Width = 18, Height = 18 },
|
|
new TextBlock{ Text = header, FontSize = 16}
|
|
}
|
|
},
|
|
IsClosable = false,
|
|
Content = content
|
|
};
|
|
}
|
|
|
|
public SettingsPageViewModel(){
|
|
// Add initial tabs
|
|
Tabs.Add(CreateTab("General Settings", "avares://CRD/Assets/app_icon.ico", new GeneralSettingsView(), new GeneralSettingsViewModel()));
|
|
Tabs.Add(CreateTab("Crunchyroll Settings", "avares://CRD/Assets/crunchy_icon_round.png", new CrunchyrollSettingsView(), new CrunchyrollSettingsViewModel()));
|
|
|
|
}
|
|
|
|
|
|
} |