using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace MSCFixer
{
///
/// Handles navigation button highlighting for a set of UI buttons.
///
public class NavigationHandler
{
// List of all buttons managed by the navigation handler
private readonly List _buttons;
// Color used for the active (selected) button
private readonly Color _activeColor = Color.FromArgb(76, 145, 235);
// Color used for inactive (non-selected) buttons
private readonly Color _inactiveColor = Color.FromArgb(104, 104, 104);
// Border color for inactive buttons
private readonly Color _inactiveBorderColor = Color.FromArgb(114, 114, 114);
///
/// Initializes the handler with the buttons that should be managed.
///
/// The buttons to include in the navigation group.
public NavigationHandler(params Button[] buttons)
{
_buttons = new List(buttons);
}
///
/// Sets the specified button as active, changing colors accordingly.
///
/// The button to highlight as active.
public void SetActive(Button activeButton)
{
foreach (var button in _buttons)
{
bool isActive = button == activeButton;
// Set the background color for the button (active or inactive)
button.BackColor = isActive ? _activeColor : _inactiveColor;
// Set the border color for the button (active or inactive)
button.FlatAppearance.BorderColor = isActive ? _activeColor : _inactiveBorderColor;
// Set the text color to white for both active and inactive
button.ForeColor = Color.White;
}
}
}
}