fix: a screen reader finds its way by landmarks and hears what a click changed

Titled panels are named groups, so the reader says which one focus went into.
The tab bar and the settings categories are navigation, the page is the main
part, the search boxes are search. A quality level, a section put back to its
defaults, settings reloaded, the weather put back or its time set to now are
spoken, as is the save status.
This commit is contained in:
maj00r
2026-11-15 18:05:26 +01:00
parent a0a6ebdffa
commit 6c696b44e0
13 changed files with 363 additions and 111 deletions

View File

@@ -0,0 +1,116 @@
using Avalonia.Automation;
using Avalonia.Automation.Peers;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using StarterNG.Controls;
namespace StarterNG.Tests;
public class AnnouncerTests
{
private DateTime _now = new(2026, 11, 15, 12, 0, 0, DateTimeKind.Utc);
private Announcer NewAnnouncer() => new(() => _now);
[Fact]
public void A_message_is_read_while_fresh_and_then_forgotten()
{
var announcer = NewAnnouncer();
announcer.Say(" Jakość grafiki: Wysoka ");
Assert.Equal("Jakość grafiki: Wysoka", announcer.Message);
_now += Announcer.Shown;
Assert.Null(announcer.Message);
}
[Fact]
public void Nothing_to_say_says_nothing()
{
var announcer = NewAnnouncer();
announcer.Say("Zapisano ustawienia");
announcer.Say(" ");
Assert.Equal("Zapisano ustawienia", announcer.Message);
}
[Fact]
public void A_control_inside_says_it_through_the_window_announcer()
{
var button = new Button();
var announcer = NewAnnouncer();
announcer.Child = new Border { Child = button };
Announcer.Say(button, "Godzina: 07:05");
Assert.Equal("Godzina: 07:05", announcer.Message);
}
[Fact]
public void A_control_outside_any_announcer_is_not_heard()
{
Announcer.Say(new Button(), "Godzina: 07:05");
}
[Fact]
public void A_marked_text_is_read_when_it_changes()
{
var status = new TextBlock();
Announcer.SetChanges(status, true);
var plain = new TextBlock();
var announcer = NewAnnouncer();
announcer.Child = new StackPanel { Children = { status, plain } };
plain.Text = "Ścieżka";
Assert.Null(announcer.Message);
status.Text = "Niezapisane zmiany";
Assert.True(Announcer.GetChanges(status));
Assert.Equal("Niezapisane zmiany", announcer.Message);
}
[Fact]
public void A_screen_reader_hears_it_as_a_polite_live_region()
{
var announcer = NewAnnouncer();
var peer = ControlAutomationPeer.CreatePeerForElement(announcer);
announcer.Say("Przywrócono domyślne");
Assert.Equal("Przywrócono domyślne", peer.GetName());
Assert.Equal(AutomationLiveSetting.Polite, peer.GetLiveSetting());
Assert.Equal(AutomationControlType.Group, peer.GetAutomationControlType());
}
}
public class NamedGroupTests
{
static NamedGroupTests() => ScreenReaderNames.Install();
[Fact]
public void A_panel_with_a_title_is_a_group_named_by_it()
{
var panel = new HeaderedContentControl { Header = "Scenerie" };
Assert.Equal("Scenerie", AutomationProperties.GetName(panel));
Assert.Equal(AutomationControlType.Group, AutomationProperties.GetControlTypeOverride(panel));
Assert.True(AutomationProperties.GetIsControlElementOverride(panel));
}
[Fact]
public void A_panel_whose_title_goes_is_no_longer_a_group()
{
var panel = new HeaderedContentControl { Header = "Skład" };
panel.Header = null;
Assert.Null(AutomationProperties.GetName(panel));
Assert.Null(AutomationProperties.GetControlTypeOverride(panel));
}
[Fact]
public void A_tab_keeps_its_own_way_of_speaking()
{
var tab = new TabItem { Header = "Pogoda" };
Assert.Null(AutomationProperties.GetName(tab));
Assert.Equal(AutomationControlType.TabItem, AutomationProperties.GetControlTypeOverride(tab));
}
}

View File

