Files
Chronos/src/Titano.App/Shell/SectionViewModel.cs
T
Alby96 5aeb6aa787 Add comprehensive tests for EditSection functionality in the Windows application
- Implement tests for picker behavior, including loading sequences, searching, and handling empty libraries.
- Validate sequence opening via Enter key and double-click actions.
- Ensure proper handling of unsaved edits and sequence deletion scenarios.
- Verify accessibility features for picker rows across different languages.
- Introduce a dialog counting mechanism to manage unsaved edit confirmations.
2026-10-19 12:10:42 +02:00

79 lines
2.2 KiB
C#

using Titano.Ui.Controls;
using Titano.Ui.Mvvm;
namespace Titano.App.Shell;
public enum SectionKey
{
Library,
Import,
/// <summary>One sequence analysed, edited and rendered step by step (owner review 1, R7; formerly Sequence).</summary>
Edit,
Archive,
Jobs,
Server,
Settings,
About,
}
/// <summary>A top-level destination of the navigation rail.</summary>
public abstract class SectionViewModel(SectionKey key, string iconKey) : LocalizedViewModel
{
private bool _isSelected;
private int _badge;
private bool _inCollapsedRail;
public SectionKey Key { get; } = key;
/// <summary>Resource key of the rail icon (e.g. "Icon.Library").</summary>
public string IconKey { get; } = iconKey;
public IconData? Glyph => System.Windows.Application.Current?.TryFindResource(IconKey) as IconData;
/// <summary>Rail label ("Library").</summary>
public string Label => Core.Localization.Loc.L("Shell.Nav." + Key);
/// <summary>Rail tooltip: what the section is for.</summary>
public string ToolTip => Core.Localization.Loc.L("Tooltips.Nav." + Key);
/// <summary>
/// The rail button's tooltip: <see cref="ToolTip"/>, after the section's name while the rail shows icons alone (owner
/// review 1).
/// </summary>
public string RailToolTip => _inCollapsedRail ? Core.Localization.Loc.L("Tooltips.Nav.Collapsed", Label, ToolTip) : ToolTip;
/// <summary>The rail shows icons alone (<see cref="ShellViewModel.IsRailCollapsed"/>).</summary>
internal bool InCollapsedRail
{
get => _inCollapsedRail;
set
{
if (Set(ref _inCollapsedRail, value)) OnPropertyChanged(nameof(RailToolTip));
}
}
/// <summary>Window title suffix ("Titano — Import").</summary>
public virtual string Title => Label;
public bool IsSelected
{
get => _isSelected;
set
{
if (Set(ref _isSelected, value) && value) OnActivated();
}
}
/// <summary>Count of items needing attention, shown as a rail badge.</summary>
public int Badge
{
get => _badge;
protected set => Set(ref _badge, value);
}
protected virtual void OnActivated()
{
}
}