Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5 dfef7559cb feat(app): the accessibility pass -- Ctrl+1..5, Esc closes dialogs, an automation name on every textless input (P4 PR-8)
08_UI gains an Accessibility section first, then the build it describes. Ctrl+1..5 (and the keypad)
open Dashboard, Games, Compare, Logs and Settings through ShellShortcuts, the one place that knows
which number is which page. Esc closes the open ContentDialog or MessageBox with no result through
the dialog's own Close path, and never one that offers no Close button: WPF UI 4.3.0 handles no key
in either, ContentDialog.CloseButtonText defaults to "Close", and MessageBox.Close() is obsolete, so
DialogKeyboard uses the Close button's TemplateButtonCommand from one class handler on Window.

Thirty controls that announced only their type carry an AutomationProperties.Name from .resx; four
new strings (en/vi/ja) name the ones with no label to borrow. The maintenance dialog's status line is
a polite live region. AccessibilityTests hold all of it: every textless input is named (proven red on
the kill switch), no XAML hard-codes a colour, the manifest is Per-Monitor V2, the shortcuts follow the
NavigationView's order, and Esc closes a real ContentDialog with no result.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 01:10:05 +07:00
26 changed files with 542 additions and 20 deletions

No files matched your search

+18
View File
@@ -21,6 +21,24 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
### Added
- **P4 PR-8 — the accessibility pass, with the section it passes against written first (NFR-9, 2026-09-15).**
NFR-9 was one sentence and `08_UI` one bullet ("Ctrl+1…5; grids fully navigable; Esc closes flyouts/dialogs"), none
of it built. `08_UI` §Accessibility now says what each clause means here and names the check: **Ctrl+1 … Ctrl+5**
and the keypad open Dashboard / Games / Compare / Logs / Settings (`MainWindow` `InputBindings` →
`MainWindowViewModel.NavigateToCommand` → `ShellShortcuts`), and `AccessibilityTests` holds the bindings, the map and
the NavigationView's order together; **Esc closes the open `ContentDialog` or `MessageBox` with no result**, through
its own Close path, and never a dialog that offers no Close button (`Services/DialogKeyboard`, one class handler on
`Window` registered in `App.OnStartup`, bubbling so a dropdown's Esc wins) — WPF UI 4.3.0 handles no key in either
dialog, measured in its source; **every input that shows no text of its own has an `AutomationProperties.Name`** —
thirty controls had none (every Settings toggle, number box and choice box, the hooking switch, the trend metric,
the Games and Logs filters and search boxes, the log tail, the edit-game and consent text boxes, the Legal Gate's
document, the summary window's tags and notes, and the icon-only close button in the `InfoBar` template), a scan of
the App's XAML goes red on the next one (proven by removing one name), and four new strings name the controls that
had no label to borrow (en/vi/ja); **no XAML hard-codes a colour** (a second scan), so contrast is the Fluent
themes'; the manifest is Per-Monitor V2 (a third). Known gaps are stated there: ScottPlot plots are not
keyboard-operable, and no Narrator pass has been done. Docs: `08_UI` §Accessibility and §UX rules, `02_SPEC` NFR-9,
`16_WPFUI_SYNTAX` §Gotchas (no Esc in 4.3.0, `CloseButtonText` defaults to "Close", the obsolete `MessageBox.Close`),
`15_ROADMAP`, HANDOFF §P4. The Database maintenance dialog's status line is `LiveSetting="Polite"`, so a result is read out.
- **P4 PR-7 — Tools ▸ Database maintenance: integrity check, backup, the retention sweep on demand, compaction
(2026-09-15).** `06_DATA_MODEL` §Retention promised the four since P0; the menu item said "not built yet". **The
sweep is the Agent's**, because `frame_blobs` and `sensor_blobs` are (§Writer ownership): the App sends the new
+1 -1
View File
@@ -100,7 +100,7 @@ Draw live FPS/frametime/upscaler info inside the game. Only for games already ho
- **NFR-6 Accuracy:** per `03_METRICS` §Accuracy budget, stated per tier.
- **NFR-7 Resilience:** power loss loses at most the last 60 s of raw data; DB never corrupts (WAL + transactions); Agent restart recovers `.partial` sessions as `interrupted`.
- **NFR-8 OS support:** Windows 10 22H2+ and Windows 11, x64. No ARM64 in v1.
- **NFR-9 Accessibility:** full keyboard navigation, adequate contrast in both Fluent themes, Per-Monitor V2 DPI awareness.
- **NFR-9 Accessibility:** full keyboard navigation, adequate contrast in both Fluent themes, Per-Monitor V2 DPI awareness. *(What each clause means for this app, and the check that holds it: `08_UI` §Accessibility, P4 PR-8.)*
- **NFR-10 Offline-first:** everything except updates and opt-in metadata works with zero connectivity.
- **NFR-11 Auditability:** the entire set of hooks is enumerable in `17_HOOK_ENGINE` §Hook inventory and matches the code; a reviewer must be able to verify in minutes that nothing reads game memory.
+51 -1
View File
@@ -324,6 +324,56 @@ Agent section: elevation state with a plain explanation of what elevation *optio
- Empty states for every list ("No sessions yet — launch a tracked game and FrameLedger will do the rest").
- All destructive actions confirm via `Wpf.Ui.Controls.MessageBox` (async — 16 §Dialogs): delete game/sessions, DB maintenance.
- Notifications strictly per the policy above (snackbar / InfoBar / tray).
- Keyboard: NavigationView items Ctrl+1…5; grids fully navigable; Esc closes flyouts/dialogs.
- Keyboard: ~~NavigationView items Ctrl+1…5; grids fully navigable; Esc closes flyouts/dialogs~~ — §Accessibility below, since P4 PR-8 (2026-09-15); this bullet named three behaviours and none of them was built or checked.
- No blocking dialogs during capture; errors surface as InfoBars/tray toasts.
- Charts and stat numbers use culture-aware formatting per active UI culture (09); colors only from theme resources or the per-theme chart palette (16 §ScottPlot).
## Accessibility
NFR-9 names three things — full keyboard navigation, adequate contrast in both Fluent themes, Per-Monitor V2 DPI —
and this section is what they mean for this app, each with the test that holds it (P4 PR-8, 2026-09-15). Until then
the requirement was one bullet under §UX rules, and nothing checked it.
### Keyboard
| Keys | Does | Where |
|---|---|---|
| **Ctrl+1 … Ctrl+5** (and the numeric keypad's 1–5) | Dashboard · Games · Compare · Logs · Settings | `MainWindow` `InputBindings` → `MainWindowViewModel.NavigateToCommand` → `ShellShortcuts` |
| **Alt**, **F10** | Focuses the menu bar; arrows and Enter walk File / Tools / Help | WPF `Menu`, nothing custom |
| **Tab / Shift+Tab** | Moves through a page in reading order | layout order; no `TabIndex` overrides |
| **Arrows, Home/End, Page Up/Down** | Move within a `DataGrid` (Sessions, Compare picker, Import checklist) | `DataGrid` defaults |
| **Esc** | Closes the open `ContentDialog` or `MessageBox` with no result — the same as its Close/Cancel button | `DialogKeyboard`, one class handler per dialog type registered at start-up |
**Esc is the Close button, never the primary one.** On the consent dialog (FR-2.1) that is "Keep it off": nothing is
stamped. A dialog that offers no Close button is not dismissed by Esc, and the Legal Gate (FR-11) is a window of its own
(`FirstRunWindow`) with explicit Decline and Accept, on which Esc does nothing. WPF UI 4.3.0 handles no key in
either dialog type (its `ContentDialog.cs` and `MessageBox.cs` at tag 4.3.0 have no key handler — read 2026-09-15),
which is why the handler is ours.
### Screen readers
- Every interactive control that shows no text of its own carries `AutomationProperties.Name` from `.resx` — the
toggles and choice boxes on Settings, the hooking switch on a game's page, and the icon-only close button in the
`InfoBar` template. A control *with* visible text needs nothing: its text is its name.
- `PagesLoadTests`-style scan (`AccessibilityTests.EveryTextlessControlHasAName`): every `Button`, `ToggleSwitch`,
`ToggleButton`, `CheckBox`, `ComboBox` and `HyperlinkButton` in the App's XAML either has content or a name. A new
unnamed one is red.
- Status lines that change after an action (the Database maintenance result) are `AutomationProperties.LiveSetting="Polite"`.
### Contrast
Colours come from the WPF UI theme dictionaries and nothing else, so contrast is the Fluent themes' — both of which
meet it — and cannot be broken locally: `AccessibilityTests.NoXamlHardCodesAColour` fails on any `#RRGGBB` or named
colour in the App's XAML. The chart palette is the one deliberate exception (`16_WPFUI_SYNTAX` §ScottPlot: one
palette per theme, chosen with the theme).
### DPI
`app.manifest` declares Per-Monitor V2 (`AccessibilityTests.TheManifestIsPerMonitorV2`).
### Known gaps, stated
- ScottPlot plots are not keyboard-operable (no focus, no pan/zoom by keys). The numbers behind them are on the
session summary's stat cards and in File ▸ Export (CSV/JSON).
- No screen-reader pass with Narrator has been done; the names above are necessary, not proven sufficient. That pass
is the owner's.
+1 -1
View File
@@ -317,7 +317,7 @@ Agent: watcher, tier selection, injection orchestration, shm drain, telemetry po
WPF UI shell (`16_WPFUI_SYNTAX`), library, per-game hooking consent flow, Dashboard live card showing *measured* settings, session summary, ScottPlot charts, game detail tabs, Compare with tier guarding, segment ribbon, tri-state chips with override, refusal/degradation/unhook notices as first-class UI. **Plus, moved here from P4 on 2026-09-13 (owner):** the command pipe (`07_IPC` §C — P2's decision D10 put it here), i18n en/vi/ja with `tools/resx-audit` (the consent dialog is the first thing that needs a reviewed `.resx`, so it cannot wait), the Legal Gate (FR-11), Settings (FR-10, the kill switch first), the Logs page, tray + toasts. The owner chose the whole of `08_UI` over a shell-first cut; HANDOFF §P3 carries the slice order and the decisions (D11–D17). *Not started as of 2026-09-13: `FrameLedger.App` is the scaffold, `FrameLedger.Shared` has no IPC type, and no `.resx` exists in the tree.*
## P4 — Detection & product polish (1 week)
~~Static rules engine + `detection-rules.json` (engines, platforms, capabilities, **anticheat blocklist**) + validator + fixtures~~ **landed 2026-09-14 (P4 PR-1: the engine existed since P0; the Agent's `DetectionSweep` is its first caller, `ApplyDetectionAsync` its first writer — HANDOFF §P4)**; ~~store auto-import~~ **landed 2026-09-14 (P4 PR-4)**; ~~capability-vs-measured UI separation~~ **(PR-1: the Supports row reads the sweep's flags)**; ~~i18n en/vi/ja; Legal Gate;~~ ~~Velopack + updater (with the hooked-session deferral)~~ **landed 2026-09-14 (P4 PR-5 — the deferral is `UpdateService`'s shape, not a flag)**; bug bundle incl. overlay logs; ~~tray + toasts; Settings;~~ ~~DB maintenance~~ **landed 2026-09-15 (P4 PR-7: the sweep is the Agent's over `SweepRetention`; integrity, backup and compaction in the App)**; accessibility pass; ~~the scheduled task (`--install-task`)~~ (P3 PR-8b) and ~~the Velopack install hooks~~ **(PR-5: the uninstall hook; install registers nothing, by design — `12_BUILD` §The Vulkan layer is not registered at install time)**. *(The struck items moved to P3 on 2026-09-13 — see §P3.)*
~~Static rules engine + `detection-rules.json` (engines, platforms, capabilities, **anticheat blocklist**) + validator + fixtures~~ **landed 2026-09-14 (P4 PR-1: the engine existed since P0; the Agent's `DetectionSweep` is its first caller, `ApplyDetectionAsync` its first writer — HANDOFF §P4)**; ~~store auto-import~~ **landed 2026-09-14 (P4 PR-4)**; ~~capability-vs-measured UI separation~~ **(PR-1: the Supports row reads the sweep's flags)**; ~~i18n en/vi/ja; Legal Gate;~~ ~~Velopack + updater (with the hooked-session deferral)~~ **landed 2026-09-14 (P4 PR-5 — the deferral is `UpdateService`'s shape, not a flag)**; bug bundle incl. overlay logs; ~~tray + toasts; Settings;~~ ~~DB maintenance~~ **landed 2026-09-15 (P4 PR-7: the sweep is the Agent's over `SweepRetention`; integrity, backup and compaction in the App)**; ~~accessibility pass~~ **landed 2026-09-15 (P4 PR-8: `08_UI` §Accessibility written first — Ctrl+1…5, Esc on every dialog, an automation name on every textless input, theme colours only — each held by `AccessibilityTests`)**; ~~the scheduled task (`--install-task`)~~ (P3 PR-8b) and ~~the Velopack install hooks~~ **(PR-5: the uninstall hook; install registers nothing, by design — `12_BUILD` §The Vulkan layer is not registered at install time)**. *(The struck items moved to P3 on 2026-09-13 — see §P3.)*
## P5 — Ship (3–4 days)
CI/CD with the native build (`release.yml` exists since P4 PR-5, 2026-09-14 — untested by a tag yet); CodeQL (C# + C++); Dependabot; CHANGELOG; README with the P0 accuracy comparison — **which is not a percentage, and this line used to send its author looking for one**. The decision is recorded under item 3 and in `spike-notes.md` §8: the baseline can answer **none** of item 4's four runtime questions, so the defensible claim is *"the baseline cannot answer four of these five questions at all"*, not *"N% more accurate"*. Overhead + tier cross-validation measurements; release smoke on clean VMs; `v0.1.0-beta.1`.
+6
View File
@@ -205,3 +205,9 @@ On startup and on `ApplicationThemeManager.Changed`: for every live plot set fig
bar with no exit, which is exactly how the safety notices shipped (2026-09-14). `Styles/FrameLedger.xaml` carries
the upstream template plus one presenter column; `PagesLoadTests.TheInfoBarTemplateRendersItsContent` renders both
templates and turns red when upstream gains a presenter, which is when the copy comes out.
- [ ] **No dialog in 4.3.0 closes on Esc.** Neither `ContentDialog.cs` nor `MessageBox.cs` at the 4.3.0 tag handles a
key (read 2026-09-15), and `ContentDialog.CloseButtonText` DEFAULTS to "Close" — an empty string is how a dialog
says it has no Close button. `MessageBox.Close()` is `[Obsolete("Use Close with MessageBoxResult instead")]` while no
such overload is public; the Close button's own path is `TemplateButtonCommand.Execute(MessageBoxButton.Close)`.
`Services/DialogKeyboard` registers one class handler on `Window` (bubbling `KeyDown`, so a dropdown's Esc wins) and
closes through those paths; `AccessibilityTests.EscapeClosesTheOpenDialogWithNoResult` holds it (`08_UI` §Accessibility).
+1 -1
View File
@@ -1247,7 +1247,7 @@ script~~ **LANDED 2026-09-15 (P4 PR-6: `tools/license-gather.ps1` → `legal/lic
`15_ROADMAP` §P4's last two items were not in the list above: ~~DB maintenance~~ **LANDED 2026-09-15 (P4 PR-7:
Tools ▸ Database maintenance — the retention sweep on demand is the Agent's, over a new `SweepRetention` command with
no payload; integrity check, `VACUUM INTO` backup and compaction run in the App and change no row — `06_DATA_MODEL`
§Retention built note)**, and the accessibility pass, which needs `08_UI` §Accessibility written before any code.
§Retention built note)**, and ~~the accessibility pass, which needs `08_UI` §Accessibility written before any code~~ **LANDED 2026-09-15 (P4 PR-8: the section first, then `AccessibilityTests` — Ctrl+1…5, Esc on every dialog, an automation name on every textless input, theme colours only)**.
## P3 — ~~**START HERE**~~ (2026-09-13, owner-approved plan; **code-complete 2026-09-14** — every row below is struck with its PR)
+2
View File
@@ -55,6 +55,8 @@ public partial class App : System.Windows.Application
UiPaths.EnsureDirectories();
ConfigureLogging();
HookCrashHandlers();
// 08_UI §Accessibility (P4 PR-8): Esc closes the open ContentDialog or MessageBox, before any window exists.
DialogKeyboard.Register();
_run = DiagReport.Requested(e.Args) ? DiagAsync() : RunAsync();
}
@@ -44,6 +44,7 @@
Icon="{ui:SymbolIcon Open24}" />
</StackPanel>
<TextBox Grid.Row="1"
AutomationProperties.Name="{Binding ViewModel.SelectedDocument.Title}"
AcceptsReturn="True"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
@@ -31,6 +31,7 @@
<ui:TextBlock Margin="0,18,0,6" Appearance="Secondary" Text="{Binding TypeToConfirm}" TextWrapping="Wrap" />
<ui:TextBox x:Name="Acknowledgement"
AutomationProperties.Name="{Binding TypeToConfirm}"
Text="{Binding Typed, UpdateSourceTrigger=PropertyChanged}"
PlaceholderText="{x:Static vm:ConsentDialogViewModel.Phrase}" />
</StackPanel>
@@ -60,7 +60,7 @@
<DockPanel Margin="0,12,0,0">
<ui:ProgressRing Width="16" Height="16" Margin="0,0,8,0" DockPanel.Dock="Left" IsIndeterminate="True"
Visibility="{Binding IsBusy, Converter={StaticResource BoolToVis}}" />
<ui:TextBlock MaxWidth="680" HorizontalAlignment="Left" Text="{Binding Status}" TextWrapping="Wrap" />
<ui:TextBlock MaxWidth="680" HorizontalAlignment="Left" AutomationProperties.LiveSetting="Polite" Text="{Binding Status}" TextWrapping="Wrap" />
</DockPanel>
</StackPanel>
</UserControl>
@@ -15,23 +15,23 @@
Visibility="{Binding NameDetected, Converter={StaticResource BoolToVis}}" />
<ui:TextBlock Appearance="Secondary" Text="{x:Static vm:EditGameViewModel.NameLabel}" />
</DockPanel>
<ui:TextBox Margin="0,4,0,12" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBox Margin="0,4,0,12" AutomationProperties.Name="{x:Static vm:EditGameViewModel.NameLabel}" Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
<DockPanel>
<ui:Badge DockPanel.Dock="Right" Margin="8,0,0,0" Appearance="Info" Content="{x:Static vm:EditGameViewModel.DetectedBadge}"
Visibility="{Binding PublisherDetected, Converter={StaticResource BoolToVis}}" />
<ui:TextBlock Appearance="Secondary" Text="{x:Static vm:EditGameViewModel.PublisherLabel}" />
</DockPanel>
<ui:TextBox Margin="0,4,0,12" Text="{Binding Publisher, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBox Margin="0,4,0,12" AutomationProperties.Name="{x:Static vm:EditGameViewModel.PublisherLabel}" Text="{Binding Publisher, UpdateSourceTrigger=PropertyChanged}" />
<DockPanel>
<ui:Badge DockPanel.Dock="Right" Margin="8,0,0,0" Appearance="Info" Content="{x:Static vm:EditGameViewModel.DetectedBadge}"
Visibility="{Binding VersionDetected, Converter={StaticResource BoolToVis}}" />
<ui:TextBlock Appearance="Secondary" Text="{x:Static vm:EditGameViewModel.VersionLabel}" />
</DockPanel>
<ui:TextBox Margin="0,4,0,12" Text="{Binding Version, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBox Margin="0,4,0,12" AutomationProperties.Name="{x:Static vm:EditGameViewModel.VersionLabel}" Text="{Binding Version, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBlock Appearance="Secondary" Text="{x:Static vm:EditGameViewModel.NotesLabel}" />
<ui:TextBox Margin="0,4,0,0" MinHeight="72" AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding Notes, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBox Margin="0,4,0,0" MinHeight="72" AutomationProperties.Name="{x:Static vm:EditGameViewModel.NotesLabel}" AcceptsReturn="True" TextWrapping="Wrap" Text="{Binding Notes, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</UserControl>
+14
View File
@@ -13,6 +13,20 @@
WindowBackdropType="Mica"
WindowCornerPreference="Round"
WindowStartupLocation="CenterScreen">
<!-- 08_UI §Accessibility (P4 PR-8): Ctrl+1…5 open the NavigationView's pages in its order; ShellShortcuts holds the map. -->
<ui:FluentWindow.InputBindings>
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="1" Key="D1" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="2" Key="D2" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="3" Key="D3" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="4" Key="D4" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="5" Key="D5" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="1" Key="NumPad1" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="2" Key="NumPad2" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="3" Key="NumPad3" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="4" Key="NumPad4" Modifiers="Control" />
<KeyBinding Command="{Binding ViewModel.NavigateToCommand}" CommandParameter="5" Key="NumPad5" Modifiers="Control" />
</ui:FluentWindow.InputBindings>
<!--
docs/16_WPFUI_SYNTAX.md §Main window skeleton: TitleBar row, a classic Menu row BELOW it (never inside the
drag region), then the NavigationView. Every string is a resx key; every colour a theme brush.
@@ -108,7 +108,8 @@
<ui:CardControl Margin="0,12,0,0" Header="{x:Static vm:GameDetailViewModel.HookingHeader}" Icon="{ui:SymbolIcon ShieldTask24}">
<StackPanel Orientation="Horizontal">
<ui:TextBlock Appearance="Secondary" VerticalAlignment="Center" Margin="0,0,12,0" Text="{Binding ViewModel.HookStatusText}" />
<ui:ToggleSwitch IsChecked="{Binding ViewModel.HookEnabled, Mode=OneWay}"
<ui:ToggleSwitch AutomationProperties.Name="{x:Static vm:GameDetailViewModel.HookingHeader}"
IsChecked="{Binding ViewModel.HookEnabled, Mode=OneWay}"
IsEnabled="{Binding ViewModel.HookToggleEnabled}"
Command="{Binding ViewModel.ToggleHookingCommand}" />
</StackPanel>
@@ -232,7 +233,7 @@
<StackPanel Margin="0,12,0,0">
<StackPanel Orientation="Horizontal">
<ui:TextBlock Appearance="Secondary" VerticalAlignment="Center" Margin="0,0,8,0" Text="{x:Static vm:GameDetailViewModel.TrendMetricLabel}" />
<ComboBox MinWidth="180" DisplayMemberPath="Label" ItemsSource="{x:Static vm:GameDetailViewModel.TrendMetrics}"
<ComboBox MinWidth="180" AutomationProperties.Name="{x:Static vm:GameDetailViewModel.TrendMetricLabel}" DisplayMemberPath="Label" ItemsSource="{x:Static vm:GameDetailViewModel.TrendMetrics}"
SelectedValue="{Binding ViewModel.TrendMetric, Mode=TwoWay}" SelectedValuePath="Value" />
<CheckBox Margin="16,0,0,0" VerticalAlignment="Center" Content="{x:Static vm:GameDetailViewModel.IncludeMidSessionText}"
IsChecked="{Binding ViewModel.IncludeMidSession}" />
+2
View File
@@ -19,10 +19,12 @@
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Column="0" FontTypography="Title" Text="{x:Static vm:GamesViewModel.Header}" />
<ui:TextBox Grid.Column="1" MinWidth="220" Margin="0,0,12,0" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static vm:GamesViewModel.SearchPlaceholder}"
Icon="{ui:SymbolIcon Search24}"
PlaceholderText="{x:Static vm:GamesViewModel.SearchPlaceholder}"
Text="{Binding ViewModel.Search, UpdateSourceTrigger=PropertyChanged}" />
<ComboBox Grid.Column="2" MinWidth="150" Margin="0,0,12,0" VerticalAlignment="Center"
AutomationProperties.Name="{x:Static res:Strings.A11y_Games_Sort}"
DisplayMemberPath="Label"
ItemsSource="{x:Static vm:GamesViewModel.Sorts}"
SelectedValue="{Binding ViewModel.Sort, Mode=TwoWay}"
+4
View File
@@ -19,18 +19,21 @@
<WrapPanel Grid.Row="1" Margin="0,12,0,8" Orientation="Horizontal">
<ComboBox MinWidth="120"
Margin="0,0,8,4"
AutomationProperties.Name="{x:Static res:Strings.A11y_Logs_Source}"
DisplayMemberPath="Label"
ItemsSource="{x:Static vm:LogsViewModel.Sources}"
SelectedValue="{Binding ViewModel.Source, Mode=TwoWay}"
SelectedValuePath="Value" />
<ComboBox MinWidth="170"
Margin="0,0,8,4"
AutomationProperties.Name="{x:Static res:Strings.A11y_Logs_Level}"
DisplayMemberPath="Label"
ItemsSource="{x:Static vm:LogsViewModel.Levels}"
SelectedValue="{Binding ViewModel.Level, Mode=TwoWay}"
SelectedValuePath="Value" />
<ui:TextBox MinWidth="220"
Margin="0,0,8,4"
AutomationProperties.Name="{x:Static res:Strings.Logs_Search_Placeholder}"
Icon="{ui:SymbolIcon Search24}"
PlaceholderText="{x:Static res:Strings.Logs_Search_Placeholder}"
Text="{Binding ViewModel.Search, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
@@ -51,6 +54,7 @@
<TextBox x:Name="Tail"
Grid.Row="2"
AutomationProperties.Name="{x:Static res:Strings.A11y_Logs_Tail}"
AcceptsReturn="True"
FontFamily="Consolas"
FontSize="12"
+13 -7
View File
@@ -22,7 +22,7 @@
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_KillSwitch_Label}" />
<ui:TextBlock Appearance="Secondary" Text="{Binding ViewModel.KillSwitchState}" />
</StackPanel>
<ui:ToggleSwitch Grid.Column="1" Margin="12,0" IsChecked="{Binding ViewModel.KillSwitch, Mode=TwoWay}" />
<ui:ToggleSwitch Grid.Column="1" Margin="12,0" AutomationProperties.Name="{x:Static res:Strings.Settings_KillSwitch_Label}" IsChecked="{Binding ViewModel.KillSwitch, Mode=TwoWay}" />
</Grid>
</ui:CardExpander.Header>
<ui:TextBlock Appearance="Secondary" Text="{x:Static res:Strings.Settings_KillSwitch_Body}" TextWrapping="Wrap" />
@@ -94,6 +94,7 @@
</StackPanel>
</ui:CardControl.Header>
<ui:NumberBox MinWidth="140"
AutomationProperties.Name="{x:Static res:Strings.Settings_MinSession_Label}"
Maximum="{x:Static vm:SettingsViewModel.MinSessionMaximum}"
Minimum="{x:Static vm:SettingsViewModel.MinSessionMinimum}"
SpinButtonPlacementMode="Inline"
@@ -107,6 +108,7 @@
</StackPanel>
</ui:CardControl.Header>
<ui:NumberBox MinWidth="140"
AutomationProperties.Name="{x:Static res:Strings.Settings_Interval_Label}"
Maximum="{x:Static vm:SettingsViewModel.IntervalMaximum}"
Minimum="{x:Static vm:SettingsViewModel.IntervalMinimum}"
SpinButtonPlacementMode="Inline"
@@ -120,6 +122,7 @@
</StackPanel>
</ui:CardControl.Header>
<ui:NumberBox MinWidth="140"
AutomationProperties.Name="{x:Static res:Strings.Settings_Retention_Label}"
Maximum="{x:Static vm:SettingsViewModel.RetentionMaximum}"
Minimum="0"
SpinButtonPlacementMode="Inline"
@@ -132,7 +135,7 @@
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Appearance="Secondary" Text="{x:Static res:Strings.Settings_Background_Body}" TextWrapping="Wrap" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ViewModel.BackgroundCapture, Mode=TwoWay}" />
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_Background_Label}" IsChecked="{Binding ViewModel.BackgroundCapture, Mode=TwoWay}" />
</ui:CardControl>
<!-- Agent: elevation is optional and no tier needs it; the logon task arrives with the tray build. -->
@@ -175,6 +178,7 @@
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static vm:SettingsViewModel.AppearanceHeader}" />
<ui:CardControl Margin="0,4,0,0" Header="{x:Static vm:SettingsViewModel.ThemeLabel}" Icon="{ui:SymbolIcon Color24}">
<ComboBox MinWidth="180"
AutomationProperties.Name="{x:Static vm:SettingsViewModel.ThemeLabel}"
DisplayMemberPath="Label"
ItemsSource="{x:Static vm:SettingsViewModel.Themes}"
SelectedValue="{Binding ViewModel.SelectedTheme, Mode=TwoWay}"
@@ -182,6 +186,7 @@
</ui:CardControl>
<ui:CardControl Margin="0,8,0,0" Header="{x:Static vm:SettingsViewModel.LanguageLabel}" Icon="{ui:SymbolIcon LocalLanguage24}">
<ComboBox MinWidth="180"
AutomationProperties.Name="{x:Static vm:SettingsViewModel.LanguageLabel}"
DisplayMemberPath="Label"
ItemsSource="{x:Static vm:SettingsViewModel.Languages}"
SelectedValue="{Binding ViewModel.SelectedLanguage, Mode=TwoWay}"
@@ -197,7 +202,7 @@
<ui:TextBlock Appearance="Secondary" Text="{x:Static res:Strings.Settings_StartWithWindows_Body}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ViewModel.StartWithWindows, Mode=TwoWay}" />
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_StartWithWindows_Label}" IsChecked="{Binding ViewModel.StartWithWindows, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Margin="0,8,0,0" Icon="{ui:SymbolIcon ArrowMinimize24}">
<ui:CardControl.Header>
@@ -206,7 +211,7 @@
<ui:TextBlock Appearance="Secondary" Text="{x:Static res:Strings.Settings_MinimizeToTray_Body}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ViewModel.MinimizeToTray, Mode=TwoWay}" />
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_MinimizeToTray_Label}" IsChecked="{Binding ViewModel.MinimizeToTray, Mode=TwoWay}" />
</ui:CardControl>
<!-- Privacy, updates, logging, legal. -->
@@ -218,7 +223,7 @@
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Appearance="Secondary" Text="{x:Static res:Strings.Settings_OnlineMetadata_Body}" TextWrapping="Wrap" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ViewModel.OnlineMetadata, Mode=TwoWay}" />
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_OnlineMetadata_Label}" IsChecked="{Binding ViewModel.OnlineMetadata, Mode=TwoWay}" />
</ui:CardControl>
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Updates_Header}" />
@@ -230,6 +235,7 @@
</StackPanel>
</ui:CardControl.Header>
<ComboBox MinWidth="140"
AutomationProperties.Name="{x:Static res:Strings.Settings_UpdateChannel_Label}"
DisplayMemberPath="Label"
ItemsSource="{x:Static vm:SettingsViewModel.UpdateChannels}"
SelectedValue="{Binding ViewModel.UpdateChannel, Mode=TwoWay}"
@@ -243,7 +249,7 @@
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Appearance="Secondary" Text="{x:Static res:Strings.Settings_AutoCheck_Body}" TextWrapping="Wrap" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ViewModel.AutoCheckUpdates, Mode=TwoWay}" />
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_AutoCheck_Label}" IsChecked="{Binding ViewModel.AutoCheckUpdates, Mode=TwoWay}" />
</ui:CardControl>
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Logging_Header}" />
@@ -254,7 +260,7 @@
<ui:TextBlock Appearance="Secondary" Text="{x:Static res:Strings.Settings_LogDebug_Body}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ViewModel.LogDebug, Mode=TwoWay}" />
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_LogDebug_Label}" IsChecked="{Binding ViewModel.LogDebug, Mode=TwoWay}" />
</ui:CardControl>
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Legal_Header}" />
@@ -0,0 +1,102 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Wpf.Ui.Controls;
namespace FrameLedger.App.Services;
/// <summary>
/// <c>08_UI</c> §Accessibility: Esc closes the open dialog with no result — the same as its Close or Cancel button.
/// WPF UI 4.3.0 handles no key in <c>ContentDialog</c> or <c>MessageBox</c> (both sources at the 4.3.0 tag, read
/// 2026-09-15), so one class handler on <see cref="Window"/> does it for every window this app opens: a
/// <c>MessageBox</c> closes itself; any other window hides the <c>ContentDialog</c> its <see cref="ContentDialogHost"/>
/// is showing.
/// </summary>
/// <remarks>
/// The BUBBLING key event, not the preview: a control that uses Esc itself — a dropdown closing its list, a text box
/// with an IME composition — handles it first, and only an Esc nobody wanted reaches the window. Esc is never an
/// acceptance: the consent dialog and the Legal Gate already treat a close without a result as the refusal.
/// </remarks>
public static class DialogKeyboard
{
private static int _registered;
/// <summary>Once per process, before the first window (<c>App.OnStartup</c>).</summary>
public static void Register()
{
if (Interlocked.Exchange(ref _registered, 1) == 1)
{
return;
}
EventManager.RegisterClassHandler(typeof(Window), UIElement.KeyDownEvent, new KeyEventHandler(OnKeyDown));
}
/// <summary>
/// Hides the dialog <paramref name="host"/> shows, with no result; false when it shows none, or when the dialog offers
/// no Close button — a dialog built to be answered is not dismissed by a key it never offered.
/// </summary>
public static bool CloseOpenDialog(ContentDialogHost? host)
{
if (host?.Content is not ContentDialog dialog || string.IsNullOrEmpty(dialog.CloseButtonText))
{
return false;
}
dialog.Hide(ContentDialogResult.None);
return true;
}
/// <summary>The message box's own Close button, pressed: the path its template takes, so the result is the one a click gives.</summary>
public static bool CloseMessageBox(Wpf.Ui.Controls.MessageBox box)
{
ArgumentNullException.ThrowIfNull(box);
if (string.IsNullOrEmpty(box.CloseButtonText) || !box.IsCloseButtonEnabled)
{
return false;
}
box.TemplateButtonCommand.Execute(Wpf.Ui.Controls.MessageBoxButton.Close);
return true;
}
private static void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key != Key.Escape || e.Handled)
{
return;
}
if (sender is Wpf.Ui.Controls.MessageBox box)
{
e.Handled = CloseMessageBox(box);
return;
}
if (sender is Window window && CloseOpenDialog(ContentDialogHost.GetForWindow(window) ?? FindHost(window)))
{
e.Handled = true;
}
}
/// <summary>The host by walking the visual tree, for a window whose host has not registered itself yet.</summary>
private static ContentDialogHost? FindHost(DependencyObject root)
{
int count = VisualTreeHelper.GetChildrenCount(root);
for (int i = 0; i < count; i++)
{
DependencyObject child = VisualTreeHelper.GetChild(root, i);
if (child is ContentDialogHost host)
{
return host;
}
if (FindHost(child) is { } found)
{
return found;
}
}
return null;
}
}
@@ -0,0 +1,38 @@
using FrameLedger.App.Pages;
namespace FrameLedger.App.Services;
/// <summary>
/// <c>08_UI</c> §Accessibility, keyboard: Ctrl+1 … Ctrl+5 (and the numeric keypad) open the NavigationView's pages in
/// the order the shell lists them — Dashboard, Games, Compare, Logs, Settings. The key bindings live in
/// <c>MainWindow.xaml</c>; this is the one place that knows which number is which page, and a test holds the two
/// orders together.
/// </summary>
public static class ShellShortcuts
{
/// <summary>Navigates for <paramref name="key"/> ("1" … "5"); false for anything else, which does nothing.</summary>
public static bool Navigate(IPageNavigator navigator, string? key)
{
ArgumentNullException.ThrowIfNull(navigator);
switch (key)
{
case "1":
navigator.Navigate<DashboardPage>();
return true;
case "2":
navigator.Navigate<GamesPage>();
return true;
case "3":
navigator.Navigate<ComparePage>();
return true;
case "4":
navigator.Navigate<LogsPage>();
return true;
case "5":
navigator.Navigate<SettingsPage>();
return true;
default:
return false;
}
}
}
+12
View File
@@ -26,6 +26,10 @@ public static class Strings
/// <summary>Every key, for an audit that walks them.</summary>
public static IReadOnlyList<string> Keys { get; } =
[
nameof(A11y_Games_Sort),
nameof(A11y_Logs_Level),
nameof(A11y_Logs_Source),
nameof(A11y_Logs_Tail),
nameof(About_Body_Format),
nameof(About_Title),
nameof(AddGame_Added_Format),
@@ -571,6 +575,14 @@ public static class Strings
nameof(Upscaler_Unknown),
];
public static string A11y_Games_Sort => ResourceManager.GetString(nameof(A11y_Games_Sort), Culture) ?? nameof(A11y_Games_Sort);
public static string A11y_Logs_Level => ResourceManager.GetString(nameof(A11y_Logs_Level), Culture) ?? nameof(A11y_Logs_Level);
public static string A11y_Logs_Source => ResourceManager.GetString(nameof(A11y_Logs_Source), Culture) ?? nameof(A11y_Logs_Source);
public static string A11y_Logs_Tail => ResourceManager.GetString(nameof(A11y_Logs_Tail), Culture) ?? nameof(A11y_Logs_Tail);
public static string About_Body_Format => ResourceManager.GetString(nameof(About_Body_Format), Culture) ?? nameof(About_Body_Format);
public static string About_Title => ResourceManager.GetString(nameof(About_Title), Culture) ?? nameof(About_Title);
+15
View File
@@ -2187,6 +2187,21 @@
</data>
<data name="Maintenance_Status_Working" xml:space="preserve">
<value>実行中…</value>
</data>
<data name="A11y_Games_Sort" xml:space="preserve">
<value>ゲームの並べ替え</value>
<comment>review</comment>
</data>
<data name="A11y_Logs_Source" xml:space="preserve">
<value>ログのソース</value>
<comment>review</comment>
</data>
<data name="A11y_Logs_Level" xml:space="preserve">
<value>最小ログレベル</value>
<comment>review</comment>
</data>
<data name="A11y_Logs_Tail" xml:space="preserve">
<value>ログの行</value>
<comment>review</comment>
</data>
</root>
+12
View File
@@ -1647,4 +1647,16 @@
<data name="Maintenance_Status_Working" xml:space="preserve">
<value>Working…</value>
</data>
<data name="A11y_Games_Sort" xml:space="preserve">
<value>Sort games</value>
</data>
<data name="A11y_Logs_Source" xml:space="preserve">
<value>Log source</value>
</data>
<data name="A11y_Logs_Level" xml:space="preserve">
<value>Minimum log level</value>
</data>
<data name="A11y_Logs_Tail" xml:space="preserve">
<value>Log lines</value>
</data>
</root>
+12
View File
@@ -1642,4 +1642,16 @@
<data name="Maintenance_Status_Working" xml:space="preserve">
<value>Đang thực hiện…</value>
</data>
<data name="A11y_Games_Sort" xml:space="preserve">
<value>Sắp xếp game</value>
</data>
<data name="A11y_Logs_Source" xml:space="preserve">
<value>Nguồn log</value>
</data>
<data name="A11y_Logs_Level" xml:space="preserve">
<value>Mức log tối thiểu</value>
</data>
<data name="A11y_Logs_Tail" xml:space="preserve">
<value>Các dòng log</value>
</data>
</root>
+3 -1
View File
@@ -2,7 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:controls="clr-namespace:FrameLedger.App.Controls"
xmlns:converters="clr-namespace:FrameLedger.App.Converters">
xmlns:converters="clr-namespace:FrameLedger.App.Converters"
xmlns:res="clr-namespace:FrameLedger.App">
<!--
Our styles, merged LAST (16_WPFUI_SYNTAX §App bootstrap). Colours only through theme brushes with
DynamicResource; the chart palette (16 §Theming) arrives with the charts (P3 PR-6) as its own dictionary.
@@ -102,6 +103,7 @@
HorizontalAlignment="Right" />
<Border Grid.Column="3" Margin="12,-2,0,0" VerticalAlignment="Top">
<ui:Button x:Name="CloseButton" Padding="4" Background="Transparent" BorderThickness="0" IsEnabled="True"
AutomationProperties.Name="{x:Static res:Strings.Common_Close}"
Command="{Binding Path=TemplateButtonCommand, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}">
<ui:Button.Icon>
<ui:SymbolIcon Symbol="Dismiss24" />
@@ -143,6 +143,10 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
[RelayCommand]
private void Exit() => _shell.Quit();
/// <summary>08_UI §Accessibility: Ctrl+1…5 (and the keypad) — the NavigationView's pages in its order.</summary>
[RelayCommand]
private void NavigateTo(string? key) => _ = ShellShortcuts.Navigate(_navigator, key);
/// <summary>Tools ▸ Agent status… is the Dashboard's Agent card.</summary>
[RelayCommand]
private void AgentStatus() => _navigator.Navigate<DashboardPage>();
@@ -101,8 +101,9 @@
<!-- annotations -->
<ui:TextBlock Margin="0,16,0,0" FontTypography="Subtitle" Text="{x:Static vm:SessionSummaryViewModel.AnnotationsHeader}" />
<ui:TextBox Margin="0,6,0,0" PlaceholderText="{x:Static vm:SessionSummaryViewModel.TagsPlaceholder}" Text="{Binding ViewModel.Tags, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBox Margin="0,6,0,0" AutomationProperties.Name="{x:Static vm:SessionSummaryViewModel.TagsPlaceholder}" PlaceholderText="{x:Static vm:SessionSummaryViewModel.TagsPlaceholder}" Text="{Binding ViewModel.Tags, UpdateSourceTrigger=PropertyChanged}" />
<ui:TextBox Margin="0,6,0,0" MinHeight="72" AcceptsReturn="True" TextWrapping="Wrap"
AutomationProperties.Name="{x:Static vm:SessionSummaryViewModel.NotesPlaceholder}"
PlaceholderText="{x:Static vm:SessionSummaryViewModel.NotesPlaceholder}" Text="{Binding ViewModel.Notes, UpdateSourceTrigger=PropertyChanged}" />
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<ui:Button Appearance="Primary" Command="{Binding ViewModel.SaveAnnotationCommand}" Content="{x:Static vm:SessionSummaryViewModel.SaveText}" Icon="{ui:SymbolIcon Save24}" />
@@ -0,0 +1,219 @@
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
using System.Xml.Linq;
using FluentAssertions;
using FrameLedger.App.Pages;
using FrameLedger.App.Services;
using Wpf.Ui.Controls;
namespace FrameLedger.App.Tests;
/// <summary>
/// NFR-9 as <c>08_UI</c> §Accessibility states it (P4 PR-8), each clause held by a check that goes red on a regression:
/// every input that shows no text of its own carries an automation name, no XAML hard-codes a colour (contrast is the
/// Fluent themes'), the manifest is Per-Monitor V2, Ctrl+1…5 follow the NavigationView's order, and Esc closes the open
/// dialog with no result.
/// </summary>
public sealed class AccessibilityTests
{
private static readonly XNamespace _x = "http://schemas.microsoft.com/winfx/2006/xaml";
/// <summary>The input controls a screen reader announces by name; a textless one without a name is announced as its type alone.</summary>
private static readonly HashSet<string> _namedControls = new(StringComparer.Ordinal)
{
"Button", "ToggleButton", "ToggleSwitch", "CheckBox", "RadioButton", "ComboBox", "TextBox", "NumberBox", "PasswordBox", "Slider", "HyperlinkButton",
};
private static readonly HashSet<string> _colourProperties = new(StringComparer.Ordinal)
{
"Foreground", "Background", "BorderBrush", "Fill", "Stroke", "Color", "CaretBrush", "SelectionBrush",
};
private static string RepoRoot()
{
for (DirectoryInfo? dir = new(AppContext.BaseDirectory); dir is not null; dir = dir.Parent)
{
if (File.Exists(Path.Combine(dir.FullName, "FrameLedger.slnx")))
{
return dir.FullName;
}
}
throw new InvalidOperationException("the repository root (FrameLedger.slnx) is not above " + AppContext.BaseDirectory);
}
private static IEnumerable<(string File, XDocument Xaml)> AppXaml()
{
string app = Path.Combine(RepoRoot(), "src", "FrameLedger.App");
foreach (string file in Directory.EnumerateFiles(app, "*.xaml", SearchOption.AllDirectories)
.Where(static f => !f.Contains(Path.DirectorySeparatorChar + "obj" + Path.DirectorySeparatorChar, StringComparison.Ordinal)
&& !f.Contains(Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar, StringComparison.Ordinal)))
{
yield return (Path.GetRelativePath(app, file), XDocument.Load(file));
}
}
private static bool HasVisibleText(XElement element)
{
if (element.Attribute("Content") is not null || element.Attribute("Header") is not null)
{
return true;
}
// Content as a child element — anything that is not a property element such as <ui:Button.Icon>.
return element.Elements().Any(child => !child.Name.LocalName.Contains('.', StringComparison.Ordinal));
}
private static bool HasAutomationName(XElement element) =>
element.Attributes().Any(static a => a.Name.LocalName is "AutomationProperties.Name" or "AutomationProperties.LabeledBy");
[Fact]
public void EveryInputThatShowsNoTextHasAnAutomationName()
{
var unnamed = new List<string>();
foreach ((string file, XDocument xaml) in AppXaml())
{
foreach (XElement element in xaml.Descendants().Where(e => _namedControls.Contains(e.Name.LocalName)))
{
if (!HasVisibleText(element) && !HasAutomationName(element))
{
string where = element.Attribute(_x + "Name")?.Value ?? string.Join(" ", element.Attributes().Where(static a => a.Name.LocalName is "Command" or "IsChecked" or "Text" or "SelectedValue" or "Value").Select(static a => a.Value));
unnamed.Add($"{file}: <{element.Name.LocalName}> {where}");
}
}
}
unnamed.Should().BeEmpty("08_UI §Accessibility: a control with no text of its own is announced by AutomationProperties.Name, from .resx");
}
[Fact]
public void NoXamlHardCodesAColour()
{
HashSet<string> named = new(typeof(System.Windows.Media.Colors).GetProperties().Select(static p => p.Name), StringComparer.OrdinalIgnoreCase);
named.Remove("Transparent");
var hex = new Regex("^#[0-9A-Fa-f]{3,8}$", RegexOptions.CultureInvariant, TimeSpan.FromSeconds(1));
var found = new List<string>();
foreach ((string file, XDocument xaml) in AppXaml())
{
foreach (XAttribute attribute in xaml.Descendants().Attributes().Where(a => _colourProperties.Contains(a.Name.LocalName)))
{
if (hex.IsMatch(attribute.Value) || named.Contains(attribute.Value))
{
found.Add($"{file}: {attribute.Parent!.Name.LocalName}.{attribute.Name.LocalName}=\"{attribute.Value}\"");
}
}
}
found.Should().BeEmpty("08_UI §Accessibility, contrast: colours come from the WPF UI theme dictionaries, whose Fluent themes meet contrast in both modes");
}
[Fact]
public void TheManifestIsPerMonitorV2()
{
string manifest = File.ReadAllText(Path.Combine(RepoRoot(), "src", "FrameLedger.App", "app.manifest"));
manifest.Should().Contain("PerMonitorV2", "NFR-9: Per-Monitor V2 DPI awareness");
}
private sealed class RecordingNavigator : IPageNavigator
{
public List<string> Pages { get; } = [];
public void Navigate<TPage>()
where TPage : class => Pages.Add(typeof(TPage).Name);
public void GoBack()
{
}
}
[Fact]
public void CtrlOneToFiveOpenTheNavigationViewsPagesInItsOrder()
{
XDocument shell = XDocument.Load(Path.Combine(RepoRoot(), "src", "FrameLedger.App", "MainWindow.xaml"));
string[] navigationOrder = [.. shell.Descendants().Where(static e => string.Equals(e.Name.LocalName, "NavigationViewItem", StringComparison.Ordinal))
.Select(static e => e.Attribute("TargetPageType")?.Value ?? string.Empty)
.Select(static v => Regex.Match(v, @"pages:(?<page>\w+)\}", RegexOptions.ExplicitCapture, TimeSpan.FromSeconds(1)).Groups["page"].Value)];
var bindings = shell.Descendants().Where(static e => string.Equals(e.Name.LocalName, "KeyBinding", StringComparison.Ordinal))
.Select(static e => (Key: e.Attribute("Key")?.Value, Modifiers: e.Attribute("Modifiers")?.Value, Parameter: e.Attribute("CommandParameter")?.Value, Command: e.Attribute("Command")?.Value))
.ToList();
var navigator = new RecordingNavigator();
for (int i = 1; i <= 5; i++)
{
string parameter = i.ToString(System.Globalization.CultureInfo.InvariantCulture);
bindings.Should().Contain((Key: "D" + parameter, Modifiers: "Control", Parameter: parameter, Command: "{Binding ViewModel.NavigateToCommand}"));
bindings.Should().Contain((Key: "NumPad" + parameter, Modifiers: "Control", Parameter: parameter, Command: "{Binding ViewModel.NavigateToCommand}"));
ShellShortcuts.Navigate(navigator, parameter).Should().BeTrue();
}
navigator.Pages.Should().Equal(navigationOrder);
navigationOrder.Should().Equal(nameof(DashboardPage), nameof(GamesPage), nameof(ComparePage), nameof(LogsPage), nameof(SettingsPage));
ShellShortcuts.Navigate(navigator, "6").Should().BeFalse();
ShellShortcuts.Navigate(navigator, null).Should().BeFalse();
}
/// <summary>
/// An STA thread with a running dispatcher: <c>ContentDialog.ShowAsync</c> clears its host in a <c>finally</c> that
/// resumes on the captured context, so the thread that showed the dialog must still be pumping when it closes.
/// </summary>
private static Task<T> OnDispatcherAsync<T>(Func<Task<T>> work)
{
var tcs = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
var thread = new Thread(() =>
{
System.Windows.Threading.Dispatcher dispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;
SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext(dispatcher));
#pragma warning disable VSTHRD001 // a test's own dispatcher thread: no JoinableTaskFactory exists here, and this posts the work rather than blocking on it
_ = dispatcher.InvokeAsync(async () =>
{
try
{
tcs.SetResult(await work().ConfigureAwait(true));
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
tcs.SetException(ex);
}
finally
{
dispatcher.InvokeShutdown();
}
});
#pragma warning restore VSTHRD001
System.Windows.Threading.Dispatcher.Run();
});
thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true;
thread.Start();
return tcs.Task;
}
[Fact]
public async Task EscapeClosesTheOpenDialogWithNoResult()
{
(ContentDialogResult Result, bool EmptyHost) outcome = await OnDispatcherAsync(async () =>
{
var host = new ContentDialogHost();
bool closedNothing = !DialogKeyboard.CloseOpenDialog(host);
var dialog = new ContentDialog(host) { Title = "t", PrimaryButtonText = "accept", CloseButtonText = "close" };
Task<ContentDialogResult> shown = dialog.ShowAsync();
DialogKeyboard.CloseOpenDialog(host).Should().BeTrue();
ContentDialogResult result = await shown.ConfigureAwait(true);
// WPF UI's CloseButtonText defaults to "Close"; a dialog without one says so with an empty text.
var answerOnly = new ContentDialog(host) { Title = "t", PrimaryButtonText = "accept", CloseButtonText = string.Empty };
Task<ContentDialogResult> mustAnswer = answerOnly.ShowAsync();
DialogKeyboard.CloseOpenDialog(host).Should().BeFalse("a dialog with no Close button is not dismissed by Esc");
answerOnly.Hide(ContentDialogResult.Primary);
(await mustAnswer.ConfigureAwait(true)).Should().Be(ContentDialogResult.Primary);
return (result, closedNothing);
});
outcome.Result.Should().Be(ContentDialogResult.None, "Esc is the Close button, never the primary one — the consent dialog and the Legal Gate read None as a refusal");
outcome.EmptyHost.Should().BeTrue("with no dialog open, Esc is left to whoever else wants it");
}
}