Compare commits

...
1 Commits
Author SHA1 Message Date
poli0981andClaude Opus 5.5 1ecd9d24cf fix(app): the import list readable in the dark theme with whole tick boxes, and the mouse wheel scrolls every page, dialog and chart (beta.14 PR-1)
Owner report 2026-10-05 (screenshot of File > Import library in the dark theme; "the wheel does not
scroll, I have to drag the scroll bar").

Import list: the row style added in beta.11 was based on {x:Type DataGridRow}, which WPF UI 4.3.0 does
not define - it keys its row style DefaultDataGridRowStyle - so the lookup fell through to Aero2's row and
SystemColors.WindowBrush (white in every theme) under the dark theme's white text. Based on
DefaultDataGridRowStyle now. WPF UI's CheckBox (MinWidth 120, padding 11) drew a sliver of the box in the
40 px column: MinWidth 0, no padding. The dialog's own scrolling is off (ImportReviewPrompt.Create), so the
list takes the height the window leaves and is the one thing that scrolls; the intro and the count stay.
Compare's DataGridCheckBoxColumn (an Aero2 box) is a template column with the theme's CheckBox.

Wheel: NavigationViewContentPresenter makes ScrollViewer.CanContentScroll default to true for Page and wraps
such a page in a DynamicScrollViewer; the five pages' own root ScrollViewer then had infinite height,
nothing to scroll, and took every wheel. Every Page sets CanContentScroll="False"; page roots and the
session summary show their bar on Auto. The Logs tail is bounded again, so autoscroll follows the end.
Scrollers nested in dialogs are ui:PassiveScrollViewer. Charts/ChartWheel (through ChartTheme.Attach, all
nine plots): a plain wheel is re-raised on the plot's parent so ScottPlot never zooms; Ctrl+wheel zooms
and stops there.

Tests (each run red against the unfixed XAML first): ImportReviewRenderTests (every text cell >= 4.5:1
against the composited colour painted under it, Dark and Light; ticked boxes drawn whole, counted in a
RenderTargetBitmap; a 60-row list scrolls inside the list with the footer in view), AccessibilityTests
(no BasedOn a type the App's dictionaries hold no style for; no DataGridCheckBoxColumn; every Page opts out
of the DynamicScrollViewer; no plain ScrollViewer in a dialog), PagesLoadTests (pages navigated in the real
presenter are not wrapped and the wheel scrolls them; the Logs tail is bounded and follows the end; every
page reads CanContentScroll false after WPF UI's override), ChartWheelTests. Visuals/Wcag test helpers;
ContrastTests uses Wcag.

Docs: 08_UI (UX rules, Contrast's third hole), 16_WPFUI_SYNTAX (two corrections in place, five gotchas),
14_TESTING (what the App draws), guide/03 (Ctrl+wheel), CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 00:38:31 +07:00
29 changed files with 837 additions and 108 deletions

No files matched your search

+20
View File
@@ -28,6 +28,26 @@ numeric core and does not move; the heading is the full version — corrected 20
## [Unreleased]
### Fixed
- **The import list was unreadable in the dark theme.** File ▸ Import library (and Games ▸ Refresh) drew every row white
with white text, and each tick box as a sliver at the row's edge: a row style added in beta.11 to dim the games already
in the library fell through to Windows' own row, which is white in every theme, and WPF UI's check box is too wide for
its 40 px column. The rows take the theme's colours again and the boxes are whole, and the list is the one thing in the
dialog that scrolls — its intro and the count under it stay in view, where a list scrolling inside a scrolling dialog
used to carry the intro away. Compare's session picker draws the theme's check boxes too (it drew Windows' old ones).
- **The mouse wheel scrolled nothing on the Dashboard, Games, a game's page, Compare and Settings** — only dragging the
scroll bar did. WPF UI wraps a page in a scroller of its own unless the page says otherwise, and inside it each page's
own scroller had nothing to scroll and still took every wheel. Every page scrolls itself now. The Logs page had the same
cause: its tail grew to hold every line and never followed the newest one, as it was meant to. A scroller inside a
dialog (the consent, administrator, anti-cheat exception and bug report dialogs) hands the wheel on at its ends.
### Changed
- **Over a chart, the wheel scrolls the page; Ctrl+wheel zooms the chart.** ScottPlot zoomed on every wheel, which with
the pages scrolling again would have zoomed the chart and scrolled the page at once. Dragging still pans and
double-click still resets.
## [0.1.0-beta.13] - 2026-10-04
**The thirteenth pre-release: refusal notices that say where the anti-cheat is, GPU sensors that follow the game's graphics
+18
View File
@@ -676,6 +676,12 @@ Agent section: elevation state with a plain explanation of what elevation *optio
- 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).
- **The mouse wheel scrolls whatever is under the pointer (beta.14).** Every page scrolls itself
(`ScrollViewer.CanContentScroll="False"` on the `Page` — `16_WPFUI_SYNTAX` §Gotchas: until beta.14 the wheel scrolled
nothing on five pages, and the Logs tail did not follow the newest line); a scroller nested in a dialog hands the wheel
on at its ends (`ui:PassiveScrollViewer`); over a chart a plain wheel scrolls the page and **Ctrl+wheel zooms the chart**
(`Charts/ChartWheel`, every plot through `ChartTheme.Attach`) — drag still pans and double-click still resets, as
ScottPlot does. The import checklist scrolls inside its list and nowhere else, so its intro and its count stay put.
## Accessibility
@@ -743,6 +749,18 @@ palette per theme, chosen with the theme).
> primary text, ≈ 12:1) but **clipping** — the pill sat in a star column with no trimming, so a sentence-length
> qualifier overflowed the row. The qualifier text trims with an ellipsis at 260 px (the readout's tooltip carries the
> full sentence), and the row's readout column is sized to content with the game's name trimming first.
>
> **A third hole, closed 2026-10-05 (beta.14; the owner's screenshot of File ▸ Import library in the dark theme: every
> row white, its text invisible, each tick box a sliver).** A style `BasedOn="{StaticResource {x:Type DataGridRow}}"`,
> added in beta.11 to dim the rows already in the library: WPF UI 4.3.0 keys its row style `DefaultDataGridRowStyle`
> and defines no implicit one, so the lookup fell through to Aero2's row and its `SystemColors.WindowBrush` — a white no
> theme reaches, under the dark theme's white text. No `#` in our XAML, no palette badge: neither check above could see
> it, and light-theme rows read fine. The tick boxes were WPF UI's `CheckBox` (`MinWidth` 120, padding 11) in a 40 px
> column. Held three ways: `AccessibilityTests.NoStyleIsBasedOnAnImplicitStyleTheThemeDoesNotDefine` (every `BasedOn`
> type has a style in the App's dictionaries), `ImportReviewRenderTests` (the rendered dialog, both themes: every cell's
> text against the composited colour painted under it ≥ 4.5:1, each ticked box drawn whole), and
> `AccessibilityTests.NoDataGridCheckBoxColumn` (Compare's checkbox column drew an Aero2 box). Each went red on the
> unfixed XAML before it went green.
### DPI
+12
View File
@@ -44,6 +44,18 @@ The anti-cheat guard is the one component where a bug can cost someone an accoun
- Blob codecs round-trip for every series in `frame_blobs` (NaN forbidden — assert), including the two-pair `render_res` encoding and the three-bit `rt_flags` byte. SQLite migrations apply cleanly from an empty file to the current schema, and re-applying is a no-op. (There is no v1→v2 upgrade to test — `06_DATA_MODEL` §Migrations.)
- IPC pipe: framing, split reads, oversize rejection, unknown fields/types ignored, protocol mismatch.
### What the App draws (beta.14)
A page or dialog that only *loads* has proved nothing about how it looks: `PagesLoadTests` counted the import list's
rows while every row was white text on white in the dark theme (`08_UI` §Contrast). The rendered checks run on the one
STA thread with the App's three dictionaries (`PagesLoadTests.OnStaAsync`) and look at the result: `Visuals` lays a
control out at a window's size, pumps the dispatcher (a `NavigationViewContentPresenter`'s navigation), swaps the theme
dictionary for one check and puts Dark back, and composites every Border and Panel background between a text and the
window into the colour actually painted under it; `Wcag` is the arithmetic. `ImportReviewRenderTests` measures each text
cell against that colour in both themes and counts the accent pixels of each ticked box in a `RenderTargetBitmap`; the
paging checks navigate a real page in WPF UI's presenter and send it the wheel. Each was run red against the unfixed XAML
first — a rendered check that cannot fail is the counted-rows check again.
## Integration tests (CI-runnable, no game, no anti-cheat surface)
`hook-harness` is what makes this architecture testable without touching a real title:
+26 -2
View File
@@ -132,9 +132,9 @@ Code-behind wires services once: `navigationService.SetNavigationControl(RootNav
| Busy | `ui:ProgressRing` | |
| Contextual popup | `ui:Flyout` | Popup hand-rolling |
| Hyperlink-ish | `ui:HyperlinkButton`, `ui:Anchor` | |
| Grid of records | native `DataGrid` (WPF UI restyles it) | third-party grids |
| Grid of records | native `DataGrid` (WPF UI restyles it — through the grid's own `RowStyle`/`CellStyle`/`ColumnHeaderStyle` setters, so a local one is based on WPF UI's keyed style: §Gotchas, added 2026-10-05) | third-party grids |
Native `Menu`, `TabControl`, `ComboBox`, `Slider`, `ListView` are fine — the `ControlsDictionary` restyles standard WPF controls to Fluent automatically.
Native `Menu`, `TabControl`, `ComboBox`, `Slider`~~, `ListView`~~ are fine — the `ControlsDictionary` restyles standard WPF controls to Fluent automatically. *(Corrected 2026-10-05: 4.3.0 has no implicit style for the native `ListView`, `ListViewItem` or `GridViewColumnHeader` — only `ui:ListView` is restyled — nor for `DataGridRow`, `DataGridCell`, `DataGridColumnHeader` or `FlowDocumentScrollViewer`; read from the loaded `ControlsDictionary`.)*
## Icons
@@ -227,6 +227,30 @@ 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.
- [ ] **WPF UI 4.3.0 keys its DataGrid parts' styles and defines no implicit one** (`DefaultDataGridRowStyle`,
`DefaultDataGridCellStyle`, `DefaultDataGridColumnHeaderStyle`, handed to the grid by its implicit `DataGrid` style's
`RowStyle`/`CellStyle`/`ColumnHeaderStyle` setters). A local `RowStyle` replaces WPF UI's; based on
`{StaticResource {x:Type DataGridRow}}` it falls through to Aero2's row, whose `SystemColors.WindowBrush` no theme
reaches: the import list was white text on white in the dark theme (owner's screenshot, beta.14). Base it on
`DefaultDataGridRowStyle`. `AccessibilityTests.NoStyleIsBasedOnAnImplicitStyleTheThemeDoesNotDefine` refuses any
`BasedOn` a type the App's dictionaries hold no style for, and `ImportReviewRenderTests` measures the rendered rows.
- [ ] **WPF UI's `CheckBox` is `MinWidth` 120 with an 11 px padding**: in a narrow grid column it draws a sliver of the box.
`MinWidth="0" Padding="0"` there. A `DataGridCheckBoxColumn` uses WPF's own element style, an Aero2 box — use a template
column (`AccessibilityTests.NoDataGridCheckBoxColumn`).
- [ ] **Every page sets `ScrollViewer.CanContentScroll="False"`.** `NavigationViewContentPresenter` changes that property's
default to true for `Page` and, on each navigation, wraps a page that keeps it in a `DynamicScrollViewer`. A page with
its own root `ScrollViewer` inside that wrapper has infinite height, nothing to scroll — and a stock `ScrollViewer`
marks every wheel handled even then, so the wheel scrolled nothing on five pages until beta.14 (owner: "I have to drag
the scroll bar"); the Logs tail grew to hold every line and never followed the end.
`AccessibilityTests.EveryPageOptsOutOfTheDynamicScrollViewer`, `PagesLoadTests.ANavigatedPageIsNot…`.
- [ ] **A stock `ScrollViewer` nested in a scroller takes the wheel at its ends too.** Inside a dialog use
`ui:PassiveScrollViewer`, which hands the wheel on when it cannot scroll (`AccessibilityTests.NoPlainScrollViewerInsideADialog`).
A `ContentDialog` whose content should not scroll as a whole sets `ScrollViewer.VerticalScrollBarVisibility="Disabled"`
on the dialog: its content row then has the window's height, and a `*` row inside it can hold a list that scrolls alone
(`ImportReviewPrompt`).
- [ ] **ScottPlot 5 zooms on every wheel and never marks it handled.** Without `Charts/ChartWheel` a wheel over a chart
zoomed it and scrolled the page at once; a plain wheel is the page's, Ctrl+wheel the chart's, for every plot that
`ChartTheme.Attach` registers.
- [ ] **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
+3
View File
@@ -44,6 +44,9 @@ correct it by hand — your correction is labelled as yours.
Changes to your hardware or driver are marked on it.
- **Compare** (in the navigation on the left) — pick sessions, even of different games, and see them side by side.
To look closer, hold **Ctrl** and turn the mouse wheel over a chart to zoom, drag to pan, and double-click to reset. The
wheel alone scrolls the page.
## Export
The summary's **Export CSV**, **Export JSON** and **Export PNG** buttons — or File ▸ Export — save a session to a file.
+5 -1
View File
@@ -70,10 +70,14 @@ public static class ChartTheme
(byte)Math.Round((top.B * a) + (under.B * (1 - a))));
}
/// <summary>Registers a control so a theme change re-applies and refreshes it (weakly held; a closed window is forgotten).</summary>
/// <summary>
/// Registers a control so a theme change re-applies and refreshes it (weakly held; a closed window is forgotten), and
/// gives it the App's wheel: a plain wheel scrolls the page, Ctrl+wheel zooms (<see cref="ChartWheel"/>, beta.14).
/// </summary>
public static void Attach(WpfPlot control)
{
ArgumentNullException.ThrowIfNull(control);
ChartWheel.Attach(control);
lock (_lock)
{
_live.RemoveAll(static w => !w.TryGetTarget(out _));
+56
View File
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using ScottPlot.WPF;
namespace FrameLedger.App.Charts;
/// <summary>
/// The mouse wheel over a chart (beta.14). ScottPlot 5's <see cref="WpfPlot"/> zooms on every wheel and never marks it
/// handled, so with the pages scrolling again (<c>16_WPFUI_SYNTAX</c> §Gotchas: they did not until beta.14) a wheel over a
/// chart would have zoomed it AND scrolled the page under the pointer. A plain wheel now belongs to the page — ScottPlot
/// never sees it — and Ctrl+wheel to the chart, which zooms and keeps the page where it is. Every plot reaches this through
/// <see cref="ChartTheme.Attach"/>.
/// </summary>
internal static class ChartWheel
{
/// <summary>Whether a wheel with these modifier keys zooms the chart rather than scrolling the page: Ctrl held.</summary>
public static bool Zooms(ModifierKeys modifiers) => (modifiers & ModifierKeys.Control) == ModifierKeys.Control;
public static void Attach(WpfPlot plot)
{
ArgumentNullException.ThrowIfNull(plot);
plot.PreviewMouseWheel += OnPreviewMouseWheel;
plot.MouseWheel += OnMouseWheel;
}
/// <summary>
/// The tunnelling half, before ScottPlot's own handler on its inner element: a plain wheel is taken from the plot and
/// raised again on the plot's parent, from where it bubbles to the page's scroller as any other wheel would.
/// </summary>
private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Handled || Zooms(Keyboard.Modifiers) || sender is not DependencyObject plot)
{
return;
}
e.Handled = true;
if (VisualTreeHelper.GetParent(plot) is UIElement parent)
{
parent.RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = UIElement.MouseWheelEvent, Source = sender });
}
}
/// <summary>The bubbling half, after ScottPlot has zoomed: Ctrl+wheel stops here, so the page does not scroll as well.</summary>
private static void OnMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Zooms(Keyboard.Modifiers))
{
e.Handled = true;
}
}
}
@@ -7,7 +7,8 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:sp="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF"
MinHeight="260">
<!-- 08_UI §Session summary / FR-5.1: the frametime timeline, min/max decimated (FR-5.3); zoom and pan are ScottPlot's.
<!-- 08_UI §Session summary / FR-5.1: the frametime timeline, min/max decimated (FR-5.3); zoom and pan are ScottPlot's —
zoom with Ctrl+wheel since beta.14, a plain wheel scrolls the page (ChartWheel).
The note above it says what the lines are not, when that is not obvious (beta.8). -->
<Grid>
<Grid.RowDefinitions>
@@ -16,7 +16,7 @@
Safety_AdminMode_* only, versioned by AgentAdminDisclosure.Version. It states what the option adds, what it does not
change, how Windows asks, and the risk; every colour is a theme brush.
-->
<ScrollViewer MaxHeight="520" VerticalScrollBarVisibility="Auto">
<ui:PassiveScrollViewer MaxHeight="520" VerticalScrollBarVisibility="Auto">
<StackPanel>
<ui:TextBlock Text="{x:Static vm:AgentAdminDialogViewModel.Intro}" TextWrapping="Wrap" />
<ui:TextBlock Margin="0,14,0,0" Text="{x:Static vm:AgentAdminDialogViewModel.Adds}" TextWrapping="Wrap" />
@@ -34,5 +34,5 @@
IsChecked="{Binding Accepted, Mode=TwoWay}" />
<ui:TextBlock Margin="0,12,0,0" HorizontalAlignment="Right" Appearance="Tertiary" Text="{x:Static vm:AgentAdminDialogViewModel.Version}" />
</StackPanel>
</ScrollViewer>
</ui:PassiveScrollViewer>
</UserControl>
@@ -16,7 +16,7 @@
versioned by AntiCheatExceptionDisclosure.Version. It states why the exception is offered, the risk, what is still
refused, how it ends, and that it turns nothing on; it recommends neither choice. Every colour is a theme brush.
-->
<ScrollViewer MaxHeight="520" VerticalScrollBarVisibility="Auto">
<ui:PassiveScrollViewer MaxHeight="520" VerticalScrollBarVisibility="Auto">
<StackPanel>
<ui:TextBlock Text="{Binding Intro}" TextWrapping="Wrap" />
<ui:TextBlock Margin="0,14,0,0" Text="{Binding Why}" TextWrapping="Wrap" />
@@ -37,5 +37,5 @@
Content="{x:Static vm:AntiCheatExceptionDialogViewModel.AcceptText}"
IsChecked="{Binding Accepted, Mode=TwoWay}" />
</StackPanel>
</ScrollViewer>
</ui:PassiveScrollViewer>
</UserControl>
@@ -19,7 +19,7 @@
<ui:TextBlock TextWrapping="Wrap" Text="{Binding Intro}" />
<Border Margin="0,10,0,10" Padding="10,6" CornerRadius="6"
Background="{DynamicResource ControlFillColorDefaultBrush}" BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}" BorderThickness="1">
<ScrollViewer MaxHeight="220" VerticalScrollBarVisibility="Auto">
<ui:PassiveScrollViewer MaxHeight="220" VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Entries}">
<ItemsControl.ItemTemplate>
<DataTemplate>
@@ -27,7 +27,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</ui:PassiveScrollViewer>
</Border>
<ui:HyperlinkButton Padding="0" Content="{x:Static vm:BugReportPreviewViewModel.ShowZipText}" Command="{Binding ShowZipCommand}" />
<ui:TextBlock Margin="0,10,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugReportPreviewViewModel.DragInstruction}" />
@@ -16,7 +16,7 @@
tiers are two paragraphs of the same shape, in the order enable / do-not-enable, with nothing between
them that reads as a recommendation. Every colour is a theme brush (16_WPFUI §Theming).
-->
<ScrollViewer MaxHeight="520" VerticalScrollBarVisibility="Auto">
<ui:PassiveScrollViewer MaxHeight="520" VerticalScrollBarVisibility="Auto">
<StackPanel>
<ui:TextBlock Text="{x:Static vm:ConsentDialogViewModel.Intro}" TextWrapping="Wrap" />
@@ -38,5 +38,5 @@
Text="{Binding Typed, UpdateSourceTrigger=PropertyChanged}"
PlaceholderText="{x:Static vm:ConsentDialogViewModel.Phrase}" />
</StackPanel>
</ScrollViewer>
</ui:PassiveScrollViewer>
</UserControl>
@@ -16,15 +16,30 @@
or has no executable cannot be ticked (its box is disabled since beta.11 - before, a tick was taken and ignored).
Rows already in the library are hidden unless "Show the N games already in the library" is ticked, and then
dimmed. Import never enables hooking (the intro says so).
beta.14 (owner's screenshot, dark theme): every row was white with white text and every tick box a sliver. The row
style was based on {x:Type DataGridRow}, which WPF UI 4.3.0 does not define - it keys its row style
DefaultDataGridRowStyle and hands it to the grid through the DataGrid style's RowStyle - so the lookup fell through
to Aero2's row template and its SystemColors.WindowBrush, which no theme reaches. The sliver is WPF UI's CheckBox
style, MinWidth 120 and padding 11, in a 40 px column: MinWidth 0 and no padding draw the whole box. And the list
no longer scrolls inside a dialog that scrolls too: ImportReviewPrompt turns the dialog's own
scrolling off, so the grid takes the height the window leaves and is the one thing that scrolls - the intro and the
count stay where they are (ImportReviewRenderTests).
-->
<StackPanel>
<ui:TextBlock TextWrapping="Wrap" Text="{x:Static vm:ImportReviewViewModel.Intro}" />
<CheckBox Margin="0,8,0,0" Content="{Binding ShowExistingText}" IsChecked="{Binding ShowExisting, Mode=TwoWay}"
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" MinHeight="120" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ui:TextBlock Grid.Row="0" TextWrapping="Wrap" Text="{x:Static vm:ImportReviewViewModel.Intro}" />
<CheckBox Grid.Row="1" Margin="0,8,0,0" Content="{Binding ShowExistingText}" IsChecked="{Binding ShowExisting, Mode=TwoWay}"
Visibility="{Binding HasExisting, Converter={StaticResource BoolToVis}}" />
<DataGrid Margin="0,10,0,8" MaxHeight="360" AutoGenerateColumns="False" CanUserAddRows="False" HeadersVisibility="Column"
<DataGrid x:Name="Candidates" Grid.Row="2" Margin="0,10,0,8" AutoGenerateColumns="False" CanUserAddRows="False" HeadersVisibility="Column"
ItemsSource="{Binding Shown}" SelectionMode="Single" IsReadOnly="False">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Style TargetType="DataGridRow" BasedOn="{StaticResource DefaultDataGridRowStyle}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsExisting}" Value="True">
<Setter Property="Opacity" Value="0.55" />
@@ -36,7 +51,7 @@
<DataGridTemplateColumn Width="40">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center" IsEnabled="{Binding CanImport}"
<CheckBox MinWidth="0" Padding="0" HorizontalAlignment="Center" IsEnabled="{Binding CanImport}"
AutomationProperties.Name="{Binding Name}"
IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
@@ -48,12 +63,12 @@
<DataGridTextColumn Header="{x:Static vm:ImportReviewViewModel.ColumnNote}" Binding="{Binding Note}" IsReadOnly="True" Width="Auto" />
</DataGrid.Columns>
</DataGrid>
<DockPanel>
<DockPanel Grid.Row="3">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<ui:HyperlinkButton Padding="4,0" Content="{x:Static res:Strings.Import_SelectAll}" Command="{Binding SelectAllCommand}" xmlns:res="clr-namespace:FrameLedger.App" />
<ui:HyperlinkButton Padding="4,0" Content="{x:Static res:Strings.Import_SelectNone}" Command="{Binding SelectNoneCommand}" xmlns:res="clr-namespace:FrameLedger.App" />
</StackPanel>
<ui:TextBlock Appearance="Secondary" VerticalAlignment="Center" Text="{Binding SelectedText}" />
</DockPanel>
</StackPanel>
</Grid>
</UserControl>
+13 -3
View File
@@ -8,9 +8,10 @@
xmlns:res="clr-namespace:FrameLedger.App"
xmlns:vm="clr-namespace:FrameLedger.App.ViewModels"
xmlns:charts="clr-namespace:FrameLedger.App.Charts"
Title="{x:Static res:Strings.Compare_Header}">
Title="{x:Static res:Strings.Compare_Header}"
ScrollViewer.CanContentScroll="False">
<!-- 08_UI §Compare: the picker (2–5, cross-game), the overlaid percentile curves, the stat table; FR-6.2's guard is the view model's. -->
<ScrollViewer>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Style="{StaticResource PageRoot}">
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:CompareViewModel.Header}" />
<ui:TextBlock Margin="0,16,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:CompareViewModel.EmptyText}"
@@ -32,7 +33,16 @@
ItemsSource="{Binding ViewModel.Candidates}" SelectionMode="Single"
Visibility="{Binding ViewModel.IsEmpty, Converter={StaticResource InverseBoolToVis}}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}" Width="40" />
<!-- A template column, not DataGridCheckBoxColumn: that one's element style is WPF's own, an Aero2 box on the Fluent grid; MinWidth 0
and no padding, or WPF UI's CheckBox (MinWidth 120, padding 11) draws a sliver of the box in 40 px (beta.14). -->
<DataGridTemplateColumn Width="40">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate DataType="{x:Type vm:CompareCandidateViewModel}">
<CheckBox MinWidth="0" Padding="0" HorizontalAlignment="Center" AutomationProperties.Name="{Binding Label}"
IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="{x:Static res:Strings.Compare_Col_Game}" Binding="{Binding GameName}" IsReadOnly="True" Width="2*" />
<DataGridTextColumn Header="{x:Static res:Strings.Compare_Col_Date}" Binding="{Binding DateText}" IsReadOnly="True" Width="*" />
<DataGridTextColumn Header="{x:Static res:Strings.Compare_Col_Tier}" Binding="{Binding TierText}" IsReadOnly="True" Width="Auto" />
+3 -2
View File
@@ -8,8 +8,9 @@
xmlns:res="clr-namespace:FrameLedger.App"
xmlns:vm="clr-namespace:FrameLedger.App.ViewModels"
xmlns:controls="clr-namespace:FrameLedger.App.Controls"
Title="{x:Static res:Strings.Dashboard_Header}">
<ScrollViewer>
Title="{x:Static res:Strings.Dashboard_Header}"
ScrollViewer.CanContentScroll="False">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Style="{StaticResource PageRoot}">
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:DashboardViewModel.Header}" />
@@ -9,13 +9,14 @@
xmlns:vm="clr-namespace:FrameLedger.App.ViewModels"
xmlns:controls="clr-namespace:FrameLedger.App.Controls"
xmlns:charts="clr-namespace:FrameLedger.App.Charts"
Title="{x:Static res:Strings.Games_Header}">
Title="{x:Static res:Strings.Games_Header}"
ScrollViewer.CanContentScroll="False">
<!--
08_UI §Games › Game detail. The two rows — Supports (files on disk) and Last session measured (the
hooks) — are two cards and never mixed. The hooking control opens FR-2.1's dialog; a blocked pre-scan
disables it with the reason inline; a refusal is a persistent InfoBar on this page, never a toast.
-->
<ScrollViewer>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Style="{StaticResource PageRoot}">
<ui:HyperlinkButton Padding="0" Command="{Binding ViewModel.BackCommand}" Content="{x:Static vm:GameDetailViewModel.BackText}" Icon="{ui:SymbolIcon ArrowLeft24}" />
+3 -2
View File
@@ -10,14 +10,15 @@
xmlns:controls="clr-namespace:FrameLedger.App.Controls"
Title="{x:Static res:Strings.Games_Header}"
AllowDrop="True"
Drop="OnDrop">
Drop="OnDrop"
ScrollViewer.CanContentScroll="False">
<!--
08_UI §Games: search, sort, FR-1.1 add by pick or by dropping an .exe here. Since beta.11 (owner requests 2026-10-03):
the count in the title; a grid of cards that fills the width (UniformWrapPanel - a WrapPanel of 300 px cards left a
card's width unused at the right) or a list (ui.library_view); Refresh reads the library again, offers the games the
stores installed since, and marks the entries whose executable is gone.
-->
<ScrollViewer>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Style="{StaticResource PageRoot}">
<Grid>
<Grid.ColumnDefinitions>
+2 -1
View File
@@ -7,7 +7,8 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:res="clr-namespace:FrameLedger.App"
xmlns:vm="clr-namespace:FrameLedger.App.ViewModels"
Title="{x:Static res:Strings.Logs_Header}">
Title="{x:Static res:Strings.Logs_Header}"
ScrollViewer.CanContentScroll="False">
<Grid Margin="24,16,24,16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
+3 -2
View File
@@ -7,8 +7,9 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:res="clr-namespace:FrameLedger.App"
xmlns:vm="clr-namespace:FrameLedger.App.ViewModels"
Title="{x:Static res:Strings.Settings_Header}">
<ScrollViewer>
Title="{x:Static res:Strings.Settings_Header}"
ScrollViewer.CanContentScroll="False">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Style="{StaticResource PageRoot}">
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:SettingsViewModel.Header}" />
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows.Controls;
using System.Windows.Data;
using FrameLedger.App.Dialogs;
using FrameLedger.App.ViewModels;
@@ -10,7 +11,11 @@ using Wpf.Ui.Controls;
namespace FrameLedger.App.Services;
/// <summary>FR-1.2's review checklist in WPF UI: a <c>ContentDialog</c> whose primary button follows the tick count; Cancel adds nothing.</summary>
/// <summary>
/// FR-1.2's review checklist in WPF UI: a <c>ContentDialog</c> whose primary button follows the tick count; Cancel adds nothing.
/// The dialog's own scrolling is off (beta.14): its content row then has the height the window leaves, the list fills it and is
/// the one thing that scrolls — a scrolling list inside a scrolling dialog pushed the intro out of sight at the list's end.
/// </summary>
public sealed class ImportReviewPrompt : IImportReview
{
private readonly IContentDialogService _dialogs;
@@ -21,18 +26,24 @@ public sealed class ImportReviewPrompt : IImportReview
{
ArgumentNullException.ThrowIfNull(candidates);
var viewModel = new ImportReviewViewModel(candidates);
var dialog = new ContentDialog
{
Title = ImportReviewViewModel.Title,
Content = new ImportReviewContent(viewModel),
PrimaryButtonText = Strings.Import_Add,
CloseButtonText = Strings.Common_Cancel,
DefaultButton = ContentDialogButton.Primary,
DialogMaxWidth = 900,
};
ContentDialog dialog = Create(viewModel);
_ = dialog.SetBinding(ContentDialog.IsPrimaryButtonEnabledProperty, new Binding(nameof(ImportReviewViewModel.CanImport)) { Source = viewModel, Mode = BindingMode.OneWay });
ContentDialogResult result = await _dialogs.ShowAsync(dialog, ct).ConfigureAwait(true);
return result == ContentDialogResult.Primary ? viewModel.Selected : null;
}
/// <summary>The dialog as shown, without a host: a test lays it out in one of its own.</summary>
internal static ContentDialog Create(ImportReviewViewModel viewModel, ContentDialogHost? host = null)
{
ContentDialog dialog = host is null ? new ContentDialog() : new ContentDialog(host);
dialog.Title = ImportReviewViewModel.Title;
dialog.Content = new ImportReviewContent(viewModel);
dialog.PrimaryButtonText = Strings.Import_Add;
dialog.CloseButtonText = Strings.Common_Cancel;
dialog.DefaultButton = ContentDialogButton.Primary;
dialog.DialogMaxWidth = 900;
ScrollViewer.SetVerticalScrollBarVisibility(dialog, ScrollBarVisibility.Disabled);
return dialog;
}
}
@@ -24,7 +24,7 @@
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ui:TitleBar Grid.Row="0" Title="{Binding ViewModel.Title}" ShowMaximize="True" ShowMinimize="True" />
<ScrollViewer Grid.Row="1">
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel Style="{StaticResource PageRoot}">
<ui:TextBlock Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:SessionSummaryViewModel.NotFoundText}"
Visibility="{Binding ViewModel.NotFound, Converter={StaticResource BoolToVis}}" />
@@ -111,6 +111,92 @@ public sealed class AccessibilityTests
found.Should().BeEmpty("08_UI §Accessibility, contrast: colours come from the WPF UI theme dictionaries, whose Fluent themes meet contrast in both modes");
}
/// <summary>
/// The import list's rows were white on white in the dark theme (beta.14): a row style <c>BasedOn="{StaticResource
/// {x:Type DataGridRow}}"</c>, which WPF UI 4.3.0 does not define — it keys its row style <c>DefaultDataGridRowStyle</c> —
/// so the lookup fell through to Aero2's, whose <c>SystemColors.WindowBrush</c> no theme reaches and no colour scan can see.
/// Every type a style is based on must have a style in the App's own dictionaries.
/// </summary>
[Fact]
public async Task NoStyleIsBasedOnAnImplicitStyleTheThemeDoesNotDefine()
{
var typeKeyed = new Regex(@"^\{StaticResource \{x:Type (?:\w+:)?(?<type>\w+)\}\}$", RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, TimeSpan.FromSeconds(1));
var wanted = new List<(string File, string Type)>();
foreach ((string file, XDocument xaml) in AppXaml())
{
foreach (XAttribute basedOn in xaml.Descendants().Attributes().Where(static a => string.Equals(a.Name.LocalName, "BasedOn", StringComparison.Ordinal)))
{
Match match = typeKeyed.Match(basedOn.Value.Trim());
if (match.Success)
{
wanted.Add((file, match.Groups["type"].Value));
}
}
}
HashSet<string> defined = await PagesLoadTests.OnStaAsync(() => TypeKeyedStyles(System.Windows.Application.Current.Resources));
wanted.Where(w => !defined.Contains(w.Type)).Select(static w => $"{w.File}: BasedOn {{x:Type {w.Type}}}").Should().BeEmpty(
"WPF UI defines no implicit style for that type, so the style would be based on Aero2's — base it on WPF UI's keyed style (DefaultDataGridRowStyle, …)");
}
/// <summary>The names of the types the dictionary (and those merged into it) has an implicit style for.</summary>
private static HashSet<string> TypeKeyedStyles(ResourceDictionary dictionary)
{
var names = new HashSet<string>(StringComparer.Ordinal);
foreach (object key in dictionary.Keys)
{
if (key is Type type)
{
_ = names.Add(type.Name);
}
}
foreach (ResourceDictionary merged in dictionary.MergedDictionaries)
{
names.UnionWith(TypeKeyedStyles(merged));
}
return names;
}
/// <summary>A <c>DataGridCheckBoxColumn</c>'s box is WPF's own element style — an Aero2 box on the Fluent grid (beta.14).</summary>
[Fact]
public void NoDataGridCheckBoxColumn()
{
AppXaml().SelectMany(static x => x.Xaml.Descendants().Where(static e => string.Equals(e.Name.LocalName, "DataGridCheckBoxColumn", StringComparison.Ordinal)).Select(_ => x.File))
.Should().BeEmpty("a template column with a CheckBox (MinWidth=\"0\" Padding=\"0\") draws the theme's box");
}
/// <summary>
/// WPF UI 4.3.0 wraps a page in a <c>DynamicScrollViewer</c> unless the page sets <c>ScrollViewer.CanContentScroll</c> to
/// false; inside it the page's own root scroller has nothing to scroll and takes every wheel (beta.14: "the wheel does not
/// scroll"). Every page opts out and scrolls itself.
/// </summary>
[Fact]
public void EveryPageOptsOutOfTheDynamicScrollViewer()
{
List<string> pages = [.. AppXaml().Where(static x => string.Equals(x.Xaml.Root!.Name.LocalName, "Page", StringComparison.Ordinal)).Select(static x => x.File)];
List<string> wrapped = [.. AppXaml().Where(static x => string.Equals(x.Xaml.Root!.Name.LocalName, "Page", StringComparison.Ordinal)
&& !string.Equals(x.Xaml.Root.Attribute("ScrollViewer.CanContentScroll")?.Value, "False", StringComparison.Ordinal))
.Select(static x => x.File)];
pages.Should().HaveCountGreaterThanOrEqualTo(6);
wrapped.Should().BeEmpty("a page without ScrollViewer.CanContentScroll=\"False\" is wrapped in WPF UI's scroller, and its own root swallows the wheel");
}
/// <summary>
/// A stock <c>ScrollViewer</c> takes every wheel, even with nothing left to scroll; inside a dialog that scrolls, the wheel
/// then stops at it. WPF UI's <c>PassiveScrollViewer</c> hands the wheel on at its ends (beta.14).
/// </summary>
[Fact]
public void NoPlainScrollViewerInsideADialog()
{
AppXaml().Where(static x => x.File.StartsWith("Dialogs" + Path.DirectorySeparatorChar, StringComparison.Ordinal))
.SelectMany(static x => x.Xaml.Descendants().Where(static e => string.Equals(e.Name.LocalName, "ScrollViewer", StringComparison.Ordinal)).Select(_ => x.File))
.Should().BeEmpty("use ui:PassiveScrollViewer inside a dialog");
}
[Fact]
public void TheManifestIsPerMonitorV2()
{
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using FluentAssertions;
using FrameLedger.App.Charts;
using ScottPlot.WPF;
namespace FrameLedger.App.Tests;
/// <summary>
/// The wheel over a chart (beta.14): ScottPlot zooms on every wheel and never marks it handled, so on a page that scrolls a
/// wheel over a chart zoomed it AND scrolled the page. A plain wheel is the page's now and Ctrl+wheel the chart's. The Ctrl
/// half reads <see cref="Keyboard.Modifiers"/>, which a test cannot press, so it is held by the pure rule; the plain half is
/// driven end to end.
/// </summary>
public sealed class ChartWheelTests
{
[Theory]
[InlineData(ModifierKeys.None, false)]
[InlineData(ModifierKeys.Shift, false)]
[InlineData(ModifierKeys.Alt, false)]
[InlineData(ModifierKeys.Control, true)]
[InlineData(ModifierKeys.Control | ModifierKeys.Shift, true)]
public void OnlyCtrlZooms(ModifierKeys modifiers, bool zooms) => ChartWheel.Zooms(modifiers).Should().Be(zooms);
/// <summary>
/// A plain wheel over the plot reaches the page and never the plot's drawing surface, where ScottPlot listens: the probe
/// subscribes to the surface's wheel exactly as ScottPlot does, so it is called whenever ScottPlot would zoom.
/// </summary>
[Fact]
public async Task APlainWheelOverAChartScrollsThePageAndNotTheChart()
{
(double Offset, int SurfaceWheels) result = await PagesLoadTests.OnStaAsync(() =>
{
var plot = new WpfPlot { Height = 300 };
ChartTheme.Attach(plot);
var page = new ScrollViewer
{
Height = 400,
Content = new StackPanel { Children = { new Border { Height = 200 }, plot, new Border { Height = 900 } } },
};
Visuals.Layout(page, 800, 400);
UIElement surface = Visuals.FindAll<FrameworkElement>(plot).First(static e => string.Equals(e.GetType().Name, "SKElement", StringComparison.Ordinal));
int surfaceWheels = 0;
surface.MouseWheel += (_, _) => surfaceWheels++;
var wheel = new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, -120) { RoutedEvent = UIElement.PreviewMouseWheelEvent };
surface.RaiseEvent(wheel);
wheel.RoutedEvent = UIElement.MouseWheelEvent;
surface.RaiseEvent(wheel);
page.UpdateLayout();
return (page.VerticalOffset, surfaceWheels);
});
result.Offset.Should().BeGreaterThan(0, "a plain wheel over a chart scrolls the page it is on");
result.SurfaceWheels.Should().Be(0, "and never reaches the surface ScottPlot zooms from: zoom is Ctrl+wheel");
}
}
+14 -56
View File
@@ -21,8 +21,6 @@ namespace FrameLedger.App.Tests;
/// </summary>
public sealed class ContrastTests
{
private const double _aa = 4.5;
private static readonly string[] _paletteAppearances = ["Info", "Caution", "Danger", "Success"];
/// <summary>
@@ -91,73 +89,33 @@ public sealed class ContrastTests
{
var themed = new ThemesDictionary { Theme = theme };
ApplicationAccentColorManager.Apply(_defaultAccent, theme, systemGlassColor: false, systemAccentColor: true);
Color window = Resolve(themed, "ApplicationBackgroundColor");
Color card = Over(Resolve(themed, "CardBackgroundFillColorDefault"), window);
Color pillOff = Over(Resolve(themed, "ControlFillColorDefault"), card);
Color accent = Over(Resolve(themed, "AccentFillColorDefaultBrush"), card);
Color caution = Over(Resolve(themed, "SystemFillColorCautionBackground"), card);
Color window = Wcag.Resolve(themed, "ApplicationBackgroundColor");
Color card = Wcag.Over(Wcag.Resolve(themed, "CardBackgroundFillColorDefault"), window);
Color pillOff = Wcag.Over(Wcag.Resolve(themed, "ControlFillColorDefault"), card);
Color accent = Wcag.Over(Wcag.Resolve(themed, "AccentFillColorDefaultBrush"), card);
Color caution = Wcag.Over(Wcag.Resolve(themed, "SystemFillColorCautionBackground"), card);
return new Dictionary<string, double>(StringComparer.Ordinal)
{
["hooking off: secondary text on the pill"] = Ratio(Over(Resolve(themed, "TextFillColorSecondary"), pillOff), pillOff),
["hooking on: on-accent text on the accent"] = Ratio(Over(Resolve(themed, "TextOnAccentFillColorPrimaryBrush"), accent), accent),
["qualifier warning: primary text on caution"] = Ratio(Over(Resolve(themed, "TextFillColorPrimary"), caution), caution),
["the Info badge, for the record"] = Ratio(Over(Resolve(themed, "TextFillColorPrimary"), PaletteLightBlue()), PaletteLightBlue()),
["hooking off: secondary text on the pill"] = Wcag.Ratio(Wcag.Over(Wcag.Resolve(themed, "TextFillColorSecondary"), pillOff), pillOff),
["hooking on: on-accent text on the accent"] = Wcag.Ratio(Wcag.Over(Wcag.Resolve(themed, "TextOnAccentFillColorPrimaryBrush"), accent), accent),
["qualifier warning: primary text on caution"] = Wcag.Ratio(Wcag.Over(Wcag.Resolve(themed, "TextFillColorPrimary"), caution), caution),
["the Info badge, for the record"] = Wcag.Ratio(Wcag.Over(Wcag.Resolve(themed, "TextFillColorPrimary"), PaletteLightBlue()), PaletteLightBlue()),
};
});
using (new FluentAssertions.Execution.AssertionScope(theme.ToString()))
{
ratios["hooking off: secondary text on the pill"].Should().BeGreaterThanOrEqualTo(_aa);
ratios["hooking on: on-accent text on the accent"].Should().BeGreaterThanOrEqualTo(_aa);
ratios["qualifier warning: primary text on caution"].Should().BeGreaterThanOrEqualTo(_aa);
ratios["hooking off: secondary text on the pill"].Should().BeGreaterThanOrEqualTo(Wcag.AA);
ratios["hooking on: on-accent text on the accent"].Should().BeGreaterThanOrEqualTo(Wcag.AA);
ratios["qualifier warning: primary text on caution"].Should().BeGreaterThanOrEqualTo(Wcag.AA);
}
if (theme == ApplicationTheme.Dark)
{
ratios["the Info badge, for the record"].Should().BeLessThan(_aa, "the pair this class exists for, white on #03A9F4, is what the check must be able to refuse");
ratios["the Info badge, for the record"].Should().BeLessThan(Wcag.AA, "the pair this class exists for, white on #03A9F4, is what the check must be able to refuse");
}
}
private static Color Resolve(ResourceDictionary themed, string key)
{
object value = themed[key] ?? System.Windows.Application.Current.Resources[key] ?? throw new InvalidOperationException($"{key} is in neither the theme nor the merged dictionaries");
return value switch
{
Color c => c,
SolidColorBrush b => b.Color,
_ => throw new InvalidOperationException($"{key} is not a Color or SolidColorBrush in the theme dictionary (got {value.GetType().Name})"),
};
}
/// <summary>WPF UI's Palette.xaml value, the same in both themes; read from the merged dictionaries rather than typed, so a palette change upstream is measured.</summary>
private static Color PaletteLightBlue() => Resolve(new ResourceDictionary(), "PaletteLightBlueBrush");
/// <summary>Source-over compositing of <paramref name="top"/> on an opaque <paramref name="under"/>.</summary>
private static Color Over(Color top, Color under)
{
double a = top.A / 255.0;
return Color.FromRgb(
(byte)Math.Round(top.R * a + under.R * (1 - a)),
(byte)Math.Round(top.G * a + under.G * (1 - a)),
(byte)Math.Round(top.B * a + under.B * (1 - a)));
}
/// <summary>WCAG 2.1 contrast ratio between two opaque colours.</summary>
private static double Ratio(Color a, Color b)
{
double la = Luminance(a);
double lb = Luminance(b);
return (Math.Max(la, lb) + 0.05) / (Math.Min(la, lb) + 0.05);
}
private static double Luminance(Color c)
{
static double Channel(byte v)
{
double s = v / 255.0;
return s <= 0.03928 ? s / 12.92 : Math.Pow((s + 0.055) / 1.055, 2.4);
}
return (0.2126 * Channel(c.R)) + (0.7152 * Channel(c.G)) + (0.0722 * Channel(c.B));
}
private static Color PaletteLightBlue() => Wcag.Resolve(new ResourceDictionary(), "PaletteLightBlueBrush");
}
@@ -0,0 +1,154 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.App.ViewModels;
using FrameLedger.Application.Import;
using Wpf.Ui.Appearance;
using Wpf.Ui.Markup;
namespace FrameLedger.App.Tests;
/// <summary>
/// The import checklist as the owner saw it (beta.14, a screenshot in the dark theme): every row white with white text, the
/// tick boxes cut to slivers at the left edge, and a list scrolling inside a dialog that scrolled too, which carried the
/// intro out of sight. Each check renders the dialog itself (<see cref="ImportReviewPrompt.Create"/>) laid out at a
/// window's size under the App's dictionaries — <c>PagesLoadTests</c>' check counted the rows and looked at nothing.
/// </summary>
public sealed class ImportReviewRenderTests
{
private static ImportReviewViewModel Candidates(int count)
{
var list = new List<ImportCandidate>();
for (int i = 0; i < count; i++)
{
string dir = string.Create(CultureInfo.InvariantCulture, $@"C:\Games\Game {i}");
string? exe = i == 1 ? null : string.Create(CultureInfo.InvariantCulture, $@"{dir}\game{i}.exe");
list.Add(new ImportCandidate(new StoreGame("steam", i.ToString(CultureInfo.InvariantCulture), "Game " + i.ToString(CultureInfo.InvariantCulture), dir, exe, null),
exe, AlreadyInLibrary: i == 2, ExecutableGuessed: false));
}
return new ImportReviewViewModel(list) { ShowExisting = true };
}
/// <summary>The dialog in a host the size of the window's dialog area, laid out.</summary>
private static (Wpf.Ui.Controls.ContentDialog Dialog, Grid Host) Shown(ImportReviewViewModel vm, double height)
{
Wpf.Ui.Controls.ContentDialog dialog = ImportReviewPrompt.Create(vm);
var host = new Grid { Width = 1000, Height = height, Children = { dialog } };
Visuals.Layout(host, 1000, height);
return (dialog, host);
}
/// <summary>
/// The text of every text cell against what is painted under it, composited down to the window (the tick box's glyph is an icon, not text). A row of a game already in the
/// library is drawn at 0.55 opacity on purpose (inactive: its box cannot be ticked) and is measured as drawn before that dimming.
/// </summary>
[Theory]
[InlineData(ApplicationTheme.Dark)]
[InlineData(ApplicationTheme.Light)]
public async Task EveryImportRowIsReadable(ApplicationTheme theme)
{
List<(string Text, double Ratio)> cells = await PagesLoadTests.OnStaAsync(() => Visuals.UnderTheme(theme, () =>
{
Color window = Wcag.Resolve(new ThemesDictionary { Theme = theme }, "ApplicationBackgroundColor");
(Wpf.Ui.Controls.ContentDialog dialog, Grid host) = Shown(Candidates(4), 760);
DataGrid grid = Visuals.Find<DataGrid>(dialog)!;
var measured = new List<(string, double)>();
foreach (DataGridCell cell in Visuals.FindAll<DataGridCell>(grid).Where(static c => c.Column is DataGridTextColumn))
{
foreach (TextBlock text in Visuals.FindAll<TextBlock>(cell).Where(static t => t.Text.Length > 0))
{
Color under = Visuals.PaintedUnder(text, host, window);
measured.Add((text.Text, Wcag.Ratio(Visuals.TextOver(text, under), under)));
}
}
return measured;
}));
cells.Should().NotBeEmpty("the rows were rendered and their cells hold text");
cells.Should().OnlyContain(static c => c.Ratio >= Wcag.AA, $"08_UI §Contrast: every row reads at WCAG AA in the {theme} theme (the beta.11 rows were white on white in Dark)");
}
/// <summary>
/// The owner's screenshot showed each tick box as a sliver at the row's left edge: WPF UI's CheckBox style (MinWidth 120,
/// padding 11) in a 40 px column. Counted in the rendered pixels: a ticked box is the accent's 20×20 square, about 380 accent-blue pixels when
/// it is drawn whole and about 140 when it is the sliver.
/// </summary>
[Fact]
public async Task TheTickBoxesAreDrawnWhole()
{
List<int> accentPixels = await PagesLoadTests.OnStaAsync(() =>
{
(Wpf.Ui.Controls.ContentDialog dialog, Grid host) = Shown(Candidates(4), 760);
var bitmap = new System.Windows.Media.Imaging.RenderTargetBitmap(1000, 760, 96, 96, PixelFormats.Pbgra32);
bitmap.Render(host);
byte[] pixels = new byte[1000 * 760 * 4];
bitmap.CopyPixels(pixels, 1000 * 4, 0);
var counts = new List<int>();
foreach (DataGridCell cell in Visuals.FindAll<DataGridCell>(Visuals.Find<DataGrid>(dialog)!))
{
if (Visuals.Find<CheckBox>(cell) is { IsChecked: true } box)
{
// Half a row of slack above and below: the dialog's opening transform moves what is drawn a few pixels
// from where layout puts it, and the rows on either side hold no ticked box.
Rect area = box.TransformToAncestor(host).TransformBounds(new Rect(box.RenderSize));
area.Inflate(0, 16);
counts.Add(AccentPixels(pixels, 1000, area));
}
}
return counts;
});
accentPixels.Should().HaveCount(2, "rows 0 and 3 start ticked; row 1 has no executable and row 2 is already in the library");
accentPixels.Should().OnlyContain(static n => n >= 250, "a ticked box is drawn whole (about 380 accent pixels), not as a sliver (about 140)");
}
/// <summary>Pixels in <paramref name="area"/> of a Pbgra32 bitmap that read as the accent's blue.</summary>
private static int AccentPixels(byte[] pixels, int width, Rect area)
{
int count = 0;
for (int y = (int)Math.Max(0, area.Top); y < (int)area.Bottom; y++)
{
for (int x = (int)Math.Max(0, area.Left); x < (int)Math.Min(width, area.Right); x++)
{
int i = ((y * width) + x) * 4;
byte blue = pixels[i];
byte red = pixels[i + 2];
if (blue > 150 && red < 110)
{
count++;
}
}
}
return count;
}
[Fact]
public async Task ALongListScrollsInsideTheListAndTheIntroStaysVisible()
{
(double DialogScrollable, double ListScrollable, double FooterBottom, double Viewport) layout = await PagesLoadTests.OnStaAsync(() =>
{
(Wpf.Ui.Controls.ContentDialog dialog, _) = Shown(Candidates(60), 600);
var body = (ScrollViewer)dialog.Template.FindName("PART_ContentScroll", dialog);
var content = (FrameworkElement)body.Content;
DataGrid grid = Visuals.Find<DataGrid>(content)!;
ScrollViewer list = Visuals.Find<ScrollViewer>(grid)!;
FrameworkElement footer = Visuals.FindAll<Wpf.Ui.Controls.TextBlock>(content).Last();
double footerBottom = footer.TransformToAncestor(body).Transform(new Point(0, footer.ActualHeight)).Y;
return (body.ScrollableHeight, list.ScrollableHeight, footerBottom, body.ViewportHeight);
});
layout.DialogScrollable.Should().Be(0, "the dialog's own body does not scroll: nothing above the list can be carried away");
layout.ListScrollable.Should().BeGreaterThan(0, "sixty rows scroll inside the list");
layout.FooterBottom.Should().BeLessThanOrEqualTo(layout.Viewport + 0.5, "the selection count under the list is inside the dialog, not cut off");
}
}
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using FluentAssertions;
using FrameLedger.App.Pages;
using FrameLedger.App.Services;
using FrameLedger.App.ViewModels;
using FrameLedger.Infrastructure.Persistence;
using Wpf.Ui.Controls;
namespace FrameLedger.App.Tests;
/// <summary>
/// The mouse wheel on the pages (beta.14, owner: "the wheel does not scroll, I have to drag the scroll bar"). WPF UI 4.3.0's
/// <see cref="NavigationViewContentPresenter"/> wraps a page in a <c>DynamicScrollViewer</c> unless the page sets
/// <c>ScrollViewer.CanContentScroll="False"</c>; inside it the page's own root scroller had infinite height, nothing to
/// scroll, and took every wheel all the same. Each check hosts a page the way the App does — navigated in the presenter.
/// </summary>
public sealed partial class PagesLoadTests
{
/// <summary>A page navigated in WPF UI's presenter and laid out in an area the size of the window's.</summary>
private static NavigationViewContentPresenter Navigated(System.Windows.Controls.Page page, double height)
{
var presenter = new NavigationViewContentPresenter();
var area = new Grid { Width = 1000, Height = height, Children = { presenter } };
Visuals.Layout(area, 1000, height);
_ = presenter.Navigate(page);
Visuals.Pump();
Visuals.Layout(area, 1000, height);
Visuals.Pump();
area.UpdateLayout();
return presenter;
}
private static void Wheel(UIElement over, int delta)
{
var wheel = new MouseWheelEventArgs(Mouse.PrimaryDevice, Environment.TickCount, delta) { RoutedEvent = UIElement.PreviewMouseWheelEvent };
over.RaiseEvent(wheel);
wheel.RoutedEvent = UIElement.MouseWheelEvent;
over.RaiseEvent(wheel);
}
[Fact]
public async Task ANavigatedPageIsNotWrappedInTheDynamicScrollViewerAndTheWheelScrollsIt()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
var consent = new HookingConsent(new NoAgent(), new NoPrompt());
(SettingsViewModel settings, LogsViewModel logs) = await SettingsAndLogsAsync(s, consent, new NoStrip());
using LogsViewModel ownedLogs = logs;
(bool Wrapped, double Offset) result = await OnStaAsync(() =>
{
var page = new SettingsPage(settings, new SystemInfoViewModel(new FixedHardware(), new NoClipboard(), new NoStrip()));
NavigationViewContentPresenter presenter = Navigated(page, 500);
System.Windows.Controls.ScrollViewer root = Visuals.Find<System.Windows.Controls.ScrollViewer>(page)!;
Wheel(Visuals.Leaf((UIElement)root.Content), -120);
presenter.UpdateLayout();
return (presenter.IsDynamicScrollViewerEnabled, root.VerticalOffset);
});
result.Wrapped.Should().BeFalse("the page opts out of WPF UI's wrapper (ScrollViewer.CanContentScroll=\"False\")");
result.Offset.Should().BeGreaterThan(0, "the wheel over the page's text scrolls the page");
}
[Fact]
public async Task TheLogsTailIsBoundedAndFollowsTheEnd()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
var consent = new HookingConsent(new NoAgent(), new NoPrompt());
(_, LogsViewModel logs) = await SettingsAndLogsAsync(s, consent, new NoStrip());
using LogsViewModel ownedLogs = logs;
(double Height, double Offset) tail = await OnStaAsync(() =>
{
var page = new LogsPage(logs);
_ = Navigated(page, 500);
page.Tail.Text = string.Join(Environment.NewLine, Enumerable.Range(1, 400).Select(static i => "line " + i.ToString(System.Globalization.CultureInfo.InvariantCulture)));
page.UpdateLayout();
page.Tail.ScrollToEnd();
page.UpdateLayout();
return (page.Tail.ActualHeight, page.Tail.VerticalOffset);
});
tail.Height.Should().BeLessThan(500, "the tail has the height the page leaves it, not one tall enough for every line");
tail.Offset.Should().BeGreaterThan(0, "so it scrolls, and ScrollToEnd (autoscroll) shows the newest line");
}
}
+18 -9
View File
@@ -24,7 +24,7 @@ namespace FrameLedger.App.Tests;
/// binding typo or a missing resource key produces is a XamlParseException at first navigation, which no
/// view-model test sees. Runs on an STA thread with an <c>Application</c> of its own.
/// </summary>
public sealed class PagesLoadTests
public sealed partial class PagesLoadTests
{
private sealed class NoAgent : IAgentLink
{
@@ -563,20 +563,29 @@ public sealed class PagesLoadTests
(SettingsViewModel settings, LogsViewModel logs) = await SettingsAndLogsAsync(s, consent, strip);
using LogsViewModel _ = logs;
string loaded = await OnStaAsync(() =>
(string loaded, List<string> wrapped) = await OnStaAsync(() =>
{
Render(new DashboardPage(dashboard));
Render(new GamesPage(games));
Render(new GameDetailPage(detail));
Render(new ComparePage(compare));
Render(new SettingsPage(settings, new SystemInfoViewModel(new FixedHardware(), new NoClipboard(), strip)));
Render(new LogsPage(logs));
// WPF UI changes ScrollViewer.CanContentScroll's default for Page to true when its content presenter is first
// used, as the App's NavigationView does at start-up; a page that keeps it is wrapped in a scroller (beta.14).
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(Wpf.Ui.Controls.NavigationViewContentPresenter).TypeHandle);
System.Windows.Controls.Page[] pages =
[
new DashboardPage(dashboard), new GamesPage(games), new GameDetailPage(detail), new ComparePage(compare),
new SettingsPage(settings, new SystemInfoViewModel(new FixedHardware(), new NoClipboard(), strip)), new LogsPage(logs),
];
foreach (System.Windows.Controls.Page page in pages)
{
Render(page);
}
RenderFirstRun(s);
RenderControls(detail);
return "dashboard,games,detail,settings,logs,firstrun,readout,chip";
return ("dashboard,games,detail,settings,logs,firstrun,readout,chip",
pages.Where(static p => System.Windows.Controls.ScrollViewer.GetCanContentScroll(p)).Select(static p => p.GetType().Name).ToList());
});
loaded.Should().Be("dashboard,games,detail,settings,logs,firstrun,readout,chip");
wrapped.Should().BeEmpty("every page sets ScrollViewer.CanContentScroll=\"False\", or WPF UI wraps it in a scroller its own root swallows the wheel for (16_WPFUI_SYNTAX §Gotchas)");
settings.MinSessionSeconds.Should().Be(30);
games.Games.Should().ContainSingle();
detail.Sessions.Should().HaveCount(2);
+134
View File
@@ -0,0 +1,134 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using Wpf.Ui.Appearance;
using Wpf.Ui.Markup;
namespace FrameLedger.App.Tests;
/// <summary>
/// Visual-tree helpers for the rendered checks (beta.14), all run on <see cref="PagesLoadTests.OnStaAsync{T}"/>'s thread:
/// find elements, pump the dispatcher, lay out at a size, swap the theme for one check, and the colour actually painted
/// under an element — the stack of backgrounds a pixel shows, composited, rather than one control's Background property.
/// </summary>
internal static class Visuals
{
public static T? Find<T>(DependencyObject root)
where T : DependencyObject => FindAll<T>(root).FirstOrDefault();
public static IEnumerable<T> FindAll<T>(DependencyObject root)
where T : DependencyObject
{
int count = VisualTreeHelper.GetChildrenCount(root);
for (int i = 0; i < count; i++)
{
DependencyObject child = VisualTreeHelper.GetChild(root, i);
if (child is T hit)
{
yield return hit;
}
foreach (T deeper in FindAll<T>(child))
{
yield return deeper;
}
}
}
/// <summary>The innermost element under <paramref name="root"/> along first children — where a pointer over it would land.</summary>
public static UIElement Leaf(UIElement root)
{
UIElement current = root;
while (VisualTreeHelper.GetChildrenCount(current) > 0 && VisualTreeHelper.GetChild(current, 0) is UIElement child)
{
current = child;
}
return current;
}
/// <summary>Runs the dispatcher's queue down to background priority — a Frame's navigation, Loaded, a deferred layout.</summary>
public static void Pump()
{
for (int i = 0; i < 3; i++)
{
var frame = new DispatcherFrame();
#pragma warning disable VSTHRD001 // a test's own STA thread: no JoinableTaskFactory exists here, and the frame is what is waited on
_ = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(_ =>
{
frame.Continue = false;
return null;
}), null);
#pragma warning restore VSTHRD001
Dispatcher.PushFrame(frame);
}
}
public static void Layout(FrameworkElement element, double width, double height)
{
element.Measure(new Size(width, height));
element.Arrange(new Rect(0, 0, width, height));
element.UpdateLayout();
}
/// <summary>
/// Runs <paramref name="work"/> with the App's theme dictionary swapped for <paramref name="theme"/>, and puts Dark back:
/// elements made inside take the theme's resources when they are created.
/// </summary>
public static T UnderTheme<T>(ApplicationTheme theme, Func<T> work)
{
System.Collections.ObjectModel.Collection<ResourceDictionary> merged = System.Windows.Application.Current.Resources.MergedDictionaries;
int index = merged.ToList().FindIndex(static d => d is ThemesDictionary);
ResourceDictionary original = merged[index];
merged[index] = new ThemesDictionary { Theme = theme };
try
{
return work();
}
finally
{
merged[index] = original;
}
}
/// <summary>
/// The colour painted under <paramref name="element"/>: every Border's and Panel's background from <paramref name="root"/>
/// down to the element, composited over <paramref name="window"/> — what a template's parts draw, which is what the eye sees.
/// </summary>
public static Color PaintedUnder(DependencyObject element, DependencyObject root, Color window)
{
var chain = new List<Brush?>();
for (DependencyObject? at = element; at is not null; at = VisualTreeHelper.GetParent(at))
{
chain.Add(at switch
{
Border b => b.Background,
Panel p => p.Background,
_ => null,
});
if (ReferenceEquals(at, root))
{
break;
}
}
Color painted = window;
for (int i = chain.Count - 1; i >= 0; i--)
{
if (chain[i] is SolidColorBrush { Color.A: > 0 } solid)
{
painted = Wcag.Over(Color.FromArgb((byte)Math.Round(solid.Color.A * solid.Opacity), solid.Color.R, solid.Color.G, solid.Color.B), painted);
}
}
return painted;
}
/// <summary>A TextBlock's text colour as drawn over <paramref name="under"/>.</summary>
public static Color TextOver(TextBlock text, Color under) =>
text.Foreground is SolidColorBrush brush ? Wcag.Over(brush.Color, under) : throw new InvalidOperationException("a text whose foreground is not a solid colour");
}
+58
View File
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Windows;
using System.Windows.Media;
namespace FrameLedger.App.Tests;
/// <summary>
/// WCAG 2.1 contrast arithmetic for the App's colour checks (<c>08_UI</c> §Contrast): a theme key resolved to a colour,
/// source-over compositing of a translucent colour on an opaque one, and the contrast ratio. Shared by
/// <see cref="ContrastTests"/> and the rendered checks since beta.14.
/// </summary>
internal static class Wcag
{
/// <summary>WCAG AA for body text.</summary>
public const double AA = 4.5;
public static Color Resolve(ResourceDictionary themed, string key)
{
object value = themed[key] ?? System.Windows.Application.Current.Resources[key] ?? throw new InvalidOperationException($"{key} is in neither the theme nor the merged dictionaries");
return value switch
{
Color c => c,
SolidColorBrush b => b.Color,
_ => throw new InvalidOperationException($"{key} is not a Color or SolidColorBrush in the theme dictionary (got {value.GetType().Name})"),
};
}
/// <summary>Source-over compositing of <paramref name="top"/> on an opaque <paramref name="under"/>.</summary>
public static Color Over(Color top, Color under)
{
double a = top.A / 255.0;
return Color.FromRgb(
(byte)Math.Round(top.R * a + under.R * (1 - a)),
(byte)Math.Round(top.G * a + under.G * (1 - a)),
(byte)Math.Round(top.B * a + under.B * (1 - a)));
}
/// <summary>WCAG 2.1 contrast ratio between two opaque colours.</summary>
public static double Ratio(Color a, Color b)
{
double la = Luminance(a);
double lb = Luminance(b);
return (Math.Max(la, lb) + 0.05) / (Math.Min(la, lb) + 0.05);
}
private static double Luminance(Color c)
{
static double Channel(byte v)
{
double s = v / 255.0;
return s <= 0.03928 ? s / 12.92 : Math.Pow((s + 0.055) / 1.055, 2.4);
}
return (0.2126 * Channel(c.R)) + (0.7152 * Channel(c.G)) + (0.0722 * Channel(c.B));
}
}