@@ -0,0 +1,89 @@
using System;
using Avalonia;
using Avalonia.Automation;
using Avalonia.Automation.Peers;
using Avalonia.Controls;
using Avalonia.VisualTree;
namespace StarterNG.Controls;
/// <summary>
/// Says what a click changed out of sight, such as a quality level that moved a dozen
/// sliders or a time set to now. It wraps the whole window: a screen reader learns of
/// an element only on its way to the focused one, and this lies on every such way.
/// A text marked <see cref="ChangesProperty"/> is read whenever it changes.
/// </summary>
public class Announcer : Decorator
{
/// <summary>How long a message stays its name, so it is not read again later on.</summary>
public static readonly TimeSpan Shown = TimeSpan.FromSeconds(3);
public static readonly AttachedProperty<bool> ChangesProperty =
AvaloniaProperty.RegisterAttached<Announcer, TextBlock, bool>("Changes");
public static bool GetChanges(TextBlock block) => block.GetValue(ChangesProperty);
public static void SetChanges(TextBlock block, bool value) => block.SetValue(ChangesProperty, value);
static Announcer()
{
TextBlock.TextProperty.Changed.AddClassHandler<TextBlock>((block, _) =>
{
if (GetChanges(block))
Say(block, block.Text);
});
}
private readonly Func<DateTime> _now;
private string? _message;
private DateTime _saidAt;
public Announcer() : this(() => DateTime.UtcNow)
{
}
public Announcer(Func<DateTime> now) => _now = now;
/// <summary>The message while it is fresh, then nothing.</summary>
public string? Message => _message is not null && _now() - _saidAt < Shown ? _message : null;
/// <summary>Says the text through the announcer of the window <paramref name="from"/> is in.</summary>
public static void Say(Visual from, string? text)
{
var announcer = from as Announcer ?? from.FindAncestorOfType<Announcer>();
announcer?.Say(text);
}
public void Say(string? text)
{
if (string.IsNullOrWhiteSpace(text))
return;
string? before = Message;
_message = text.Trim();
_saidAt = _now();
// Its name changing is what makes a live region speak.
if (ControlAutomationPeer.CreatePeerForElement(this) is Peer peer)
peer.Told(before, _message);
}
protected override AutomationPeer OnCreateAutomationPeer() => new Peer(this);
private sealed class Peer : ControlAutomationPeer
{
public Peer(Announcer owner) : base(owner)
{
}
private Announcer Announcer => (Announcer)Owner;
public void Told(string? before, string now) =>
RaisePropertyChangedEvent(AutomationElementIdentifiers.NameProperty, before, now);
protected override string? GetNameCore() => Announcer.Message;
protected override AutomationLiveSetting GetLiveSettingCore() => AutomationLiveSetting.Polite;
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Group;
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Avalonia; using Avalonia;
using Avalonia.Automation; using Avalonia.Automation;
using Avalonia.Automation.Peers;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Documents; using Avalonia.Controls.Documents;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
@@ -31,6 +32,8 @@ public static class ScreenReaderNames
ContentControl.ContentProperty.Changed.AddClassHandler<ListBoxItem>((i, _) => Give(i, TextOf(i.Content))); ContentControl.ContentProperty.Changed.AddClassHandler<ListBoxItem>((i, _) => Give(i, TextOf(i.Content)));
HeaderedItemsControl.HeaderProperty.Changed.AddClassHandler<TreeViewItem>((i, _) => Give(i, TextOf(i.Header))); HeaderedItemsControl.HeaderProperty.Changed.AddClassHandler<TreeViewItem>((i, _) => Give(i, TextOf(i.Header)));
HeaderedContentControl.HeaderProperty.Changed.AddClassHandler<HeaderedContentControl>((c, _) => NameGroup(c));
ComboBox.PlaceholderTextProperty.Changed.AddClassHandler<ComboBox>((c, _) => Give(c, c.PlaceholderText)); ComboBox.PlaceholderTextProperty.Changed.AddClassHandler<ComboBox>((c, _) => Give(c, c.PlaceholderText));
TextBox.PlaceholderTextProperty.Changed.AddClassHandler<TextBox>((t, _) => Give(t, t.PlaceholderText)); TextBox.PlaceholderTextProperty.Changed.AddClassHandler<TextBox>((t, _) => Give(t, t.PlaceholderText));
@@ -82,6 +85,22 @@ public static class ScreenReaderNames
public static string? TimeText(TimeSpan? time) => public static string? TimeText(TimeSpan? time) =>
time?.ToString(@"hh\:mm", CultureInfo.InvariantCulture); time?.ToString(@"hh\:mm", CultureInfo.InvariantCulture);
/// <summary>
/// A panel with a title, such as Scenerie or Skład, made a named group: the reader
/// says where focus went in, where before the panel was not there for it at all.
/// Tabs and expanders, which are panels with a title too, speak for themselves.
/// </summary>
private static void NameGroup(HeaderedContentControl panel)
{
if (panel.GetType() != typeof(HeaderedContentControl) && panel is not SettingsSection)
return;
string? name = TextOf(panel.Header);
Give(panel, name);
AutomationProperties.SetControlTypeOverride(panel, name is null ? null : AutomationControlType.Group);
AutomationProperties.SetIsControlElementOverride(panel, name is null ? null : true);
}
private static void NameButton(Button button) => private static void NameButton(Button button) =>
Give(button, button.Content is string ? null : TextOf(ToolTip.GetTip(button)) ?? TextOf(button.Content)); Give(button, button.Content is string ? null : TextOf(ToolTip.GetTip(button)) ?? TextOf(button.Content));

View File

@@ -8,125 +8,129 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:StarterNG.Views" xmlns:views="clr-namespace:StarterNG.Views"
xmlns:starterNg="clr-namespace:StarterNG" xmlns:starterNg="clr-namespace:StarterNG"
xmlns:ctl="clr-namespace:StarterNG.Controls"
Title="Starter MaSzyna" Title="Starter MaSzyna"
Icon="/Assets/starter.ico" Icon="/Assets/starter.ico"
Width="1010" Height="768" MinWidth="1010" MinHeight="666" Width="1010" Height="768" MinWidth="1010" MinHeight="666"
WindowStartupLocation="CenterScreen"> WindowStartupLocation="CenterScreen">
<DockPanel LastChildFill="True"> <!-- Says what a click changed out of sight; see Announcer. -->
<ctl:Announcer>
<DockPanel LastChildFill="True">
<Border x:Name="TopBar" DockPanel.Dock="Top" <Border x:Name="TopBar" DockPanel.Dock="Top"
Background="{StaticResource CarbonPanelBg}" Background="{StaticResource CarbonPanelBg}"
BorderBrush="{StaticResource CarbonBorderLight}" BorderBrush="{StaticResource CarbonBorderLight}"
BorderThickness="0,0,0,1" BorderThickness="0,0,0,1"
PointerPressed="TitleBar_OnPointerPressed"> PointerPressed="TitleBar_OnPointerPressed">
<Grid RowDefinitions="44"> <Grid RowDefinitions="44">
<Grid ColumnDefinitions="Auto,*,Auto" Background="Transparent"> <Grid ColumnDefinitions="Auto,*,Auto" Background="Transparent">
<StackPanel x:Name="TopBarLeft" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Stretch"> <StackPanel x:Name="TopBarLeft" Grid.Column="0" AutomationProperties.LandmarkType="Navigation" AutomationProperties.ControlTypeOverride="Group" AutomationProperties.IsControlElementOverride="True" Orientation="Horizontal" VerticalAlignment="Stretch">
<RadioButton x:Name="NavScenarios" GroupName="nav" Theme="{StaticResource NavTab}" <RadioButton x:Name="NavScenarios" GroupName="nav" Theme="{StaticResource NavTab}"
Tag="scenarios" IsChecked="True" Tag="scenarios" IsChecked="True"
IsCheckedChanged="Nav_OnCheckedChanged" IsCheckedChanged="Nav_OnCheckedChanged"
Content="{Binding [NavScenarios], Source={x:Static starterNg:App.Loc}}" /> Content="{Binding [NavScenarios], Source={x:Static starterNg:App.Loc}}" />
<RadioButton x:Name="NavDepot" GroupName="nav" Theme="{StaticResource NavTab}" <RadioButton x:Name="NavDepot" GroupName="nav" Theme="{StaticResource NavTab}"
Tag="depot" Tag="depot"
IsCheckedChanged="Nav_OnCheckedChanged" IsCheckedChanged="Nav_OnCheckedChanged"
Content="{Binding [NavDepot], Source={x:Static starterNg:App.Loc}}" /> Content="{Binding [NavDepot], Source={x:Static starterNg:App.Loc}}" />
<RadioButton x:Name="NavSettings" GroupName="nav" Theme="{StaticResource NavTab}" <RadioButton x:Name="NavSettings" GroupName="nav" Theme="{StaticResource NavTab}"
Tag="settings" Tag="settings"
IsCheckedChanged="Nav_OnCheckedChanged" IsCheckedChanged="Nav_OnCheckedChanged"
Content="{Binding [NavSettings], Source={x:Static starterNg:App.Loc}}" /> Content="{Binding [NavSettings], Source={x:Static starterNg:App.Loc}}" />
<Button Classes="Basic" Click="openLastLogClick" Width="48" Cursor="Hand" <Button Classes="Basic" Click="openLastLogClick" Width="48" Cursor="Hand"
HorizontalContentAlignment="Center" HorizontalContentAlignment="Center"
ToolTip.Tip="{Binding [ShowLatestLogTooltip], Source={x:Static starterNg:App.Loc}}"> ToolTip.Tip="{Binding [ShowLatestLogTooltip], Source={x:Static starterNg:App.Loc}}">
<materialIcons:MaterialIcon Kind="FileDocument" Height="16" Width="16" /> <materialIcons:MaterialIcon Kind="FileDocument" Height="16" Width="16" />
</Button> </Button>
<Button Classes="Basic" Click="openHaslerTapesClick" Width="48" Cursor="Hand" <Button Classes="Basic" Click="openHaslerTapesClick" Width="48" Cursor="Hand"
HorizontalContentAlignment="Center" HorizontalContentAlignment="Center"
ToolTip.Tip="{Binding [HaslerTapesTooltip], Source={x:Static starterNg:App.Loc}}"> ToolTip.Tip="{Binding [HaslerTapesTooltip], Source={x:Static starterNg:App.Loc}}">
<materialIcons:MaterialIcon Kind="ChartLine" Height="16" Width="16" /> <materialIcons:MaterialIcon Kind="ChartLine" Height="16" Width="16" />
</Button> </Button>
<Button x:Name="HelpButton" Classes="Basic" Width="48" Cursor="Hand" <Button x:Name="HelpButton" Classes="Basic" Width="48" Cursor="Hand"
ToolTip.Tip="{Binding [Help], Source={x:Static starterNg:App.Loc}}" ToolTip.Tip="{Binding [Help], Source={x:Static starterNg:App.Loc}}"
Click="HelpButton_OnClick" Click="HelpButton_OnClick"
Content="?" FontWeight="Bold" FontSize="16" Content="?" FontWeight="Bold" FontSize="16"
HorizontalContentAlignment="Center" /> HorizontalContentAlignment="Center" />
</StackPanel>
<StackPanel x:Name="TopBarRight" Grid.Column="2" Orientation="Horizontal"
VerticalAlignment="Center" Margin="0,0,3,0" Spacing="0">
<StackPanel x:Name="VersionPanel" Orientation="Vertical" VerticalAlignment="Center" Margin="0,0,6,0">
<Label Content="{Binding [Version], Source={x:Static starterNg:App.Loc}}"
FontSize="12" Foreground="{StaticResource CarbonFgDim}" Padding="0" />
<Label Content="{x:Static starterNg:AppInfo.Version}"
FontSize="12" Foreground="{StaticResource CarbonFg}" Padding="0" />
</StackPanel> </StackPanel>
<ComboBox x:Name="LangCombo" Width="96" VerticalAlignment="Center" <StackPanel x:Name="TopBarRight" Grid.Column="2" Orientation="Horizontal"
AutomationProperties.Name="{Binding [Language], Source={x:Static starterNg:App.Loc}}" VerticalAlignment="Center" Margin="0,0,3,0" Spacing="0">
SelectionChanged="LangCombo_OnSelectionChanged" /> <StackPanel x:Name="VersionPanel" Orientation="Vertical" VerticalAlignment="Center" Margin="0,0,6,0">
<Label Content="{Binding [Version], Source={x:Static starterNg:App.Loc}}"
FontSize="12" Foreground="{StaticResource CarbonFgDim}" Padding="0" />
<Label Content="{x:Static starterNg:AppInfo.Version}"
FontSize="12" Foreground="{StaticResource CarbonFg}" Padding="0" />
</StackPanel>
<Button Classes="Basic" Cursor="Hand" Tag="https://discord.gg/eu07" Click="linkClick" <ComboBox x:Name="LangCombo" Width="96" VerticalAlignment="Center"
ToolTip.Tip="Discord"> AutomationProperties.Name="{Binding [Language], Source={x:Static starterNg:App.Loc}}"
<PathIcon Data="{StaticResource DiscordLogo}" Height="12" /> SelectionChanged="LangCombo_OnSelectionChanged" />
</Button>
<Button Classes="Basic" Cursor="Hand" Tag="http://www.facebook.com/MaSzynaeu07pl" Click="linkClick"
ToolTip.Tip="Facebook">
<materialIcons:MaterialIcon Kind="Facebook" />
</Button>
<Button Classes="Basic" Cursor="Hand" Tag="http://www.youtube.com/@eu07official" Click="linkClick"
ToolTip.Tip="YouTube">
<materialIcons:MaterialIcon Kind="Youtube" />
</Button>
<Button Classes="Basic" Cursor="Hand" Tag="http://github.com/MaSzyna-EU07/" Click="linkClick"
ToolTip.Tip="GitHub">
<materialIcons:MaterialIcon Kind="Github" />
</Button>
<Button x:Name="LogoLink" Classes="Basic" Cursor="Hand" Tag="http://eu07.pl/" Click="linkClick" <Button Classes="Basic" Cursor="Hand" Tag="https://discord.gg/eu07" Click="linkClick"
Padding="6,0" Margin="4,0,0,0" ToolTip.Tip="Discord">
ToolTip.Tip="eu07.pl"> <PathIcon Data="{StaticResource DiscordLogo}" Height="12" />
<Image Source="/Assets/Logo/maszyna_white.png" Height="26" /> </Button>
</Button> <Button Classes="Basic" Cursor="Hand" Tag="http://www.facebook.com/MaSzynaeu07pl" Click="linkClick"
</StackPanel> ToolTip.Tip="Facebook">
<materialIcons:MaterialIcon Kind="Facebook" />
</Button>
<Button Classes="Basic" Cursor="Hand" Tag="http://www.youtube.com/@eu07official" Click="linkClick"
ToolTip.Tip="YouTube">
<materialIcons:MaterialIcon Kind="Youtube" />
</Button>
<Button Classes="Basic" Cursor="Hand" Tag="http://github.com/MaSzyna-EU07/" Click="linkClick"
ToolTip.Tip="GitHub">
<materialIcons:MaterialIcon Kind="Github" />
</Button>
<Button x:Name="LogoLink" Classes="Basic" Cursor="Hand" Tag="http://eu07.pl/" Click="linkClick"
Padding="6,0" Margin="4,0,0,0"
ToolTip.Tip="eu07.pl">
<Image Source="/Assets/Logo/maszyna_white.png" Height="26" />
</Button>
</StackPanel>
</Grid>
</Grid> </Grid>
</Border>
<!-- The other ways to start - without saving, free fly - were only under the
right button; the arrow beside it says they exist. The editor is not one
of them: it opens the scenery itself, so it has a button of its own. -->
<Grid DockPanel.Dock="Bottom" ColumnDefinitions="*,Auto,Auto,Auto" ColumnSpacing="4" Margin="3">
<Button Name="startButton" Classes="Start" Height="42"
TabIndex="9"
Click="StartButton_OnClick"
Content="{Binding [Start], Source={x:Static starterNg:App.Loc}}" />
<Button Name="startMoreButton" Grid.Column="1" Classes="Start" Width="36" Height="42"
TabIndex="10" Cursor="Hand"
Click="StartMoreButton_OnClick"
ToolTip.Tip="{Binding [StartMore], Source={x:Static starterNg:App.Loc}}">
<materialIcons:MaterialIcon Kind="ChevronUp" Width="20" Height="20" />
</Button>
<Button Name="startEditorButton" Grid.Column="2" Classes="Flat" Height="42" Padding="14,0"
TabIndex="11" Cursor="Hand" VerticalContentAlignment="Center"
Click="StartEditorButton_OnClick" />
<Button Name="startEditorMoreButton" Grid.Column="3" Classes="Flat" Width="36" Height="42" Padding="0"
TabIndex="12" Cursor="Hand" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Click="StartEditorMoreButton_OnClick"
ToolTip.Tip="{Binding [StartEditorWizard], Source={x:Static starterNg:App.Loc}}">
<materialIcons:MaterialIcon Kind="ChevronUp" Width="20" Height="20" />
</Button>
</Grid> </Grid>
</Border>
<!-- The other ways to start - without saving, free fly - were only under the <!-- Scrolls only below the size the pages are laid out for; see KeepPagesUsable. -->
right button; the arrow beside it says they exist. The editor is not one <ScrollViewer x:Name="PageScroll" AutomationProperties.LandmarkType="Main" Margin="3,3,3,0" TabIndex="1"
of them: it opens the scenery itself, so it has a button of its own. --> HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled">
<Grid DockPanel.Dock="Bottom" ColumnDefinitions="*,Auto,Auto,Auto" ColumnSpacing="4" Margin="3"> <Panel x:Name="PageHost">
<Button Name="startButton" Classes="Start" Height="42" <views:Scenarios x:Name="ScenariosView" />
TabIndex="9" <views:Depot x:Name="DepotView" IsVisible="False" />
Click="StartButton_OnClick" <views:Settings x:Name="SettingsView" IsVisible="False" />
Content="{Binding [Start], Source={x:Static starterNg:App.Loc}}" /> </Panel>
<Button Name="startMoreButton" Grid.Column="1" Classes="Start" Width="36" Height="42" </ScrollViewer>
TabIndex="10" Cursor="Hand" </DockPanel>
Click="StartMoreButton_OnClick" </ctl:Announcer>
ToolTip.Tip="{Binding [StartMore], Source={x:Static starterNg:App.Loc}}">
<materialIcons:MaterialIcon Kind="ChevronUp" Width="20" Height="20" />
</Button>
<Button Name="startEditorButton" Grid.Column="2" Classes="Flat" Height="42" Padding="14,0"
TabIndex="11" Cursor="Hand" VerticalContentAlignment="Center"
Click="StartEditorButton_OnClick" />
<Button Name="startEditorMoreButton" Grid.Column="3" Classes="Flat" Width="36" Height="42" Padding="0"
TabIndex="12" Cursor="Hand" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
Click="StartEditorMoreButton_OnClick"
ToolTip.Tip="{Binding [StartEditorWizard], Source={x:Static starterNg:App.Loc}}">
<materialIcons:MaterialIcon Kind="ChevronUp" Width="20" Height="20" />
</Button>
</Grid>
<!-- Scrolls only below the size the pages are laid out for; see KeepPagesUsable. -->
<ScrollViewer x:Name="PageScroll" Margin="3,3,3,0" TabIndex="1"
HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled">
<Panel x:Name="PageHost">
<views:Scenarios x:Name="ScenariosView" />
<views:Depot x:Name="DepotView" IsVisible="False" />
<views:Settings x:Name="SettingsView" IsVisible="False" />
</Panel>
</ScrollViewer>
</DockPanel>
</Window> </Window>

View File

@@ -81,7 +81,7 @@
PointerWheelChanged="Combo_OnPointerWheel" PointerWheelChanged="Combo_OnPointerWheel"
SelectionChanged="ClassCombo_OnSelectionChanged" /> SelectionChanged="ClassCombo_OnSelectionChanged" />
<TextBox Name="searchBox" Grid.Row="3" Margin="0,0,0,6" <TextBox Name="searchBox" AutomationProperties.LandmarkType="Search" Grid.Row="3" Margin="0,0,0,6"
PlaceholderText="{Binding [SearchAllVehicles], Source={x:Static starterNg:App.Loc}}" PlaceholderText="{Binding [SearchAllVehicles], Source={x:Static starterNg:App.Loc}}"
TextChanged="SearchBox_OnTextChanged" /> TextChanged="SearchBox_OnTextChanged" />

View File

@@ -836,6 +836,7 @@ public partial class Scenarios : UserControl
{ {
var now = DateTime.Now; var now = DateTime.Now;
weatherTime.SelectedTime = new TimeSpan(now.Hour, now.Minute, 0); weatherTime.SelectedTime = new TimeSpan(now.Hour, now.Minute, 0);
Announcer.Say(this, ScreenReaderNames.PickerText(App.Loc["Time"], ScreenReaderNames.TimeText(weatherTime.SelectedTime)));
} }
private void WeatherRestore_OnClick(object? sender, RoutedEventArgs e) private void WeatherRestore_OnClick(object? sender, RoutedEventArgs e)
@@ -843,8 +844,18 @@ public partial class Scenarios : UserControl
if (_currentScenery is null) return; if (_currentScenery is null) return;
_currentScenery.Weather.Restore(); _currentScenery.Weather.Restore();
ShowWeather(_currentScenery); ShowWeather(_currentScenery);
Announcer.Say(this, WeatherSummary());
} }
/// <summary>The weather as a reader hears it once put back: every field and its value.</summary>
private string WeatherSummary() => string.Join(", ",
ScreenReaderNames.PickerText(App.Loc["Date"], ScreenReaderNames.DateText(weatherDate.SelectedDate, weatherDate.YearVisible)),
ScreenReaderNames.PickerText(App.Loc["Season"], ScreenReaderNames.TextOf(weatherSeason.SelectedItem)),
ScreenReaderNames.PickerText(App.Loc["Time"], ScreenReaderNames.TimeText(weatherTime.SelectedTime)),
ScreenReaderNames.PickerText(App.Loc["Temperature"], weatherTempLabel.Text),
ScreenReaderNames.PickerText(App.Loc["Visibility"], weatherFogLabel.Text),
ScreenReaderNames.PickerText(App.Loc["Overcast"], ScreenReaderNames.TextOf(weatherOvercast.SelectedItem)));
private static TimeSpan? ParseTime(string? text) private static TimeSpan? ParseTime(string? text)
{ {
if (string.IsNullOrWhiteSpace(text)) if (string.IsNullOrWhiteSpace(text))

View File

@@ -22,7 +22,7 @@
TextTrimming="LeadingCharacterEllipsis" /> TextTrimming="LeadingCharacterEllipsis" />
</DockPanel> </DockPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="12" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="12" HorizontalAlignment="Right">
<TextBlock x:Name="SaveStatus" VerticalAlignment="Center" Opacity="0.8" Text="" /> <TextBlock x:Name="SaveStatus" ctl:Announcer.Changes="True" VerticalAlignment="Center" Opacity="0.8" Text="" />
<Button x:Name="ChangesButton" Classes="Flat" Click="ChangesButton_OnClick" <Button x:Name="ChangesButton" Classes="Flat" Click="ChangesButton_OnClick"
Content="{Binding [IniChangesButton], Source={x:Static starterNg:App.Loc}}" /> Content="{Binding [IniChangesButton], Source={x:Static starterNg:App.Loc}}" />
<Button x:Name="ResetButton" Classes="Flat" Click="ResetButton_OnClick" <Button x:Name="ResetButton" Classes="Flat" Click="ResetButton_OnClick"
@@ -40,7 +40,7 @@
<Border Grid.Column="0" Background="{StaticResource CarbonPanelBg}" <Border Grid.Column="0" Background="{StaticResource CarbonPanelBg}"
BorderBrush="{StaticResource CarbonBorderLight}" BorderThickness="0,0,1,0"> BorderBrush="{StaticResource CarbonBorderLight}" BorderThickness="0,0,1,0">
<DockPanel Margin="8,10,8,10"> <DockPanel Margin="8,10,8,10">
<TextBox x:Name="SettingsSearch" DockPanel.Dock="Top" Margin="0,0,0,10" <TextBox x:Name="SettingsSearch" AutomationProperties.LandmarkType="Search" DockPanel.Dock="Top" Margin="0,0,0,10"
PlaceholderText="{Binding [Search], Source={x:Static starterNg:App.Loc}}" PlaceholderText="{Binding [Search], Source={x:Static starterNg:App.Loc}}"
TextChanged="SettingsSearch_OnTextChanged" /> TextChanged="SettingsSearch_OnTextChanged" />
@@ -69,7 +69,7 @@
Click="ExportIniButton_OnClick" /> Click="ExportIniButton_OnClick" />
</StackPanel> </StackPanel>
<ListBox x:Name="CategoryList" Classes="SettingsNav" SelectedIndex="0" <ListBox x:Name="CategoryList" AutomationProperties.LandmarkType="Navigation" Classes="SettingsNav" SelectedIndex="0"
ItemContainerTheme="{StaticResource SettingsNavItem}" ItemContainerTheme="{StaticResource SettingsNavItem}"
SelectionChanged="CategoryList_OnSelectionChanged"> SelectionChanged="CategoryList_OnSelectionChanged">
<ListBoxItem Tag="general" Content="{Binding [General], Source={x:Static starterNg:App.Loc}}" /> <ListBoxItem Tag="general" Content="{Binding [General], Source={x:Static starterNg:App.Loc}}" />
@@ -94,7 +94,7 @@
<TextBlock VerticalAlignment="Center" FontWeight="Bold" <TextBlock VerticalAlignment="Center" FontWeight="Bold"
Text="{Binding [GfxColPresets], Source={x:Static starterNg:App.Loc}}" /> Text="{Binding [GfxColPresets], Source={x:Static starterNg:App.Loc}}" />
<StackPanel x:Name="PresetButtons" Grid.Column="1" Orientation="Horizontal" Spacing="6" /> <StackPanel x:Name="PresetButtons" Grid.Column="1" Orientation="Horizontal" Spacing="6" />
<TextBlock x:Name="PresetStateText" Grid.Column="2" VerticalAlignment="Center" FontSize="12" <TextBlock x:Name="PresetStateText" ctl:Announcer.Changes="True" Grid.Column="2" VerticalAlignment="Center" FontSize="12"
Foreground="{StaticResource CarbonFgDim}" /> Foreground="{StaticResource CarbonFgDim}" />
</Grid> </Grid>
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="10"> <Grid ColumnDefinitions="Auto,*" ColumnSpacing="10">

View File

@@ -580,6 +580,7 @@ public partial class Settings : UserControl, ISettingsCapture
// Chosen as a whole, its values are choices, not ones the screen could not show. // Chosen as a whole, its values are choices, not ones the screen could not show.
ForgetShown(applied.ChosenKeys); ForgetShown(applied.ChosenKeys);
UpdatePresetMarks(); UpdatePresetMarks();
Announcer.Say(this, ScreenReaderNames.PickerText(App.Loc["GfxColPresets"], App.Loc[preset.NameKey]));
} }
/// <summary>Puts one part at a level, as edits waiting for Save.</summary> /// <summary>Puts one part at a level, as edits waiting for Save.</summary>
@@ -747,6 +748,7 @@ public partial class Settings : UserControl, ISettingsCapture
// Put back by hand, a value is a choice like any other. // Put back by hand, a value is a choice like any other.
ForgetShown(keys); ForgetShown(keys);
Announcer.Say(this, ScreenReaderNames.PickerText(ScreenReaderNames.TextOf(section.Header), App.Loc["DefaultsRestored"]));
} }
// ── Values the screen shows otherwise than the file has them ───────────── // ── Values the screen shows otherwise than the file has them ─────────────
@@ -1147,6 +1149,7 @@ public partial class Settings : UserControl, ISettingsCapture
_keyBindings.Reload(); _keyBindings.Reload();
_dirty = false; _dirty = false;
UpdateSaveState(); UpdateSaveState();
Announcer.Say(this, App.Loc["SettingsRestored"]);
} }
/// <summary>The list as <see cref="ResolutionChoices"/> has it for the monitors there are now, with the size selected.</summary> /// <summary>The list as <see cref="ResolutionChoices"/> has it for the monitors there are now, with the size selected.</summary>

