using System; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; namespace StarterNG.Controls; public class SettingsSection : HeaderedContentControl { public static readonly StyledProperty ToggleProperty = AvaloniaProperty.Register(nameof(Toggle)); public static readonly StyledProperty ToggleKeyProperty = AvaloniaProperty.Register(nameof(ToggleKey)); public static readonly StyledProperty ResetLabelProperty = AvaloniaProperty.Register(nameof(ResetLabel)); public static readonly StyledProperty LevelProperty = AvaloniaProperty.Register(nameof(Level)); private Button? _reset; /// The header's choice of a level of detail for this section alone; none where it has no such thing. public object? Level { get => GetValue(LevelProperty); set => SetValue(LevelProperty, value); } public object? Toggle { get => GetValue(ToggleProperty); set => SetValue(ToggleProperty, value); } /// The eu07.ini key the header's switch sets. public string? ToggleKey { get => GetValue(ToggleKeyProperty); set => SetValue(ToggleKeyProperty, value); } /// The words on the header's button that puts the section back as the simulator has it; none, no button. public string? ResetLabel { get => GetValue(ResetLabelProperty); set => SetValue(ResetLabelProperty, value); } /// Raised when the header's reset button is pressed. public event Action? ResetRequested; protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); if (_reset is not null) _reset.Click -= OnResetClick; _reset = e.NameScope.Find