diff --git a/RetroBar/PropertiesWindow.xaml b/RetroBar/PropertiesWindow.xaml index be5fde7d..231eb09d 100644 --- a/RetroBar/PropertiesWindow.xaml +++ b/RetroBar/PropertiesWindow.xaml @@ -429,7 +429,8 @@ + Name="ThemeCustomizationsEnabled_CheckBox" + IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=CustomizeThemeEnabled}"> diff --git a/RetroBar/Utilities/CustomizeTheme.cs b/RetroBar/Utilities/CustomizeTheme.cs index ca79f4b9..eb3e7bb8 100644 --- a/RetroBar/Utilities/CustomizeTheme.cs +++ b/RetroBar/Utilities/CustomizeTheme.cs @@ -1,4 +1,5 @@ -using System; +using RetroBar.Utilities; +using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -12,6 +13,7 @@ namespace RetroBar public partial class PropertiesWindow : Window { private static readonly ResourceDictionary _resourceDictionary = System.Windows.Application.Current.Resources; + private bool _hasInitialized = false; protected override void OnInitialized(EventArgs e) { @@ -37,13 +39,25 @@ private void SetupEventHandlers() private void PropertiesWindow_Loaded(object sender, RoutedEventArgs e) { PopulateResourcesList(); -// TODO: get EnableCustomizationControls value from settings - EnableCustomizationControls(false); + EnableCustomizationControls(Settings.Instance.CustomizeThemeEnabled); + + if (Settings.Instance.CustomizeThemeEnabled) + { + if (ResourcesList.SelectedItem is string selectedKey) + { + UpdateSelectedResourceDetails(selectedKey); + } + } + + _hasInitialized = true; } private void ThemeCustomizationsEnabled_CheckBox_OnChecked(object sender, RoutedEventArgs e) { + if(!_hasInitialized){return;} + EnableCustomizationControls(true); + _settingsCustomizeThemeEnabled = true; if (ResourcesList.SelectedItem is string selectedKey) { @@ -53,7 +67,10 @@ private void ThemeCustomizationsEnabled_CheckBox_OnChecked(object sender, Routed private void ThemeCustomizationsEnabled_CheckBox_OnUnChecked(object sender, RoutedEventArgs e) { + if(!_hasInitialized){return;} + EnableCustomizationControls(false); + _settingsCustomizeThemeEnabled = false; } private void ChangeColorButton_Click(object sender, RoutedEventArgs e) @@ -72,6 +89,8 @@ private void ResetColorButton_Click(object sender, RoutedEventArgs e) private void ResourcesList_SelectionChanged(object sender, SelectionChangedEventArgs e) { + if(!_hasInitialized){return;} + if (ResourcesList.SelectedItem is string selectedKey) { UpdateSelectedResourceDetails(selectedKey); @@ -170,6 +189,19 @@ private void EnableCustomizationControls(bool isEnabled) HexColorText.Text = isEnabled ? string.Empty : ""; } + private bool _settingsCustomizeThemeEnabled + { + get => Settings.Instance.CustomizeThemeEnabled; + set + { + if (Settings.Instance.CustomizeThemeEnabled != value) + { + Settings.Instance.CustomizeThemeEnabled = value; + Settings.Instance.PropertyChanged += Settings_PropertyChanged; + } + } + } + private static void ListAddUnique(List list, string item) { if (!list.Contains(item)) diff --git a/RetroBar/Utilities/Settings.cs b/RetroBar/Utilities/Settings.cs index 0737c8f5..67cf57cb 100644 --- a/RetroBar/Utilities/Settings.cs +++ b/RetroBar/Utilities/Settings.cs @@ -289,6 +289,13 @@ public bool CheckForUpdates get => _checkForUpdates; set => Set(ref _checkForUpdates, value); } + + private bool _customizeThemeEnabled = false; + public bool CustomizeThemeEnabled + { + get => _customizeThemeEnabled; + set => Set(ref _customizeThemeEnabled, value); + } #endregion #region Old Properties