From 0a465698a6757d800b173dc033266b5c00f1701b Mon Sep 17 00:00:00 2001 From: Meik Date: Thu, 5 Mar 2026 13:01:28 +0100 Subject: [PATCH] Improve nav hover contrast and preserve hover after click --- MainWindow.xaml.cs | 22 ++++++++++++++++++---- libs/configHelper.cs | 6 ++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 6d95945..0305f78 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -928,14 +928,27 @@ namespace C4IT_CustomerPanel : visualHelper.FindVisualChild(button, "ActiveIcon"); } + private SolidColorBrush GetNavigationHoverBrush() + { + if (ConfigSettings == null) + return System.Windows.Media.Brushes.Transparent; + + Color hoverColor = ConfigSettings.GetButtonHoverColor(ConfigSettings.GetBackgroundColor().Color, 1.30); + return new SolidColorBrush(hoverColor); + } + public void SetMenuAktivInaktiv(object sender, bool force, bool Silent = false) { Button clickedButton = (Button)sender; ShowTabContent(this.StPaMain, clickedButton); + SolidColorBrush navHoverBrush = GetNavigationHoverBrush(); + if (ActiveButton != clickedButton) { - clickedButton.Background = System.Windows.Media.Brushes.Transparent; + clickedButton.Background = clickedButton.IsMouseOver + ? navHoverBrush + : System.Windows.Media.Brushes.Transparent; FrameworkElement activeIndicator = GetActiveTabIndicator(clickedButton); if (activeIndicator != null) activeIndicator.Visibility = Visibility.Visible; @@ -945,7 +958,9 @@ namespace C4IT_CustomerPanel if (ActiveButton != null) { - ActiveButton.Background = System.Windows.Media.Brushes.Transparent; + ActiveButton.Background = ActiveButton.IsMouseOver + ? navHoverBrush + : System.Windows.Media.Brushes.Transparent; FrameworkElement inactiveIndicator = GetActiveTabIndicator(ActiveButton); if (inactiveIndicator != null) inactiveIndicator.Visibility = Visibility.Hidden; @@ -1858,8 +1873,7 @@ namespace C4IT_CustomerPanel if (!(sender is Button bu)) return; - Color hoverColor = ConfigSettings.GetButtonHoverColor(ConfigSettings.GetBackgroundColor().Color); - bu.Background = new SolidColorBrush(hoverColor); + bu.Background = GetNavigationHoverBrush(); } catch (Exception exp) { diff --git a/libs/configHelper.cs b/libs/configHelper.cs index 4a82588..ee1ca73 100644 --- a/libs/configHelper.cs +++ b/libs/configHelper.cs @@ -200,11 +200,13 @@ namespace C4IT_CustomerPanel.libs { return cpConfig._linkList; } - public Color GetButtonHoverColor(Color? baseColor = null) + public Color GetButtonHoverColor(Color? baseColor = null, double contrastMultiplier = 1.0) { Color activeColor = baseColor ?? GetActiveButtonColor().Color; bool isLightActive = GetRelativeLuminance(activeColor) >= 0.55; - return BlendColor(activeColor, isLightActive ? Colors.Black : Colors.White, isLightActive ? 0.10 : 0.12); + double baseAmount = isLightActive ? 0.10 : 0.12; + double blendAmount = Math.Max(0.0, Math.Min(0.35, baseAmount * contrastMultiplier)); + return BlendColor(activeColor, isLightActive ? Colors.Black : Colors.White, blendAmount); } public SolidColorBrush GetActiveButtonColor() {