Skip to content

Commit

Permalink
CustomizeTheme: Handle CustomizeThemeEnabled settings value.
Browse files Browse the repository at this point in the history
  • Loading branch information
MKKNinetyTwo authored and hackeranonymousdeepweb committed Nov 18, 2024
1 parent 118ed4d commit 12fd8f9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
3 changes: 2 additions & 1 deletion RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@
<StackPanel Orientation="Vertical" Margin="10,0,0,10">
<CheckBox Checked="ThemeCustomizationsEnabled_CheckBox_OnChecked"
Unchecked="ThemeCustomizationsEnabled_CheckBox_OnUnChecked"
Name="ThemeCustomizationsEnabled_CheckBox">
Name="ThemeCustomizationsEnabled_CheckBox"
IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=CustomizeThemeEnabled}">
<Label Content="Theme Customizations Enabled" />
</CheckBox>
</StackPanel>
Expand Down
38 changes: 35 additions & 3 deletions RetroBar/Utilities/CustomizeTheme.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using RetroBar.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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<string> list, string item)
{
if (!list.Contains(item))
Expand Down
7 changes: 7 additions & 0 deletions RetroBar/Utilities/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 12fd8f9

Please sign in to comment.