Refine navigation UX and header action styling

This commit is contained in:
Meik
2026-03-05 12:29:49 +01:00
parent 2e53ede66b
commit d6b03c5858
4 changed files with 132 additions and 17 deletions

View File

@@ -205,12 +205,18 @@
Value="50"></Setter>
<EventSetter Event="PreviewMouseDown"
Handler="Button_MouseDown" />
<EventSetter Event="Click"
Handler="NavigationButton_Click" />
<EventSetter Event="MouseEnter"
Handler="Button_MouseEnter" />
<EventSetter Event="MouseLeave"
Handler="Button_MouseLeave" />
<EventSetter Event="KeyDown"
Handler="NavigationButton_KeyDown" />
<EventSetter Event="Loaded"
Handler="Button_Loaded" />
<Setter Property="IsTabStop"
Value="True" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Foreground"
@@ -252,11 +258,11 @@
<Setter Property="Foreground"
Value="{DynamicResource navForeground}" />
<Setter Property="Background"
Value="{DynamicResource headerControlBackgroundColor}" />
Value="Transparent" />
<Setter Property="BorderBrush"
Value="{DynamicResource panelBorderColor}" />
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
Value="0" />
<Setter Property="Cursor"
Value="Hand" />
<Setter Property="Width"
@@ -300,7 +306,7 @@
<Setter Property="BorderThickness"
Value="0" />
<Setter Property="Background"
Value="{DynamicResource headerControlBackgroundColor}" />
Value="Transparent" />
<Setter Property="Width"
Value="32" />
<Setter Property="Height"
@@ -360,9 +366,9 @@
Margin="0,12,12,0"
Panel.ZIndex="500"
CornerRadius="10"
BorderThickness="1"
BorderBrush="{DynamicResource panelBorderColor}"
Background="{DynamicResource headerControlBackgroundColor}"
BorderThickness="0"
BorderBrush="Transparent"
Background="Transparent"
shell:WindowChrome.IsHitTestVisibleInChrome="True">
<StackPanel Orientation="Horizontal">
<Button x:Name="RefreshIcon"
@@ -375,11 +381,9 @@
Width="16"
Height="16" />
</Button>
<Border Width="1"
Margin="0,6"
Background="{DynamicResource panelBorderColor}" />
<Button x:Name="Close_Text"
Style="{StaticResource HeaderGroupButtonStyle}"
Margin="2,0,0,0"
ToolTip="{x:Static resx:Resources.close}"
shell:WindowChrome.IsHitTestVisibleInChrome="True"
Click="OnMinimizeButtonClick">

View File

