Improve nav hover contrast and preserve hover after click
This commit is contained in:
@@ -928,14 +928,27 @@ namespace C4IT_CustomerPanel
|
|||||||
: visualHelper.FindVisualChild<FrameworkElement>(button, "ActiveIcon");
|
: visualHelper.FindVisualChild<FrameworkElement>(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)
|
public void SetMenuAktivInaktiv(object sender, bool force, bool Silent = false)
|
||||||
{
|
{
|
||||||
Button clickedButton = (Button)sender;
|
Button clickedButton = (Button)sender;
|
||||||
ShowTabContent(this.StPaMain, clickedButton);
|
ShowTabContent(this.StPaMain, clickedButton);
|
||||||
|
|
||||||
|
SolidColorBrush navHoverBrush = GetNavigationHoverBrush();
|
||||||
|
|
||||||
if (ActiveButton != clickedButton)
|
if (ActiveButton != clickedButton)
|
||||||
{
|
{
|
||||||
clickedButton.Background = System.Windows.Media.Brushes.Transparent;
|
clickedButton.Background = clickedButton.IsMouseOver
|
||||||
|
? navHoverBrush
|
||||||
|
: System.Windows.Media.Brushes.Transparent;
|
||||||
FrameworkElement activeIndicator = GetActiveTabIndicator(clickedButton);
|
FrameworkElement activeIndicator = GetActiveTabIndicator(clickedButton);
|
||||||
if (activeIndicator != null)
|
if (activeIndicator != null)
|
||||||
activeIndicator.Visibility = Visibility.Visible;
|
activeIndicator.Visibility = Visibility.Visible;
|
||||||
@@ -945,7 +958,9 @@ namespace C4IT_CustomerPanel
|
|||||||
|
|
||||||
if (ActiveButton != null)
|
if (ActiveButton != null)
|
||||||
{
|
{
|
||||||
ActiveButton.Background = System.Windows.Media.Brushes.Transparent;
|
ActiveButton.Background = ActiveButton.IsMouseOver
|
||||||
|
? navHoverBrush
|
||||||
|
: System.Windows.Media.Brushes.Transparent;
|
||||||
FrameworkElement inactiveIndicator = GetActiveTabIndicator(ActiveButton);
|
FrameworkElement inactiveIndicator = GetActiveTabIndicator(ActiveButton);
|
||||||
if (inactiveIndicator != null)
|
if (inactiveIndicator != null)
|
||||||
inactiveIndicator.Visibility = Visibility.Hidden;
|
inactiveIndicator.Visibility = Visibility.Hidden;
|
||||||
@@ -1858,8 +1873,7 @@ namespace C4IT_CustomerPanel
|
|||||||
if (!(sender is Button bu))
|
if (!(sender is Button bu))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Color hoverColor = ConfigSettings.GetButtonHoverColor(ConfigSettings.GetBackgroundColor().Color);
|
bu.Background = GetNavigationHoverBrush();
|
||||||
bu.Background = new SolidColorBrush(hoverColor);
|
|
||||||
}
|
}
|
||||||
catch (Exception exp)
|
catch (Exception exp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -200,11 +200,13 @@ namespace C4IT_CustomerPanel.libs
|
|||||||
{
|
{
|
||||||
return cpConfig._linkList;
|
return cpConfig._linkList;
|
||||||
}
|
}
|
||||||
public Color GetButtonHoverColor(Color? baseColor = null)
|
public Color GetButtonHoverColor(Color? baseColor = null, double contrastMultiplier = 1.0)
|
||||||
{
|
{
|
||||||
Color activeColor = baseColor ?? GetActiveButtonColor().Color;
|
Color activeColor = baseColor ?? GetActiveButtonColor().Color;
|
||||||
bool isLightActive = GetRelativeLuminance(activeColor) >= 0.55;
|
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()
|
public SolidColorBrush GetActiveButtonColor()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user