View File

@@ -563,6 +563,8 @@
<String key="Save">Uložit</String> <String key="Save">Uložit</String>
<String key="Reset">Obnovit</String> <String key="Reset">Obnovit</String>
<String key="SettingsSaved">Nastavení uloženo</String> <String key="SettingsSaved">Nastavení uloženo</String>
<String key="DefaultsRestored">Výchozí hodnoty obnoveny</String>
<String key="SettingsRestored">Uložené nastavení obnoveno</String>
<String key="SettingsNotSaved">Nastavení se nepodařilo uložit</String> <String key="SettingsNotSaved">Nastavení se nepodařilo uložit</String>
<String key="UnsavedChanges">Neuložené změny</String> <String key="UnsavedChanges">Neuložené změny</String>

View File

@@ -589,6 +589,8 @@
<String key="Save">Save</String> <String key="Save">Save</String>
<String key="Reset">Reset</String> <String key="Reset">Reset</String>
<String key="SettingsSaved">Settings saved</String> <String key="SettingsSaved">Settings saved</String>
<String key="DefaultsRestored">Defaults restored</String>
<String key="SettingsRestored">Saved settings restored</String>
<String key="SettingsNotSaved">Could not save the settings</String> <String key="SettingsNotSaved">Could not save the settings</String>
<String key="UnsavedChanges">Unsaved changes</String> <String key="UnsavedChanges">Unsaved changes</String>

