Refine navigation UX and header action styling
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user