From 897ecf70e4a6a83128aea6efc2146e806b178530 Mon Sep 17 00:00:00 2001 From: Meik Date: Thu, 5 Mar 2026 12:15:18 +0100 Subject: [PATCH] Derive nav hover from dynamic active button color --- libs/configHelper.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libs/configHelper.cs b/libs/configHelper.cs index fb94d3f..eb88f3a 100644 --- a/libs/configHelper.cs +++ b/libs/configHelper.cs @@ -202,12 +202,9 @@ namespace C4IT_CustomerPanel.libs } public Color GetButtonHoverColor() { - - var drawingcolor = System.Drawing.Color.FromArgb( - GetActiveButtonColor().Color.A, GetActiveButtonColor().Color.R, GetActiveButtonColor().Color.G, GetActiveButtonColor().Color.B); - System.Drawing.Color returnColor = System.Windows.Forms.ControlPaint.Dark(drawingcolor, 0.1f); - return System.Windows.Media.Color.FromArgb(returnColor.A, returnColor.R, returnColor.G, returnColor.B); - + Color activeColor = GetActiveButtonColor().Color; + bool isLightActive = GetRelativeLuminance(activeColor) >= 0.55; + return BlendColor(activeColor, isLightActive ? Colors.Black : Colors.White, isLightActive ? 0.10 : 0.12); } public SolidColorBrush GetActiveButtonColor() { @@ -242,10 +239,14 @@ namespace C4IT_CustomerPanel.libs bool isLightBackground = GetRelativeLuminance(baseColor) >= 0.55; Color panelColor = BlendColor(baseColor, Colors.White, isLightBackground ? 0.06 : 0.08); Color navColor = BlendColor(baseColor, Colors.Black, isLightBackground ? 0.06 : 0.08); + Color activeColor = BlendColor(baseColor, isLightBackground ? Colors.Black : Colors.White, isLightBackground ? 0.30 : 0.34); + Color inactiveColor = BlendColor(baseColor, isLightBackground ? Colors.White : Colors.Black, isLightBackground ? 0.18 : 0.14); Color panelBorder = BlendColor(baseColor, isLightBackground ? Colors.Black : Colors.White, isLightBackground ? 0.16 : 0.22); Color navBorder = BlendColor(baseColor, isLightBackground ? Colors.Black : Colors.White, isLightBackground ? 0.20 : 0.28); Application.Current.Resources["backgroundColor"] = new SolidColorBrush(baseColor); + Application.Current.Resources["activeButtonColor"] = new SolidColorBrush(activeColor); + Application.Current.Resources["inactiveButtonColor"] = new SolidColorBrush(inactiveColor); Application.Current.Resources["panelBackgroundColor"] = new SolidColorBrush(panelColor); Application.Current.Resources["navigationRailColor"] = new SolidColorBrush(navColor); Application.Current.Resources["panelBorderColor"] = new SolidColorBrush(panelBorder); @@ -989,13 +990,9 @@ namespace C4IT_CustomerPanel.libs { try { - Color activeColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["activeButtonColor"]); - Color inactiveColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["inactiveButtonColor"]); Color backgroundColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]); Color headerColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]); - System.Windows.Application.Current.Resources["activeButtonColor"] = new SolidColorBrush(activeColor); - System.Windows.Application.Current.Resources["inactiveButtonColor"] = new SolidColorBrush(inactiveColor); System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush(headerColor); ApplyBackgroundDerivedResources(backgroundColor); } @@ -1006,13 +1003,9 @@ namespace C4IT_CustomerPanel.libs cpConfig._uiColors["headerColor"] = Properties.Resources.headerColor; cpConfig._uiColors["activeButtonColor"] = Properties.Resources.activeButtonColor; - Color fallbackActive = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["activeButtonColor"]); - Color fallbackInactive = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["inactiveButtonColor"]); Color fallbackBackground = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]); Color fallbackHeader = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]); - System.Windows.Application.Current.Resources["activeButtonColor"] = new SolidColorBrush(fallbackActive); - System.Windows.Application.Current.Resources["inactiveButtonColor"] = new SolidColorBrush(fallbackInactive); System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush(fallbackHeader); ApplyBackgroundDerivedResources(fallbackBackground); }