@@ -923,7 +923,7 @@ namespace C4IT_CustomerPanel
if (ActiveButton != clickedButton)
{
clickedButton.Background = System.Windows.Media.Brushes.Transparent;
clickedButton.Background = ConfigSettings.GetActiveButtonColor();
FrameworkElement activeIndicator = GetActiveTabIndicator(clickedButton);
if (activeIndicator != null)
activeIndicator.Visibility = Visibility.Visible;
@@ -1727,6 +1727,13 @@ namespace C4IT_CustomerPanel
private void App_KeyDown(object sender, KeyEventArgs e)
{
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.Tab)
{
var backwards = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
e.Handled = MoveNavigationButtonFocus(Keyboard.FocusedElement as Button, backwards ? -1 : 1, true);
return;
}
if (((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) && Keyboard.IsKeyDown(Key.R) && ConfigSettings.GetConfig()._isDraggable)
{
if (WindowState == WindowState.Normal)
@@ -1736,6 +1743,97 @@ namespace C4IT_CustomerPanel
}
}
private List<Button> GetVisibleNavigationButtons()
{
if (MainFunctionButtons == null || MainFunctionButtons.Count == 0)
return new List<Button>();
return MainFunctionButtons.Values
.Where(entry => entry?.button != null && entry.button.Visibility == Visibility.Visible && entry.button.IsEnabled)
.Select(entry => entry.button)
.Distinct()
.OrderBy(button => button.Margin.Top)
.ThenBy(button => button.Name)
.ToList();
}
private bool ActivateAndFocusNavigationButton(Button targetButton, bool activateButton)
{
if (targetButton == null)
return false;
targetButton.Focus();
if (activateButton)
SetMenuAktivInaktiv(targetButton, true);
return true;
}
private bool MoveNavigationButtonFocus(Button currentButton, int step, bool activateTarget)
{
var visibleButtons = GetVisibleNavigationButtons();
if (visibleButtons.Count == 0)
return false;
var currentIndex = visibleButtons.IndexOf(currentButton);
if (currentIndex < 0 && ActiveButton != null)
currentIndex = visibleButtons.IndexOf(ActiveButton);
if (currentIndex < 0)
currentIndex = 0;
var targetIndex = (currentIndex + step + visibleButtons.Count) % visibleButtons.Count;
return ActivateAndFocusNavigationButton(visibleButtons[targetIndex], activateTarget);
}
private void NavigationButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (!(sender is Button button))
return;
if (button == ActiveButton)
return;
SetMenuAktivInaktiv(button, true);
}
catch (Exception exp)
{
cLogManager.LogException(exp);
}
}
private void NavigationButton_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (!(sender is Button button))
return;
switch (e.Key)
{
case Key.Up:
case Key.Left:
e.Handled = MoveNavigationButtonFocus(button, -1, true);
break;
case Key.Down:
case Key.Right:
e.Handled = MoveNavigationButtonFocus(button, 1, true);
break;
case Key.Home:
e.Handled = ActivateAndFocusNavigationButton(GetVisibleNavigationButtons().FirstOrDefault(), true);
break;
case Key.End:
e.Handled = ActivateAndFocusNavigationButton(GetVisibleNavigationButtons().LastOrDefault(), true);
break;
}
}
catch (Exception exp)
{
cLogManager.LogException(exp);
}
}
public void Button_MouseEnter(object sender, EventArgs e)
{
try
@@ -1743,7 +1841,11 @@ namespace C4IT_CustomerPanel
if (!(sender is Button bu))
return;
Color btnColor = ConfigSettings.GetButtonHoverColor();
SolidColorBrush activeBrush = ConfigSettings.GetActiveButtonColor();
if (activeBrush == null)
return;
Color btnColor = ConfigSettings.GetButtonHoverColor(activeBrush.Color);
if (btnColor != null)
bu.Background = new SolidColorBrush(btnColor);
}
@@ -1760,7 +1862,9 @@ namespace C4IT_CustomerPanel
if (!(sender is Button bu))
return;
bu.Background = System.Windows.Media.Brushes.Transparent;
bu.Background = Equals(bu, ActiveButton)
? ConfigSettings.GetActiveButtonColor()
: System.Windows.Media.Brushes.Transparent;
}
catch (Exception exp)
{
@@ -1815,6 +1919,7 @@ namespace C4IT_CustomerPanel
if (bu != ActiveButton)
return;
bu.Background = ConfigSettings.GetActiveButtonColor();
FrameworkElement activeIndicator = GetActiveTabIndicator(bu);
if (activeIndicator != null)
activeIndicator.Visibility = Visibility.Visible;

View File

@@ -21,13 +21,14 @@
BorderBrush="{DynamicResource cardBorderColor}"
Background="{DynamicResource cardBackgroundColor}"
CornerRadius="12"
ClipToBounds="True"
MouseEnter="OnAnnMouseEnter"
MouseLeave="OnAnnMouseLeave">
<Grid Background="Transparent"
Height="auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="6"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
@@ -37,7 +38,12 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid Background="{Binding Path=PrioColor}" Grid.RowSpan="3" x:Name="annColor"></Grid>
<Border Grid.RowSpan="3"
Grid.Column="0"
x:Name="annColor"
Background="{Binding Path=PrioColor}"
CornerRadius="12,0,0,12"
Margin="0" />
<DockPanel Grid.Column="1" >
<Image Source="pack://application:,,,/Resources/StateOverlays/OverlayNewContentButton.png"
Panel.ZIndex="18"

View File

@@ -200,9 +200,9 @@ namespace C4IT_CustomerPanel.libs
{
return cpConfig._linkList;
}
public Color GetButtonHoverColor()
public Color GetButtonHoverColor(Color? baseColor = null)
{
Color activeColor = GetActiveButtonColor().Color;
Color activeColor = baseColor ?? GetActiveButtonColor().Color;
bool isLightActive = GetRelativeLuminance(activeColor) >= 0.55;
return BlendColor(activeColor, isLightActive ? Colors.Black : Colors.White, isLightActive ? 0.10 : 0.12);
}