- The job bar is a status bar for screen readers; it announces which job starts and when the queue empties (ShellViewModel.JobAnnouncement), never its progress ticks. - The status strip's connection text announces a change of server state. - Toast.IsError: error notices are announced at once; other notices queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
64 lines
3.8 KiB
C#
64 lines
3.8 KiB
C#
using System.Windows;
|
|
using System.Windows.Automation.Peers;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
|
|
namespace Titano.Ui.Controls;
|
|
|
|
/// <summary>
|
|
/// 40-px strip under the title bar: current job, progress, time left and a stop (or pause) button (DESIGN §4). Screen
|
|
/// readers see a status bar; its name is <c>AutomationProperties.Name</c> (the owner keeps it to the job's state, so
|
|
/// it can be a live region that does not speak every progress tick), else <see cref="Text"/>.
|
|
/// </summary>
|
|
public class JobBar : Control
|
|
{
|
|
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(nameof(Text), typeof(string), typeof(JobBar));
|
|
public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register(nameof(Progress), typeof(double), typeof(JobBar), new PropertyMetadata(0.0));
|
|
public static readonly DependencyProperty IsIndeterminateProperty = DependencyProperty.Register(nameof(IsIndeterminate), typeof(bool), typeof(JobBar));
|
|
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(nameof(IsActive), typeof(bool), typeof(JobBar));
|
|
public static readonly DependencyProperty StopCommandProperty = DependencyProperty.Register(nameof(StopCommand), typeof(ICommand), typeof(JobBar));
|
|
public static readonly DependencyProperty StopToolTipProperty = DependencyProperty.Register(nameof(StopToolTip), typeof(object), typeof(JobBar));
|
|
public static readonly DependencyProperty StopNameProperty = DependencyProperty.Register(nameof(StopName), typeof(string), typeof(JobBar));
|
|
public static readonly DependencyProperty ActionGlyphProperty = DependencyProperty.Register(nameof(ActionGlyph), typeof(IconData), typeof(JobBar));
|
|
|
|
static JobBar()
|
|
{
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(JobBar), new FrameworkPropertyMetadata(typeof(JobBar)));
|
|
}
|
|
|
|
public string? Text { get => (string?)GetValue(TextProperty); set => SetValue(TextProperty, value); }
|
|
|
|
/// <summary>0..1.</summary>
|
|
public double Progress { get => (double)GetValue(ProgressProperty); set => SetValue(ProgressProperty, value); }
|
|
|
|
public bool IsIndeterminate { get => (bool)GetValue(IsIndeterminateProperty); set => SetValue(IsIndeterminateProperty, value); }
|
|
|
|
/// <summary>A job is running: shows the progress fill and the stop button.</summary>
|
|
public bool IsActive { get => (bool)GetValue(IsActiveProperty); set => SetValue(IsActiveProperty, value); }
|
|
|
|
public ICommand? StopCommand { get => (ICommand?)GetValue(StopCommandProperty); set => SetValue(StopCommandProperty, value); }
|
|
public object? StopToolTip { get => GetValue(StopToolTipProperty); set => SetValue(StopToolTipProperty, value); }
|
|
|
|
/// <summary>Short accessible name of the stop (or pause) button; the tooltip sentence becomes its help text.</summary>
|
|
public string? StopName { get => (string?)GetValue(StopNameProperty); set => SetValue(StopNameProperty, value); }
|
|
|
|
/// <summary>Glyph of the action button: stop by default; the client shows pause (DESIGN §4 job bar).</summary>
|
|
public IconData? ActionGlyph { get => (IconData?)GetValue(ActionGlyphProperty); set => SetValue(ActionGlyphProperty, value); }
|
|
|
|
protected override AutomationPeer OnCreateAutomationPeer() => new JobBarAutomationPeer(this);
|
|
}
|
|
|
|
/// <summary>The job bar seen by UI Automation: a status bar holding the progress bar and the pause button.</summary>
|
|
public sealed class JobBarAutomationPeer(JobBar owner) : FrameworkElementAutomationPeer(owner)
|
|
{
|
|
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.StatusBar;
|
|
|
|
protected override string GetClassNameCore() => nameof(JobBar);
|
|
|
|
protected override string GetNameCore()
|
|
{
|
|
var name = base.GetNameCore();
|
|
return string.IsNullOrEmpty(name) ? ((JobBar)Owner).Text ?? string.Empty : name;
|
|
}
|
|
}
|