using System; using System.Collections.Generic; using System.IO; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; namespace RedBookPlayer.GUI.Views { public class SettingsWindow : Window { private readonly Settings _settings; private string _selectedTheme; private ListBox _themeList; public SettingsWindow() {} public SettingsWindow(Settings settings) { DataContext = _settings = settings; InitializeComponent(); } public void ThemeList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) return; _selectedTheme = (string)e.AddedItems[0]; } public void ApplySettings(object sender, RoutedEventArgs e) { if (!string.IsNullOrWhiteSpace(_selectedTheme)) { _settings.SelectedTheme = _selectedTheme; MainWindow.ApplyTheme(_selectedTheme); } SaveKeyboardList(); _settings.Save(); } public void UpdateView() => this.FindControl("VolumeLabel").Text = _settings.Volume.ToString(); void InitializeComponent() { AvaloniaXamlLoader.Load(this); PopulateThemes(); PopulateKeyboardList(); this.FindControl