mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[Settings] Fix for theming aware titles (#5245)
* Fix for theming aware titles * Converter fix
This commit is contained in:
@@ -17,6 +17,13 @@
|
||||
<ResourceDictionary Source="/Styles/Button.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:ModuleEnabledToForegroundConverter x:Key="ModuleEnabledToForegroundConverter"/>
|
||||
|
||||
|
||||
<SolidColorBrush x:Key="DarkForegroundDisabledBrush">#66FFFFFF</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="DarkForegroundBrush">#FFFFFFFF</SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="LightForegroundDisabledBrush">#66000000</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="LightForegroundBrush">#FF000000</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</xaml:XamlApplication>
|
||||
@@ -1,7 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||
using System;
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
@@ -15,13 +12,36 @@ namespace Microsoft.PowerToys.Settings.UI.Converters
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
bool isEnabled = (bool)value;
|
||||
if (isEnabled)
|
||||
GeneralSettings generalSettings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
|
||||
|
||||
var defaultTheme = new Windows.UI.ViewManagement.UISettings();
|
||||
var uiTheme = defaultTheme.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background).ToString();
|
||||
|
||||
string selectedTheme = generalSettings.Theme.ToLower();
|
||||
|
||||
if (selectedTheme == "dark" || (selectedTheme == "system" && uiTheme == "#FF000000"))
|
||||
{
|
||||
return new SolidColorBrush((Color)Application.Current.Resources["SystemBaseHighColor"]);
|
||||
// DARK
|
||||
if (isEnabled)
|
||||
{
|
||||
return (SolidColorBrush)Application.Current.Resources["DarkForegroundBrush"];
|
||||
}
|
||||
else
|
||||
{
|
||||
return (SolidColorBrush)Application.Current.Resources["DarkForegroundDisabledBrush"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return (SolidColorBrush)Application.Current.Resources["SystemControlDisabledBaseMediumLowBrush"];
|
||||
// LIGHT
|
||||
if (isEnabled)
|
||||
{
|
||||
return (SolidColorBrush)Application.Current.Resources["LightForegroundBrush"];
|
||||
}
|
||||
else
|
||||
{
|
||||
return (SolidColorBrush)Application.Current.Resources["LightForegroundDisabledBrush"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user