View File

@@ -563,6 +563,8 @@
<String key="Save">Mentés</String> <String key="Save">Mentés</String>
<String key="Reset">Visszaállítás</String> <String key="Reset">Visszaállítás</String>
<String key="SettingsSaved">A beállítások elmentve</String> <String key="SettingsSaved">A beállítások elmentve</String>
<String key="DefaultsRestored">Alapértékek visszaállítva</String>
<String key="SettingsRestored">A mentett beállítások visszaállítva</String>
<String key="SettingsNotSaved">A beállításokat nem sikerült elmenteni</String> <String key="SettingsNotSaved">A beállításokat nem sikerült elmenteni</String>
<String key="UnsavedChanges">Nem mentett módosítások</String> <String key="UnsavedChanges">Nem mentett módosítások</String>

View File

@@ -589,6 +589,8 @@
<String key="Save">Zapisz</String> <String key="Save">Zapisz</String>
<String key="Reset">Przywróć</String> <String key="Reset">Przywróć</String>
<String key="SettingsSaved">Zapisano ustawienia</String> <String key="SettingsSaved">Zapisano ustawienia</String>
<String key="DefaultsRestored">Przywrócono domyślne</String>
<String key="SettingsRestored">Przywrócono zapisane ustawienia</String>
<String key="SettingsNotSaved">Nie udało się zapisać ustawień</String> <String key="SettingsNotSaved">Nie udało się zapisać ustawień</String>
<String key="UnsavedChanges">Niezapisane zmiany</String> <String key="UnsavedChanges">Niezapisane zmiany</String>

View File

@@ -563,6 +563,8 @@
<String key="Save">Сохранить</String> <String key="Save">Сохранить</String>
<String key="Reset">Сбросить</String> <String key="Reset">Сбросить</String>
<String key="SettingsSaved">Настройки сохранены</String> <String key="SettingsSaved">Настройки сохранены</String>
<String key="DefaultsRestored">Восстановлены значения по умолчанию</String>
<String key="SettingsRestored">Восстановлены сохранённые настройки</String>
<String key="SettingsNotSaved">Не удалось сохранить настройки</String> <String key="SettingsNotSaved">Не удалось сохранить настройки</String>
<String key="UnsavedChanges">Несохранённые изменения</String> <String key="UnsavedChanges">Несохранённые изменения</String>