Derive nav hover from dynamic active button color

This commit is contained in:
Meik
2026-03-05 12:15:18 +01:00
parent d4777636fc
commit 897ecf70e4

View File

@@ -202,12 +202,9 @@ namespace C4IT_CustomerPanel.libs
} }
public Color GetButtonHoverColor() public Color GetButtonHoverColor()
{ {
Color activeColor = GetActiveButtonColor().Color;
var drawingcolor = System.Drawing.Color.FromArgb( bool isLightActive = GetRelativeLuminance(activeColor) >= 0.55;
GetActiveButtonColor().Color.A, GetActiveButtonColor().Color.R, GetActiveButtonColor().Color.G, GetActiveButtonColor().Color.B); return BlendColor(activeColor, isLightActive ? Colors.Black : Colors.White, isLightActive ? 0.10 : 0.12);
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);
} }
public SolidColorBrush GetActiveButtonColor() public SolidColorBrush GetActiveButtonColor()
{ {
@@ -242,10 +239,14 @@ namespace C4IT_CustomerPanel.libs
bool isLightBackground = GetRelativeLuminance(baseColor) >= 0.55; bool isLightBackground = GetRelativeLuminance(baseColor) >= 0.55;
Color panelColor = BlendColor(baseColor, Colors.White, isLightBackground ? 0.06 : 0.08); Color panelColor = BlendColor(baseColor, Colors.White, isLightBackground ? 0.06 : 0.08);
Color navColor = BlendColor(baseColor, Colors.Black, 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 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); Color navBorder = BlendColor(baseColor, isLightBackground ? Colors.Black : Colors.White, isLightBackground ? 0.20 : 0.28);
Application.Current.Resources["backgroundColor"] = new SolidColorBrush(baseColor); 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["panelBackgroundColor"] = new SolidColorBrush(panelColor);
Application.Current.Resources["navigationRailColor"] = new SolidColorBrush(navColor); Application.Current.Resources["navigationRailColor"] = new SolidColorBrush(navColor);
Application.Current.Resources["panelBorderColor"] = new SolidColorBrush(panelBorder); Application.Current.Resources["panelBorderColor"] = new SolidColorBrush(panelBorder);
@@ -989,13 +990,9 @@ namespace C4IT_CustomerPanel.libs
{ {
try 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 backgroundColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]);
Color headerColor = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]); 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); System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush(headerColor);
ApplyBackgroundDerivedResources(backgroundColor); ApplyBackgroundDerivedResources(backgroundColor);
} }
@@ -1006,13 +1003,9 @@ namespace C4IT_CustomerPanel.libs
cpConfig._uiColors["headerColor"] = Properties.Resources.headerColor; cpConfig._uiColors["headerColor"] = Properties.Resources.headerColor;
cpConfig._uiColors["activeButtonColor"] = Properties.Resources.activeButtonColor; 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 fallbackBackground = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["backgroundColor"]);
Color fallbackHeader = (Color)ConverterHelper.ColorConvertFromString(cpConfig._uiColors["headerColor"]); 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); System.Windows.Application.Current.Resources["headerColor"] = new SolidColorBrush(fallbackHeader);
ApplyBackgroundDerivedResources(fallbackBackground); ApplyBackgroundDerivedResources(fallbackBackground);
} }