feat(app): the first .resx family with its generator and gate, and the App shell -- Generic Host, FluentWindow, the Agent pill over the pipe, theme + language persisted (P3 PR-2) (#155)
resx: src/FrameLedger.App/Strings.resx + .vi + .ja (65 keys; ja machine-drafted, marked `review`), tools/resx-gen.ps1 writing the committed Strings.Designer.cs (the SDK-style WPF project runs no ResXFileCodeGenerator), tools/resx-audit.ps1 as build.ps1 step 15: -SelfTest (11 fixture cases, 9 red) then live. Per family: identifier keys, non-empty neutral values, EXACT key sets in vi/ja, Safety_* in ja marked `safety: human review required` with the English verbatim (that is how "shown as en until signed" is true by construction) or `safety: reviewed by <name>`, and the accessor current. No family under src/ is red, not green. App: Generic Host per 16_WPFUI §App bootstrap; FluentWindow with the Agent pill in the TitleBar, the Menu row (unbuilt items say so in a snackbar), NavigationView with Settings in the footer, the offline InfoBar + Retry, SnackbarPresenter, ContentDialogHost. Theme (Light/Dark/System + SystemThemeWatcher) and language (rebuilds the shell in the new culture) persisted in `settings` under D16's ui.theme/ui.language through SqliteSettingsStore -- the App opens ledger.db directly (06_DATA_MODEL §Writer ownership, D15). Services.AgentConnection is 07_IPC §Client behavior as a state machine over PipeClient: 8 x 250 ms, start FrameLedger.Agent.exe --serve beside the App when absent, Hello/GetStatus, keepalive, the event stream, retry every 5 s. Dashboard shows the Agent card with N/A until answered; Games/Compare/Logs are empty states. Serilog logs/ui-.log per 10_LOGGING. Three things 16_WPFUI now records: MainWindow is transient with ShutdownMode=OnExplicitShutdown and the host lifetime ending the process; the run is one Task from a synchronous OnStartup (async void overrides are VSTHRD100 here); and ApplicationThemeManager.Apply(..., updateAccent: true) must precede the first window's XAML or the accent resources are missing at first Measure (measured: XamlParseException 'SystemAccentColorPrimary'). tests/FrameLedger.App.Tests (16): every key resolves in en/vi/ja and the satellites really load; the accessor's keys are the resx's; appearance settings round-trip; the connection against an in-process PipeServer -- Missing with nothing to start, Connected on Hello, Starting -> Connected through a launcher that brings the server up, Offline then Connected again when it returns. First window measured at 1.3 s. Docs corrected in place: 09_I18N (generator, audit as built, the ja Safety_* rule), 12_BUILD line 15, 13_CI_CD, CLAUDE.md (App is the shell; resx-audit exists), 08_UI §Shell built note, 16_WPFUI deviations + gotcha, 10_LOGGING ui log, HANDOFF §P3 row 2 struck (Shared's family waits for PR-4 on purpose). CHANGELOG. Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf3e9f22ba
commit
e16185f60e
61 files changed
+3216
-63
No files matched your search
@@ -19,6 +19,31 @@ GitHub release body, so a missing section will mean an empty release note.
|
||||
|
||||
### Added
|
||||
|
||||
- **P3 PR-2 — the first `.resx` family, its generator and its gate, and the App shell (2026-09-13).**
|
||||
`src/FrameLedger.App/Strings.resx` + `.vi` + `.ja` (65 keys, `ja` machine-drafted and marked `review`),
|
||||
`tools/resx-gen.ps1` writing the committed `Strings.Designer.cs` (the SDK-style WPF project runs no
|
||||
`ResXFileCodeGenerator`), and `tools/resx-audit.ps1` as `build.ps1` step 15 — self-test (11 fixture
|
||||
cases, both directions) then live: identifier keys, exact key sets across the three files, `Safety_*`
|
||||
in `ja` marked `safety: human review required` with the English verbatim or `safety: reviewed by <name>`,
|
||||
the accessor current; a tree with no family is red. `09_I18N` §Translation workflow and §Safety-critical
|
||||
strings, `12_BUILD` line 15, `13_CI_CD` and `CLAUDE.md` stop saying the tool does not exist. The App is a
|
||||
Generic Host under `16_WPFUI_SYNTAX` §App bootstrap: `FluentWindow`, TitleBar with the Agent pill, the
|
||||
Menu row (unbuilt items say so in a snackbar), NavigationView (Dashboard · Games · Compare · Logs, Settings
|
||||
in the footer), the offline `InfoBar` with Retry, `SnackbarPresenter`, `ContentDialogHost`; theme
|
||||
(Light/Dark/System with `SystemThemeWatcher`) and language (rebuilds the shell in the new culture) both
|
||||
persisted in `settings` under D16's `ui.theme`/`ui.language` through `SqliteSettingsStore` — the App opens
|
||||
`ledger.db` directly per `06_DATA_MODEL` §Writer ownership (D15). `Services.AgentConnection` is `07_IPC`
|
||||
§Client behavior as a state machine over `PipeClient`: 8 × 250 ms connect, start `FrameLedger.Agent.exe
|
||||
--serve` beside the App when absent, `Hello`/`GetStatus`, keepalive pings, the event stream, retry every
|
||||
5 s; the Dashboard's Agent card shows `HelloAck`/`StatusAck` with `N/A` until answered. Serilog
|
||||
`logs/ui-.log` per `10_LOGGING`. `tests/FrameLedger.App.Tests` (16): every key resolves in en/vi/ja and
|
||||
the satellites really load, the accessor's keys are the resx's, appearance settings round-trip, and the
|
||||
connection against an in-process `PipeServer` — Missing with nothing to start, Connected on `Hello`,
|
||||
Starting → Connected through a launcher that brings the server up, Offline then Connected again when it
|
||||
returns. Measured: first window at 1.3 s. Three things `16_WPFUI` now records: `MainWindow` is transient
|
||||
with `ShutdownMode=OnExplicitShutdown` and the host lifetime ending the process; the run is one task from
|
||||
a synchronous `OnStartup`; and `ApplicationThemeManager.Apply(…, updateAccent: true)` must precede the
|
||||
first window's XAML or the accent resources are missing at first Measure (`XamlParseException`).
|
||||
- **P3 PR-1b — the command pipe, command half: `SetWatchlist`, `LaunchGame`, `SetHookEnabled` (pre-scan, no stamp
|
||||
yet), pause/resume, `StopSession`, `UpdateRules`, `Shutdown` (2026-09-13).** `Application.Ipc.AgentCommandHandler`
|
||||
answers every UI → Agent row of `07_IPC` §Messages under the one rule of §The pipe is not a trust boundary — the
|
||||
|
||||
@@ -88,7 +88,11 @@ src/
|
||||
# `--console` = the operator's verbs incl. `consent grant` (decision D4,
|
||||
# ConsentProvenance.AgentConsoleOperator) and `killswitch` (FR-2.4,
|
||||
# the gate's FOURTH input, decision D7). --data-dir under --console only.
|
||||
FrameLedger.App/ # WPF UI
|
||||
FrameLedger.App/ # WPF UI — the SHELL since 2026-09-13 (P3 PR-2): Generic Host,
|
||||
# FluentWindow + TitleBar/Menu/NavigationView, theme + language
|
||||
# persisted in `settings`, the Agent pill over the pipe (starts
|
||||
# `FrameLedger.Agent.exe --serve` beside itself when absent),
|
||||
# five pages of which four are empty states; Strings.resx en/vi/ja
|
||||
FrameLedger.CaptureHost/ # UNSHIPPED, and since P2 PR-C (2026-09-09) a THIN SHELL: verbs,
|
||||
# the operator disclosure, the report consumer, and the composition
|
||||
# of Application.Capture.CaptureSession over Infrastructure's
|
||||
@@ -108,7 +112,8 @@ tools/ # changelog-check, chokepoint-check, coverage-gat
|
||||
# rules-validate, vendor-exports, versioninfo-check,
|
||||
# vklayer-blastradius
|
||||
# (PowerShell). This line used to name three, one of which
|
||||
# — resx-audit — does not exist.
|
||||
# — resx-audit — ~~does not exist~~ exists since 2026-09-13 with
|
||||
# resx-gen (the committed Strings.Designer.cs generator).
|
||||
# native tooling lives under src/native/tools:
|
||||
# fl-layout-dump -> struct offsets for the C# mirror test
|
||||
# hook-harness -> dummy D3D11 + D3D12 + Vulkan + OpenGL app
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
</Folder>
|
||||
<Folder Name="/tests/">
|
||||
<Project Path="tests/FrameLedger.Agent.Tests/FrameLedger.Agent.Tests.csproj" />
|
||||
<Project Path="tests/FrameLedger.App.Tests/FrameLedger.App.Tests.csproj" />
|
||||
<Project Path="tests/FrameLedger.Application.Tests/FrameLedger.Application.Tests.csproj" />
|
||||
<Project Path="tests/FrameLedger.CaptureHost.Tests/FrameLedger.CaptureHost.Tests.csproj" />
|
||||
<Project Path="tests/FrameLedger.Domain.Tests/FrameLedger.Domain.Tests.csproj" />
|
||||
|
||||
@@ -426,13 +426,17 @@ function Invoke-ProjectGates {
|
||||
Skip-Gate 'changelog-check' 'tools/changelog-check.ps1 not implemented yet'
|
||||
}
|
||||
|
||||
# 09_I18N's gate, built with the first .resx family (P3 PR-2, 2026-09-13): every key in en/vi/ja, ja
|
||||
# Safety_* marked for human review, the generated accessor current. Self-test first (at least four
|
||||
# cases must go red), then the live pass; a tree with no family is red, not skipped.
|
||||
Write-Step 'resx-audit'
|
||||
$resxTool = Join-Path $repo 'tools/resx-audit'
|
||||
$resxTool = Join-Path $repo 'tools/resx-audit.ps1'
|
||||
if (Test-Path $resxTool) {
|
||||
Invoke-Checked 'resx-audit' { & $resxTool }
|
||||
Invoke-Checked 'resx-audit (self-test)' { & $resxTool -SelfTest }
|
||||
Invoke-Checked 'resx-audit' { & $resxTool -Root $repo }
|
||||
}
|
||||
else {
|
||||
Skip-Gate 'resx-audit' 'tools/resx-audit not implemented yet (no .resx files exist)'
|
||||
throw 'resx-audit: tools/resx-audit.ps1 is missing — 09_I18N names it and build.ps1 used to skip it loudly'
|
||||
}
|
||||
|
||||
# The shared-memory struct mirror. CLAUDE.md §Struct mirroring calls this the
|
||||
|
||||
@@ -28,6 +28,16 @@ WPF + **WPF UI (Wpf.Ui, Fluent)**. Shell = `ui:FluentWindow` with custom `ui:Tit
|
||||
|
||||
The Menu sits in its own row **below** the TitleBar (never inside the drag region — 16 §Gotchas).
|
||||
|
||||
> **Built 2026-09-13 (P3 PR-2): the shell, and only the shell.** `FluentWindow`, the TitleBar with the
|
||||
> Agent pill as trailing content, the Menu row (every item that a later slice builds says so in a 4 s
|
||||
> snackbar rather than doing nothing), the NavigationView with the four items and Settings in the footer,
|
||||
> the offline `InfoBar` with Retry, `SnackbarPresenter` and `ContentDialogHost`. The Dashboard shows the
|
||||
> Agent status card (`HelloAck`/`StatusAck`, every value `N/A` until answered); Games, Compare and Logs
|
||||
> are empty states; Settings has Appearance (theme + language, both persisted in `settings` — D16's
|
||||
> `ui.theme`/`ui.language`). The App starts `FrameLedger.Agent.exe --serve` beside itself when the pipe
|
||||
> is absent (`07_IPC` §Client behavior, 8 × 250 ms) and shows **Missing** when there is no Agent to start.
|
||||
> Measured on the dev box: first window at 1.3 s from process start (NFR-4's 2 s). The tray is PR-8's.
|
||||
|
||||
**Tray (H.NotifyIcon):** icon states idle / ● capturing (T1 hooked) / ◐ recording only (T2 — nothing measured) / ⏸ paused; menu: Open, Pause/Resume capture, Agent status, Exit. Closing the window minimizes to tray when enabled.
|
||||
|
||||
## Notifications policy
|
||||
|
||||
+8
-7
@@ -4,7 +4,7 @@ Languages: **en** (neutral/default) · **vi** · **ja**. Same `.resx` pattern as
|
||||
|
||||
## Mechanics
|
||||
|
||||
- One `Strings.resx` (+ `Strings.vi.resx`, `Strings.ja.resx`) per assembly that has user-visible text (`App`, `Shared` for error codes). Access through a generated strongly-typed class; **no string literals in XAML/C# for user-visible text** (analyzer TODO: Meziantou MA0011/manual review in PR checklist).
|
||||
- One `Strings.resx` (+ `Strings.vi.resx`, `Strings.ja.resx`) per assembly that has user-visible text (`App`, `Shared` for error codes). Access through a generated strongly-typed class; **no string literals in XAML/C# for user-visible text** (analyzer TODO: Meziantou MA0011/manual review in PR checklist). **As built (P3 PR-2, 2026-09-13):** the class is `Strings.Designer.cs`, written by `tools/resx-gen.ps1 -Resx <file>` and **committed** — not the SDK's `ResXFileCodeGenerator`, which the SDK-style WPF project does not run — with `Culture`, `ResourceManager`, `Keys`, and one property per key; the audit below fails when it is stale. The first family is `src/FrameLedger.App/Strings.resx` (65 keys); `Shared`'s arrives with PR-4's `Safety_*` text, because an empty family is what the audit refuses.
|
||||
- XAML binding via `{x:Static res:Strings.Key}` plus a `LocalizeExtension` for the few dynamic cases.
|
||||
- **Runtime switching:** setting change → set `CultureInfo.CurrentUICulture` + `Thread` defaults → re-create the main window shell (cheap; state preserved via VM). Persist in `settings`.
|
||||
- `SatelliteResourceLanguages` = `en;vi;ja` in the App csproj to keep publish size down.
|
||||
@@ -25,7 +25,7 @@ Languages: **en** (neutral/default) · **vi** · **ja**. Same `.resx` pattern as
|
||||
- `en` written first, is authoritative.
|
||||
- `vi` authored by the maintainer.
|
||||
- `ja` machine-drafted, each entry marked with `<comment>review</comment>` until reviewed; the About dialog credits reviewers.
|
||||
- CI check (`tools/resx-audit`): every key present in all three files; missing → build warning list artifact.
|
||||
- CI check (`tools/resx-audit`): every key present in all three files; ~~missing → build warning list artifact~~ **missing is RED (2026-09-13)**: `tools/resx-audit.ps1` exists since P3 PR-2 as `build.ps1` step 15, self-test first (11 fixture cases, at least four must go red) then the live pass over every `Strings.resx` under `src/`. Per family it requires C#-identifier keys with non-empty neutral values, **exactly** the neutral key set in `vi` and `ja` (a missing key would fall back to English silently; an extra one is dead text), the `Safety_*` rule below, and a current `Strings.Designer.cs`. A tree with no family is red, not green — the gate must not be vacuous.
|
||||
|
||||
## Glossary (fixed translations)
|
||||
|
||||
@@ -52,7 +52,7 @@ Technical benchmark vocabulary stays in English across all locales where the com
|
||||
|
||||
Consent, refusal, and safety-unhook text (FR-2.1, `19_SAFETY`) is **reviewed like legal text, not like UI text**:
|
||||
|
||||
- No machine-drafted `ja` in this category — a mistranslated ban warning is a real harm. These keys are marked `<comment>safety: human review required</comment>` and the `ja` build fails the resx audit until a human reviewer signs off; until then the `en` string is shown as fallback rather than an unreviewed translation.
|
||||
- No machine-drafted `ja` in this category — a mistranslated ban warning is a real harm. These keys are marked `<comment>safety: human review required</comment>` and ~~the `ja` build fails the resx audit until a human reviewer signs off; until then the `en` string is shown as fallback rather than an unreviewed translation~~ **as built (2026-09-13): the audit is red on a `Safety_*` key in `ja` that carries neither `safety: human review required` nor `safety: reviewed by <name>`, and red on one marked review-required whose value is anything but the `en` string verbatim** — the key-set rule forbids leaving it out, so "shown as `en` until signed" is true by construction (the value IS the English), not by a runtime fallback. Signing = replacing the comment with `safety: reviewed by <name>` beside the reviewed text.
|
||||
- Never soften the wording per locale. "May result in a permanent ban of your account" must survive translation with the same force in all three languages.
|
||||
- Key prefix `Safety_*` so they are easy to audit as a group.
|
||||
|
||||
@@ -66,12 +66,13 @@ Consent, refusal, and safety-unhook text (FR-2.1, `19_SAFETY`) is **reviewed lik
|
||||
> **It is also why `ConsentProvenance` has no FR-2.1 member.** The host writes a consent record on
|
||||
> the strength of an operator acknowledgement whose first line states, in substance, that it is
|
||||
> *not* the FR-2.1 dialog. Drafting that dialog's wording English-only inside a developer tool
|
||||
> would manufacture the reviewed artifact without the review this section requires — no `.resx`
|
||||
> file exists anywhere in the tree yet, and `tools/resx-audit` does not exist either. The enum has
|
||||
> would manufacture the reviewed artifact without the review this section requires — ~~no `.resx`
|
||||
> file exists anywhere in the tree yet, and `tools/resx-audit` does not exist either~~ (both exist
|
||||
> since P3 PR-2, 2026-09-13; the App's family holds shell text and no `Safety_*` key yet). The enum has
|
||||
> ~~exactly two members~~ **exactly three members since 2026-09-10** (P2 PR-F added
|
||||
> `AgentConsoleOperator`, the shipped Agent's console verb — HANDOFF §P2 decision D4 — which is
|
||||
> likewise *not* FR-2.1 and says so in its first line; this sentence said "two" for three days after
|
||||
> that) and a test asserts the list, so adding the FR-2.1 value is a deliberate act that arrives with
|
||||
> its reviewed strings or not at all. **P3 is where it arrives** (HANDOFF §P3): `Safety_*` in `en` and
|
||||
> `vi`, `ja` marked for human review and shown as `en` until signed, and `tools/resx-audit` built in
|
||||
> the same phase.
|
||||
> `vi`, `ja` marked for human review and shown as `en` until signed, and `tools/resx-audit` ~~built in
|
||||
> the same phase~~ built first (PR-2), so PR-4's family lands under a gate that already exists.
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## Serilog configuration
|
||||
|
||||
- Sinks: rolling file per process — `logs/ui-.log`, `logs/agent-.log` (`rollingInterval: Day`, `retainedFileCountLimit: 7`, `fileSizeLimitBytes: 10 MB`, `rollOnFileSizeLimit: true`). Console sink in DEBUG builds.
|
||||
- Sinks: rolling file per process — `logs/ui-.log`, `logs/agent-.log` (`rollingInterval: Day`, `retainedFileCountLimit: 7`, `fileSizeLimitBytes: 10 MB`, `rollOnFileSizeLimit: true`). Console sink in DEBUG builds. *(`ui-.log` is written since 2026-09-13, P3 PR-2, with `Process=ui` enriched and every unhandled path — Dispatcher, AppDomain, unobserved task — logged as Fatal/Error; the crash dialog and minidump of §Crash handling are still P4's.)*
|
||||
- Minimum level `Information` (`Debug` toggle in Settings → applies live via `LoggingLevelSwitch`).
|
||||
- Enrichers: process name, version, `SessionGuid` and `GamePid` scoped properties during capture (`LogContext.PushProperty`).
|
||||
- Template: `[{Timestamp:HH:mm:ss.fff} {Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}`.
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ document the app displays for acceptance (FR-11) is a defect, not a template.
|
||||
13. `tools/license-check.ps1` — asserts every vendored third-party has a licence copy in `legal/licenses/`, and that no Intel IGCL / AMD ADLX material has appeared in the tree
|
||||
13b. `tools/accuracy-check.ps1 -SelfTest`, then live — the accuracy block is ONE text (`legal/ACCURACY.md`) embedded verbatim in `README.md` and `legal/DISCLAIMER.md` §4; a copy that drifted, a copy with no markers, or an empty source is red. Four self-test cases, both directions (§S23-6, 2026-09-06)
|
||||
14. `tools/changelog-check.ps1 -SelfTest` — nine cases, five expected RED. The live half needs a pull request's changed-file list and is supplied by `ci.yml`
|
||||
15. `tools/resx-audit` — **skipped loudly; it does not exist, and no `.resx` file does either**
|
||||
15. `tools/resx-audit.ps1` — ~~**skipped loudly; it does not exist, and no `.resx` file does either**~~ **built 2026-09-13 (P3 PR-2)**: `-SelfTest` first (11 fixture cases, both directions), then the live pass over every `Strings.resx` family under `src/` — key sets equal across en/vi/ja, `Safety_*` in `ja` marked for review or signed, `Strings.Designer.cs` current with `tools/resx-gen.ps1`. A tree with no family is red (`09_I18N` §Translation workflow)
|
||||
16. **struct-mirror** — reads this run's `.trx` and fails when `ShmLayoutMirrorTests` did not execute, so deleting the mirror test is red as well as breaking it
|
||||
17. Placeholder guard — fails if any `{{` token other than `{{RELEASE_DATE}}` survives in `README.md` or `legal/*.md`
|
||||
|
||||
|
||||
+3
-2
@@ -47,8 +47,9 @@ FrameLedger uses the **`poli0981/.github` ops repo** where its templates fit, an
|
||||
- **Changelog gate**, on pull requests only: the changed-file list comes from GitHub's own view of the PR — not `git diff`, so a shallow checkout cannot silently produce a short one — and an empty list is refused rather than read as "no `src/` changes". It is a **step of the required `check` job** and deliberately not a job of its own: `main`'s required contexts are exactly `check` and the two `analyze` jobs, so a new job would go red while the merge button stayed green, which is what already makes `Rules / validate` advisory (§S23-2).
|
||||
|
||||
> **Three claims in this section were false and are corrected 2026-08-06.** There is no Vulkan SDK
|
||||
> step and there will not be one — the Khronos headers are vendored. `resx-audit` does not exist and
|
||||
> is skipped loudly, so no artifact of it is uploaded. And the struct-mirror parenthesis — *"that
|
||||
> step and there will not be one — the Khronos headers are vendored. `resx-audit` ~~does not exist and
|
||||
> is skipped loudly, so no artifact of it is uploaded~~ (exists since 2026-09-13, P3 PR-2, as a hard step
|
||||
> of the gate — red on a missing key, never an artifact; `12_BUILD` line 15). And the struct-mirror parenthesis — *"that
|
||||
> gate does not exist and `build.ps1` skips it loudly"* — has been false since 2026-08-05:
|
||||
> `build.ps1` implements it as a hard throwing gate that reads the run's `.trx` and fails when
|
||||
> `ShmLayoutMirrorTests` did not execute. `12_BUILD` carried the identical stale sentence and is
|
||||
|
||||
@@ -57,10 +57,12 @@ private static readonly IHost _host = Host.CreateDefaultBuilder()
|
||||
.Build();
|
||||
```
|
||||
|
||||
**As built (P3 PR-2, 2026-09-13), three deviations from the sketch above:** `Host.CreateApplicationBuilder()` rather than `CreateDefaultBuilder`; `MainWindow` is **transient** (a language change rebuilds it in the new culture — `09_I18N` §Mechanics — and `Services.ShellHost` tracks the live one), so `App.xaml` sets `ShutdownMode="OnExplicitShutdown"` and the host's `IHostApplicationLifetime` is what ends the process (the shell host stops it when the live window closes; the old window of a rebuild closing is not an exit); and the run is one `Task` started from a synchronous `OnStartup` (`async void` overrides are VSTHRD100 under this repo's analyzers) that opens the ledger, starts the host, awaits its shutdown, tears down, and only then calls `Shutdown()`.
|
||||
|
||||
Theme rules:
|
||||
- Manual Light/Dark: `ApplicationThemeManager.Apply(ApplicationTheme.Dark)`.
|
||||
- System: `SystemThemeWatcher.Watch(mainWindow)` — call it in the window's `Loaded` handler (needs an HWND), and unwatch when switching to manual.
|
||||
- Persist the choice in `settings`; re-apply before the main window shows to avoid a flash.
|
||||
- Persist the choice in `settings`; re-apply before the main window shows to avoid a flash. **Measured 2026-09-13: this is a correctness rule, not a cosmetic one** — `ApplicationThemeManager.Apply(theme, backdrop, updateAccent: true)` is what registers the `SystemAccentColor*` resources the control templates `StaticResource` at first Measure; a `FluentWindow` shown before any `Apply` throws `XamlParseException: Cannot find resource named 'SystemAccentColorPrimary'`. The shell applies the theme in its constructor before `InitializeComponent()` and again from `Loaded` for the watcher.
|
||||
- Subscribe `ApplicationThemeManager.Changed` once, centrally, to re-theme ScottPlot (below).
|
||||
|
||||
## Main window skeleton
|
||||
@@ -167,7 +169,7 @@ var result = await box.ShowDialogAsync(); // Wpf.Ui.Controls.MessageBoxResult.Pr
|
||||
```
|
||||
|
||||
⚠ Name clash with `System.Windows.MessageBox` — in App code, `using MessageBox = Wpf.Ui.Controls.MessageBox;` and ban the System one (BannedSymbols/analyzer note).
|
||||
- Rich in-flow dialogs: `IContentDialogService` (host wired in MainWindow).
|
||||
- Rich in-flow dialogs: `IContentDialogService` (host wired in MainWindow — a `ui:ContentDialogHost`, since 4.3.0 marks `SetDialogHost(ContentPresenter)` obsolete).
|
||||
- Transient in-app: `ISnackbarService.Show(title, message, ControlAppearance.Success, new SymbolIcon(SymbolRegular.Checkmark24), TimeSpan.FromSeconds(4))`.
|
||||
- System/tray notifications: H.NotifyIcon only (08_UI §Notifications policy).
|
||||
|
||||
@@ -178,7 +180,7 @@ On startup and on `ApplicationThemeManager.Changed`: for every live plot set fig
|
||||
## Gotchas checklist
|
||||
|
||||
- [ ] Dictionaries order: `ThemesDictionary` → `ControlsDictionary` → app styles. Wrong order = default-looking controls.
|
||||
- [ ] `SystemThemeWatcher.Watch` after HWND exists (`Loaded`), not in the constructor.
|
||||
- [ ] `SystemThemeWatcher.Watch` after HWND exists (`Loaded`), not in the constructor — but `ApplicationThemeManager.Apply(…, updateAccent: true)` BEFORE the first window's XAML loads, or the accent resources are missing at first Measure (§App bootstrap).
|
||||
- [ ] Menu row lives **outside** `ui:TitleBar` (its area is the drag region; a Menu inside becomes undraggable/unclickable territory).
|
||||
- [ ] Don't set `AllowsTransparency`/`WindowStyle` on `FluentWindow` — it manages its own chrome.
|
||||
- [ ] Mica is Win 11-only: leave `WindowBackdropType="Mica"`; the library falls back on Win 10 — verify visuals in the Win 10 VM pass (14_TESTING matrix).
|
||||
|
||||
+4
-3
@@ -1226,8 +1226,9 @@ first, and both are *replacements* rather than new ground:
|
||||
what makes the Dashboard's live card worth having.
|
||||
2. **FR-2.1's consent dialog, which retires `ConsentProvenance.AgentConsoleOperator`.** The console
|
||||
verb exists because the reviewed wording does not: `09_I18N` reviews `Safety_*` strings as legal
|
||||
text in en/vi/ja, and no `.resx` exists anywhere in this tree. The dialog is the first thing that
|
||||
needs one. When it lands, the enum gains its FR-2.1 member, the console verb becomes the
|
||||
text in en/vi/ja, and ~~no `.resx` exists anywhere in this tree~~ (the App's shell family exists
|
||||
since PR-2, 2026-09-13, under the audit; `Shared`'s `Safety_*` family is still this item's). The
|
||||
dialog is the first thing that needs a REVIEWED one. When it lands, the enum gains its FR-2.1 member, the console verb becomes the
|
||||
developer path it always said it was, and `19_SAFETY` §User-facing consent stops carrying an
|
||||
exception. **Do not add the enum member before the reviewed text exists** — a declared value no
|
||||
code can produce is the §S29(c) shape, and `GameConsentRecordTests` turns red on purpose.
|
||||
@@ -1250,7 +1251,7 @@ because a criterion already true on `main` is decoration.
|
||||
| 0 | P2 sweep: the doc/tool drift PR-G left (`coverage-gate.ps1` prose, `13_CI_CD`'s count and its signer-probe claim, `09_I18N`'s member count, `17_HOOK_ENGINE`'s §H9 cite, this file's D-labels, `ci.yml`'s census comment), this head, the roadmap amendment | `grep -n "exactly two members" docs/09_I18N.md` matched; `§H9` resolved to nothing; two START HEREs |
|
||||
| ~~1~~ | ~~**The pipe, read half**: `Shared.Ipc` contracts + `JsonSerializerContext`; the Agent's `PipeServerHostedService`; `Hello`/`HelloAck`, `GetStatus`/`StatusAck`, `Ping`/`Pong`; the events (`SessionStarted`/`Progress`/`Completed`/`CaptureRefused`/`CaptureDegraded`/`SafetyUnhook`/`CaptureError`); a 1 Hz `SessionProgress` publisher; `Infrastructure.Ipc.PipeClient`~~ **LANDED 2026-09-13** — status in `CHANGELOG.md`; `07_IPC` §C carries what was built and the one deviation (`etwAvailable` struck) | ~~`grep -rn NamedPipeServerStream src` is empty; `FrameLedger.Shared` holds no JSON type; `04_CAPTURE` §Live progress has no producer~~ |
|
||||
| ~~1b~~ | ~~**The pipe, command half**: `SetWatchlist` (identity only), `SetHookEnabled` (the Agent re-scans and stamps), `LaunchGame`, `PauseCapture`/`ResumeCapture`, `StopSession`, `UpdateRules` (a trigger, no payload), `Shutdown`~~ **LANDED 2026-09-13** — status in `CHANGELOG.md`; `07_IPC` §Messages carries each row as built. **One thing stayed with PR-4 on purpose:** `SetHookEnabled true` stamps nothing — the pre-scan runs and a block is recorded, then `Error DisclosureUnavailable` — because the reviewed text it would stamp against does not exist, and a member no code can produce is the §S29(c) shape | ~~the Agent accepts no command from outside; `CaptureOrchestrator` has no stop/pause surface; `SetHookEnabled` has no handler~~ |
|
||||
| 2 | **resx + the App shell**: `Strings.resx` en/vi/ja for App and Shared, the generated class, `tools/resx-audit.ps1` (+`-SelfTest`) as `build.ps1` step 15; the Generic Host bootstrap, `FluentWindow`, TitleBar/Menu/NavigationView, theme + persistence, `INavigationService`, Serilog `ui-*.log`, five empty pages, the Agent status pill over `Hello`, auto-start of `--serve` on connect failure; `tests/FrameLedger.App.Tests` | `find . -name '*.resx'` is empty; step 15 prints "skipped loudly"; `App.xaml` uses `StartupUri` and `MainWindow` is a plain `Window` |
|
||||
| ~~2~~ | ~~**resx + the App shell**: `Strings.resx` en/vi/ja for App and Shared, the generated class, `tools/resx-audit.ps1` (+`-SelfTest`) as `build.ps1` step 15; the Generic Host bootstrap, `FluentWindow`, TitleBar/Menu/NavigationView, theme + persistence, `INavigationService`, Serilog `ui-*.log`, five empty pages, the Agent status pill over `Hello`, auto-start of `--serve` on connect failure; `tests/FrameLedger.App.Tests`~~ **LANDED 2026-09-13** — status in `CHANGELOG.md`; `08_UI` §Shell and `16_WPFUI_SYNTAX` §App bootstrap carry what was built and the deviations. **Two things moved on purpose:** `Shared`'s family waits for PR-4 (it would hold only `Safety_*`, and an empty family is what the audit refuses), and the generator is ours (`tools/resx-gen.ps1`, committed output) because the SDK-style WPF project runs no `ResXFileCodeGenerator` | ~~`find . -name '*.resx'` is empty; step 15 prints "skipped loudly"; `App.xaml` uses `StartupUri` and `MainWindow` is a plain `Window`~~ |
|
||||
| 2b *(owner decides)* | `FL_MOCK=1` / `Agent --serve --mock`, `--data-dir` only: a `MockSessionSource` hosted service that emits pipe events and inserts synthesised sessions through `ISessionRepository` — and can never resolve `HookedCaptureGate` (asserted) | CLAUDE.md says "specified but not implemented"; `grep FL_MOCK src` is empty |
|
||||
| 3 | **Ports the UI reads and writes**: `ISessionRepository.ListByGameAsync` / segments / sensors, `ISessionAnnotationRepository`, `ILegalAcceptanceStore.RecordAsync`, `IGameRepository.UpdateMetadataAsync` / `RemoveAsync`, the **settings registry** (closes §G's row — D16 below), `IRtOverrideRepository` (FR-8.3), `display_res`/`display_hz` producer; tests for the four PR-B adapters that have none | no port lists sessions by game; `session_annotations` has no repository; `legal_acceptance` has no writer; `ISettingsStore`'s own doc calls the registry open |
|
||||
| 4 | **FR-2.1's consent dialog**: `Safety_*` en + vi (ja marked `safety: human review required`, shown as en) in `Shared`, `SafetyDisclosureVersion`; `ConsentProvenance.ConsentDialog` whose only producer is the Agent's `SetHookEnabled` handler; `HelloAck.disclosureVersion` and the App **refusing to open the dialog** on mismatch (§S23-1's shape); the dialog itself per `19_SAFETY` §User-facing consent; FR-2.2's disabled toggle with the reason inline; FR-2.5's InfoBar; `GameConsentRecordTests`, `19_SAFETY`, `09_I18N` and item 2 above updated | `Enum.GetNames<ConsentProvenance>()` has three names; no `Safety_*` key exists; `19_SAFETY` still carries the console exception |
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
<Application x:Class="FrameLedger.App.App"
|
||||
<Application x:Class="FrameLedger.App.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:FrameLedger.App"
|
||||
StartupUri="MainWindow.xaml">
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
ShutdownMode="OnExplicitShutdown">
|
||||
<!--
|
||||
docs/16_WPFUI_SYNTAX.md §App bootstrap: dictionaries IN THIS ORDER (Themes before Controls, our styles
|
||||
last) or every control renders default-looking with no error. No StartupUri: the Generic Host in
|
||||
App.xaml.cs owns the window. ShutdownMode is explicit: the host's lifetime ends the process (the shell
|
||||
host stops it when the live window closes), so a language rebuild closing the old window is not an exit.
|
||||
-->
|
||||
<Application.Resources>
|
||||
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ui:ThemesDictionary Theme="Dark" />
|
||||
<ui:ControlsDictionary />
|
||||
<ResourceDictionary Source="Styles/FrameLedger.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
+180
-17
@@ -1,28 +1,191 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using FrameLedger.App.Pages;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.ViewModels;
|
||||
using FrameLedger.Application.Persistence;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Infrastructure.Persistence;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.DependencyInjection;
|
||||
|
||||
namespace FrameLedger.App;
|
||||
|
||||
/// <summary>
|
||||
/// Application entry point.
|
||||
/// The application (P3 PR-2): a .NET Generic Host owns everything, per <c>docs/16_WPFUI_SYNTAX.md</c> §App
|
||||
/// bootstrap. Startup opens the ledger the Agent owns (<c>06_DATA_MODEL</c> §Writer ownership: the App reads it
|
||||
/// all and writes only its own tables), reads the UI culture from <c>settings</c> BEFORE any window exists,
|
||||
/// then starts the host; <see cref="ApplicationHostService"/> shows the shell.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Scaffold only. The real bootstrap owns everything through a .NET Generic
|
||||
/// Host and must follow <c>docs/16_WPFUI_SYNTAX.md</c> exactly:
|
||||
/// <list type="bullet">
|
||||
/// <item>merged dictionaries in order <c>ThemesDictionary</c> →
|
||||
/// <c>ControlsDictionary</c> → our styles — wrong order silently yields
|
||||
/// default-looking controls;</item>
|
||||
/// <item><c>SystemThemeWatcher.Watch</c> from the window's <c>Loaded</c>
|
||||
/// handler, never the constructor (it needs an HWND);</item>
|
||||
/// <item>navigation only via <c>INavigationService</c>, with every page
|
||||
/// registered in DI.</item>
|
||||
/// </list>
|
||||
/// FULLY QUALIFIED base type, deliberately: this project's namespace is <c>FrameLedger.App</c> and there is a
|
||||
/// <c>FrameLedger.Application</c> namespace beside it, so the bare name <c>Application</c> resolves to that
|
||||
/// NAMESPACE rather than to the WPF type (CS0118) — sibling namespaces win over a <c>using</c>.
|
||||
/// </remarks>
|
||||
// FULLY QUALIFIED, deliberately. This project's namespace is FrameLedger.App
|
||||
// and there is now a FrameLedger.Application namespace beside it, so the bare
|
||||
// name `Application` resolves to that NAMESPACE rather than to the WPF type
|
||||
// (CS0118) — sibling namespaces win over a `using`. Anything here that means
|
||||
// the WPF Application must say so in full.
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
private IHost? _host;
|
||||
private LedgerDatabase? _db;
|
||||
private Task? _run;
|
||||
|
||||
/// <summary>The composition, for the few places XAML cannot reach DI (the shell rebuild, the crash path).</summary>
|
||||
public static IServiceProvider Services =>
|
||||
((App)Current)._host?.Services ?? throw new InvalidOperationException("the host is not started");
|
||||
|
||||
/// <summary>
|
||||
/// WPF's startup is synchronous and the host's is not, so the whole run is one task on the dispatcher:
|
||||
/// open, start, wait for the host's shutdown (the shell host requests it when the live window closes, the
|
||||
/// Exit command requests it directly), tear down, and only then <see cref="System.Windows.Application.Shutdown()"/>.
|
||||
/// </summary>
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
UiPaths.EnsureDirectories();
|
||||
ConfigureLogging();
|
||||
HookCrashHandlers();
|
||||
_run = RunAsync();
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(e);
|
||||
Log.Information("ui: exit {Code} (run {Status})", e.ApplicationExitCode, _run?.Status);
|
||||
Log.CloseAndFlush();
|
||||
base.OnExit(e);
|
||||
}
|
||||
|
||||
private async Task RunAsync()
|
||||
{
|
||||
int exitCode = 0;
|
||||
try
|
||||
{
|
||||
_db = await LedgerDatabase.OpenAsync(UiPaths.Database).ConfigureAwait(true);
|
||||
var appearance = new AppearanceSettings(new SqliteSettingsStore(_db));
|
||||
await appearance.LoadAsync().ConfigureAwait(true);
|
||||
ApplyCulture(appearance.Language);
|
||||
|
||||
_host = BuildHost(_db, appearance);
|
||||
await _host.StartAsync().ConfigureAwait(true);
|
||||
Log.Information("ui: started ({Version}), ledger {Ledger}", UiIdentity.Version, UiPaths.Database);
|
||||
await _host.WaitForShutdownAsync().ConfigureAwait(true);
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Fatal(ex, "ui: the run ended in an exception");
|
||||
exitCode = 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
await TearDownAsync().ConfigureAwait(true);
|
||||
Shutdown(exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task TearDownAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_host is not null)
|
||||
{
|
||||
await _host.StopAsync(TimeSpan.FromSeconds(5)).ConfigureAwait(true);
|
||||
_host.Dispose();
|
||||
_host = null;
|
||||
}
|
||||
|
||||
if (_db is not null)
|
||||
{
|
||||
await _db.DisposeAsync().ConfigureAwait(true);
|
||||
_db = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
Log.Warning(ex, "ui: shutdown was not clean");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The UI culture, once, before the first window: resources are read at XAML load.</summary>
|
||||
public static void ApplyCulture(string language)
|
||||
{
|
||||
var culture = CultureInfo.GetCultureInfo(language);
|
||||
CultureInfo.DefaultThreadCurrentUICulture = culture;
|
||||
CultureInfo.CurrentUICulture = culture;
|
||||
Strings.Culture = culture;
|
||||
}
|
||||
|
||||
private static IHost BuildHost(LedgerDatabase db, AppearanceSettings appearance)
|
||||
{
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder();
|
||||
builder.Services.AddSerilog();
|
||||
|
||||
// WPF UI: the page provider resolves pages from DI, the three services are the shell's (16 §Main window skeleton).
|
||||
builder.Services.AddNavigationViewPageProvider();
|
||||
builder.Services.AddSingleton<INavigationService, NavigationService>();
|
||||
builder.Services.AddSingleton<ISnackbarService, SnackbarService>();
|
||||
builder.Services.AddSingleton<IContentDialogService, ContentDialogService>();
|
||||
|
||||
// The ledger and the App's own settings (06_DATA_MODEL §Writer ownership: the App writes `settings`).
|
||||
builder.Services.AddSingleton(db);
|
||||
builder.Services.AddSingleton<ISettingsStore, SqliteSettingsStore>();
|
||||
builder.Services.AddSingleton(appearance);
|
||||
builder.Services.AddSingleton<IThemeApplier, WpfThemeApplier>();
|
||||
|
||||
// The Agent over the pipe (07_IPC §Client behavior): connect, start it when it is not there, tell the shell.
|
||||
builder.Services.AddSingleton<IAgentLauncher, AgentLauncher>();
|
||||
builder.Services.AddSingleton(static sp => new AgentConnection(
|
||||
sp.GetRequiredService<IAgentLauncher>(),
|
||||
static () => new PipeClient(),
|
||||
new AgentConnectionOptions(),
|
||||
UiIdentity.Version));
|
||||
builder.Services.AddHostedService<AgentConnectionHostedService>();
|
||||
|
||||
// The shell: the window is TRANSIENT because a language change rebuilds it (09_I18N §Mechanics); the
|
||||
// shell host tracks the live one. Pages and their view models are transient (16 §Navigation).
|
||||
builder.Services.AddSingleton<ShellHost>();
|
||||
builder.Services.AddTransient<MainWindow>();
|
||||
builder.Services.AddSingleton<MainWindowViewModel>();
|
||||
builder.Services.AddTransient<DashboardPage>();
|
||||
builder.Services.AddTransient<DashboardViewModel>();
|
||||
builder.Services.AddTransient<GamesPage>();
|
||||
builder.Services.AddTransient<GamesViewModel>();
|
||||
builder.Services.AddTransient<ComparePage>();
|
||||
builder.Services.AddTransient<CompareViewModel>();
|
||||
builder.Services.AddTransient<LogsPage>();
|
||||
builder.Services.AddTransient<LogsViewModel>();
|
||||
builder.Services.AddTransient<SettingsPage>();
|
||||
builder.Services.AddTransient<SettingsViewModel>();
|
||||
builder.Services.AddHostedService<ApplicationHostService>();
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
/// <summary><c>10_LOGGING</c> §Serilog configuration: <c>logs/ui-.log</c>, daily, 7 kept, 10 MB, the one template.</summary>
|
||||
private static void ConfigureLogging() =>
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.MinimumLevel.Information()
|
||||
.Enrich.WithProperty("Process", "ui")
|
||||
.WriteTo.File(
|
||||
Path.Combine(UiPaths.Logs, "ui-.log"),
|
||||
rollingInterval: RollingInterval.Day,
|
||||
retainedFileCountLimit: 7,
|
||||
fileSizeLimitBytes: 10 * 1024 * 1024,
|
||||
rollOnFileSizeLimit: true,
|
||||
formatProvider: CultureInfo.InvariantCulture,
|
||||
outputTemplate: "[{Timestamp:HH:mm:ss.fff} {Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}")
|
||||
.CreateLogger();
|
||||
|
||||
/// <summary><c>10_LOGGING</c> §Crash handling: every unhandled path is logged as Fatal. The dialog and the minidump are P4's.</summary>
|
||||
private void HookCrashHandlers()
|
||||
{
|
||||
DispatcherUnhandledException += OnDispatcherUnhandledException;
|
||||
AppDomain.CurrentDomain.UnhandledException += static (_, args) => Log.Fatal(args.ExceptionObject as Exception, "ui: unhandled exception (AppDomain)");
|
||||
TaskScheduler.UnobservedTaskException += static (_, args) => Log.Error(args.Exception, "ui: unobserved task exception");
|
||||
}
|
||||
|
||||
private static void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) =>
|
||||
Log.Fatal(e.Exception, "ui: unhandled exception (Dispatcher)");
|
||||
}
|
||||
@@ -4,6 +4,12 @@
|
||||
WPF UI (docs/08_UI.md). All XAML follows docs/16_WPFUI_SYNTAX.md — read it
|
||||
before writing any view. All user-visible strings come from .resx
|
||||
(docs/09_I18N.md); no string literals in XAML or C#.
|
||||
|
||||
The strongly-typed accessor Strings.Designer.cs is GENERATED from Strings.resx by
|
||||
tools/resx-gen.ps1 and committed; tools/resx-audit.ps1 (build.ps1 step 15) fails the
|
||||
build when it is stale or when Strings.vi.resx / Strings.ja.resx drift from the
|
||||
neutral key set. The SDK embeds the resx as FrameLedger.App.Strings.resources and
|
||||
builds the vi/ja satellites on its own (SatelliteResourceLanguages in Directory.Build.props).
|
||||
-->
|
||||
|
||||
<PropertyGroup>
|
||||
@@ -23,6 +29,11 @@
|
||||
<ProjectReference Include="..\FrameLedger.Shared\FrameLedger.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- The view models and services are internal-ish by intent; the test project pins them. -->
|
||||
<InternalsVisibleTo Include="FrameLedger.App.Tests" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="WPF-UI" />
|
||||
<PackageReference Include="WPF-UI.Abstractions" />
|
||||
|
||||
@@ -1,12 +1,103 @@
|
||||
<Window x:Class="FrameLedger.App.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FrameLedger.App"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
<ui:FluentWindow x:Class="FrameLedger.App.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:pages="clr-namespace:FrameLedger.App.Pages"
|
||||
xmlns:res="clr-namespace:FrameLedger.App"
|
||||
Title="{x:Static res:Strings.App_Title}"
|
||||
Width="1180"
|
||||
Height="760"
|
||||
MinWidth="800"
|
||||
MinHeight="520"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowCornerPreference="Round"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ui:TitleBar Grid.Row="0" Title="{x:Static res:Strings.App_Title}">
|
||||
<ui:TitleBar.TrailingContent>
|
||||
<ui:Badge Margin="0,0,12,0"
|
||||
VerticalAlignment="Center"
|
||||
Appearance="{Binding ViewModel.AgentStatusAppearance}"
|
||||
Content="{Binding ViewModel.AgentStatusText}" />
|
||||
</ui:TitleBar.TrailingContent>
|
||||
</ui:TitleBar>
|
||||
|
||||
<Menu Grid.Row="1">
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_File}">
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_File_AddGame}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_File_ImportLibrary}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_File_Export}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<Separator />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_File_Exit}" Command="{Binding ViewModel.ExitCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools}">
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools_AgentStatus}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools_UpdateRules}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools_VulkanLayer}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools_OpenDataFolder}" Command="{Binding ViewModel.OpenDataFolderCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Tools_DbMaintenance}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help}">
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_CheckUpdates}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_ReportBug}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_Documentation}" Command="{Binding ViewModel.NotYetCommand}" />
|
||||
<Separator />
|
||||
<MenuItem Header="{x:Static res:Strings.Menu_Help_About}" Command="{Binding ViewModel.AboutCommand}" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<!-- 08_UI §Notifications policy: "Agent offline" is in-app and PERSISTENT — an InfoBar with an action, never a toast. -->
|
||||
<ui:InfoBar Grid.Row="2"
|
||||
Margin="12,4,12,0"
|
||||
IsClosable="False"
|
||||
IsOpen="{Binding ViewModel.IsAgentBannerVisible}"
|
||||
Message="{Binding ViewModel.AgentBannerBody}"
|
||||
Severity="Warning"
|
||||
Title="{x:Static res:Strings.Agent_Banner_Offline_Title}">
|
||||
<ui:Button Appearance="Secondary"
|
||||
Command="{Binding ViewModel.RetryAgentCommand}"
|
||||
Content="{x:Static res:Strings.Agent_Banner_Retry}" />
|
||||
</ui:InfoBar>
|
||||
|
||||
<ui:NavigationView x:Name="RootNavigation"
|
||||
Grid.Row="3"
|
||||
IsBackButtonVisible="Collapsed"
|
||||
IsPaneToggleVisible="False"
|
||||
PaneDisplayMode="LeftFluent">
|
||||
<ui:NavigationView.MenuItems>
|
||||
<ui:NavigationViewItem Content="{x:Static res:Strings.Nav_Dashboard}"
|
||||
Icon="{ui:SymbolIcon Home24}"
|
||||
TargetPageType="{x:Type pages:DashboardPage}" />
|
||||
<ui:NavigationViewItem Content="{x:Static res:Strings.Nav_Games}"
|
||||
Icon="{ui:SymbolIcon Games24}"
|
||||
TargetPageType="{x:Type pages:GamesPage}" />
|
||||
<ui:NavigationViewItem Content="{x:Static res:Strings.Nav_Compare}"
|
||||
Icon="{ui:SymbolIcon ArrowSwap24}"
|
||||
TargetPageType="{x:Type pages:ComparePage}" />
|
||||
<ui:NavigationViewItem Content="{x:Static res:Strings.Nav_Logs}"
|
||||
Icon="{ui:SymbolIcon DocumentText24}"
|
||||
TargetPageType="{x:Type pages:LogsPage}" />
|
||||
</ui:NavigationView.MenuItems>
|
||||
<ui:NavigationView.FooterMenuItems>
|
||||
<ui:NavigationViewItem Content="{x:Static res:Strings.Nav_Settings}"
|
||||
Icon="{ui:SymbolIcon Settings24}"
|
||||
TargetPageType="{x:Type pages:SettingsPage}" />
|
||||
</ui:NavigationView.FooterMenuItems>
|
||||
</ui:NavigationView>
|
||||
|
||||
<ui:SnackbarPresenter x:Name="SnackbarPresenter" Grid.Row="3" VerticalAlignment="Bottom" />
|
||||
<ui:ContentDialogHost x:Name="DialogHost" Grid.Row="3" />
|
||||
</Grid>
|
||||
</Window>
|
||||
</ui:FluentWindow>
|
||||
@@ -1,21 +1,51 @@
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.ViewModels;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Abstractions;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App;
|
||||
|
||||
/// <summary>
|
||||
/// Shell window.
|
||||
/// The shell (P3 PR-2, <c>docs/08_UI.md</c> §Shell): wires the three WPF UI services to its own controls once,
|
||||
/// applies the theme (and with it the accent resources) before its XAML loads, and re-applies it from
|
||||
/// <c>Loaded</c> so the System watcher gets its HWND (<c>16_WPFUI_SYNTAX</c> §Gotchas).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Scaffold only. The real shell is a <c>ui:FluentWindow</c> with a custom
|
||||
/// <c>ui:TitleBar</c>, a classic <c>Menu</c> row **outside** the title bar's
|
||||
/// drag region, and a left <c>ui:NavigationView</c>
|
||||
/// (<c>docs/08_UI.md</c>, <c>docs/16_WPFUI_SYNTAX.md</c> §Main window skeleton).
|
||||
/// </remarks>
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainWindow : FluentWindow
|
||||
{
|
||||
/// <summary>Initializes the shell window.</summary>
|
||||
public MainWindow()
|
||||
public MainWindow(
|
||||
MainWindowViewModel viewModel,
|
||||
INavigationService navigation,
|
||||
ISnackbarService snackbar,
|
||||
IContentDialogService dialogs,
|
||||
INavigationViewPageProvider pages,
|
||||
IThemeApplier theme,
|
||||
AppearanceSettings appearance)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(navigation);
|
||||
ArgumentNullException.ThrowIfNull(snackbar);
|
||||
ArgumentNullException.ThrowIfNull(dialogs);
|
||||
ArgumentNullException.ThrowIfNull(pages);
|
||||
ArgumentNullException.ThrowIfNull(theme);
|
||||
ArgumentNullException.ThrowIfNull(appearance);
|
||||
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
|
||||
// Before the XAML loads: ApplicationThemeManager.Apply(…, updateAccent: true) is what registers the
|
||||
// SystemAccentColor* resources the control templates StaticResource at first Measure (measured 2026-09-13:
|
||||
// without it the first Show() throws XamlParseException "Cannot find resource named
|
||||
// 'SystemAccentColorPrimary'"). The watcher half needs the HWND and runs from Loaded.
|
||||
theme.Apply(appearance.Theme, null);
|
||||
InitializeComponent();
|
||||
|
||||
RootNavigation.SetPageProviderService(pages);
|
||||
navigation.SetNavigationControl(RootNavigation);
|
||||
snackbar.SetSnackbarPresenter(SnackbarPresenter);
|
||||
dialogs.SetDialogHost(DialogHost);
|
||||
|
||||
Loaded += (_, _) => theme.Apply(appearance.Theme, this);
|
||||
}
|
||||
|
||||
public MainWindowViewModel ViewModel { get; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<Page x:Class="FrameLedger.App.Pages.ComparePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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.Compare_Header}">
|
||||
<StackPanel Style="{StaticResource PageRoot}">
|
||||
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:CompareViewModel.Header}" />
|
||||
<ui:TextBlock Margin="0,16,0,0" Appearance="Secondary" Text="{x:Static vm:CompareViewModel.EmptyText}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Page>
|
||||
@@ -0,0 +1,16 @@
|
||||
using FrameLedger.App.ViewModels;
|
||||
using Wpf.Ui.Abstractions.Controls;
|
||||
|
||||
namespace FrameLedger.App.Pages;
|
||||
|
||||
public partial class ComparePage : INavigableView<CompareViewModel>
|
||||
{
|
||||
public ComparePage(CompareViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public CompareViewModel ViewModel { get; }
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<Page x:Class="FrameLedger.App.Pages.DashboardPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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.Dashboard_Header}">
|
||||
<ScrollViewer>
|
||||
<StackPanel Style="{StaticResource PageRoot}">
|
||||
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:DashboardViewModel.Header}" />
|
||||
|
||||
<!-- 08_UI §Dashboard: the Agent status card. Every value reads N/A until the Agent answered. -->
|
||||
<ui:Card Margin="0,16,0,0" HorizontalAlignment="Stretch">
|
||||
<StackPanel>
|
||||
<ui:TextBlock FontTypography="Subtitle" Margin="0,0,0,12" Text="{x:Static vm:DashboardViewModel.AgentHeader}" />
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource FieldLabel}" Text="{x:Static res:Strings.Dashboard_Agent_State}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource FieldValue}" Text="{Binding ViewModel.AgentState}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource FieldLabel}" Text="{x:Static res:Strings.Dashboard_Agent_Version}" />
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Style="{StaticResource FieldValue}" Text="{Binding ViewModel.AgentVersion}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource FieldLabel}" Text="{x:Static res:Strings.Dashboard_Agent_Telemetry}" />
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Style="{StaticResource FieldValue}" Text="{Binding ViewModel.TelemetrySource}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Style="{StaticResource FieldLabel}" Text="{x:Static res:Strings.Dashboard_Agent_Overlay}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Style="{StaticResource FieldValue}" Text="{Binding ViewModel.OverlayBuildId}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Style="{StaticResource FieldLabel}" Text="{x:Static res:Strings.Dashboard_Agent_Elevated}" />
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Style="{StaticResource FieldValue}" Text="{Binding ViewModel.Elevated}" />
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" Style="{StaticResource FieldLabel}" Text="{x:Static res:Strings.Dashboard_Agent_Sessions}" />
|
||||
<TextBlock Grid.Row="5" Grid.Column="1" Style="{StaticResource FieldValue}" Text="{Binding ViewModel.RunningSessions}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ui:Card>
|
||||
|
||||
<ui:TextBlock Margin="0,24,0,0"
|
||||
Appearance="Secondary"
|
||||
Text="{x:Static vm:DashboardViewModel.EmptyText}"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
@@ -0,0 +1,16 @@
|
||||
using FrameLedger.App.ViewModels;
|
||||
using Wpf.Ui.Abstractions.Controls;
|
||||
|
||||
namespace FrameLedger.App.Pages;
|
||||
|
||||
public partial class DashboardPage : INavigableView<DashboardViewModel>
|
||||
{
|
||||
public DashboardPage(DashboardViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public DashboardViewModel ViewModel { get; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<Page x:Class="FrameLedger.App.Pages.GamesPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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.Games_Header}">
|
||||
<StackPanel Style="{StaticResource PageRoot}">
|
||||
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:GamesViewModel.Header}" />
|
||||
<ui:TextBlock Margin="0,16,0,0" Appearance="Secondary" Text="{x:Static vm:GamesViewModel.EmptyText}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Page>
|
||||
@@ -0,0 +1,16 @@
|
||||
using FrameLedger.App.ViewModels;
|
||||
using Wpf.Ui.Abstractions.Controls;
|
||||
|
||||
namespace FrameLedger.App.Pages;
|
||||
|
||||
public partial class GamesPage : INavigableView<GamesViewModel>
|
||||
{
|
||||
public GamesPage(GamesViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public GamesViewModel ViewModel { get; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<Page x:Class="FrameLedger.App.Pages.LogsPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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}">
|
||||
<StackPanel Style="{StaticResource PageRoot}">
|
||||
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:LogsViewModel.Header}" />
|
||||
<ui:TextBlock Margin="0,16,0,0" Appearance="Secondary" Text="{x:Static vm:LogsViewModel.EmptyText}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Page>
|
||||
@@ -0,0 +1,16 @@
|
||||
using FrameLedger.App.ViewModels;
|
||||
using Wpf.Ui.Abstractions.Controls;
|
||||
|
||||
namespace FrameLedger.App.Pages;
|
||||
|
||||
public partial class LogsPage : INavigableView<LogsViewModel>
|
||||
{
|
||||
public LogsPage(LogsViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public LogsViewModel ViewModel { get; }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<Page x:Class="FrameLedger.App.Pages.SettingsPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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>
|
||||
<StackPanel Style="{StaticResource PageRoot}">
|
||||
<ui:TextBlock FontTypography="Title" Text="{x:Static vm:SettingsViewModel.Header}" />
|
||||
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static vm:SettingsViewModel.AppearanceHeader}" />
|
||||
|
||||
<!-- 08_UI §Settings: the WPF UI settings idiom — CardControl rows. -->
|
||||
<ui:CardControl Margin="0,4,0,0" Header="{x:Static vm:SettingsViewModel.ThemeLabel}" Icon="{ui:SymbolIcon Color24}">
|
||||
<ComboBox MinWidth="180"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:SettingsViewModel.Themes}"
|
||||
SelectedValue="{Binding ViewModel.SelectedTheme, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</ui:CardControl>
|
||||
|
||||
<ui:CardControl Margin="0,8,0,0" Header="{x:Static vm:SettingsViewModel.LanguageLabel}" Icon="{ui:SymbolIcon LocalLanguage24}">
|
||||
<ComboBox MinWidth="180"
|
||||
DisplayMemberPath="Label"
|
||||
ItemsSource="{x:Static vm:SettingsViewModel.Languages}"
|
||||
SelectedValue="{Binding ViewModel.SelectedLanguage, Mode=TwoWay}"
|
||||
SelectedValuePath="Value" />
|
||||
</ui:CardControl>
|
||||
<ui:TextBlock Margin="0,6,0,0" Appearance="Secondary" Text="{x:Static vm:SettingsViewModel.LanguageNote}" TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Page>
|
||||
@@ -0,0 +1,16 @@
|
||||
using FrameLedger.App.ViewModels;
|
||||
using Wpf.Ui.Abstractions.Controls;
|
||||
|
||||
namespace FrameLedger.App.Pages;
|
||||
|
||||
public partial class SettingsPage : INavigableView<SettingsViewModel>
|
||||
{
|
||||
public SettingsPage(SettingsViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public SettingsViewModel ViewModel { get; }
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
using System.IO;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
using Serilog;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The App's end of the pipe as a long-running state machine (<c>07_IPC</c> §Client behavior): a connect
|
||||
/// round of <see cref="AgentConnectionOptions.ConnectAttempts"/> × backoff; on failure start the Agent beside
|
||||
/// this executable and try again; then <c>Hello</c>, <c>GetStatus</c>, keepalive pings, and the event stream
|
||||
/// until the pipe drops — then the next round. "Treat the pipe as unreliable": everything persisted comes from
|
||||
/// SQLite, and this class only ever degrades the live status.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Runs on the thread pool; <see cref="Changed"/> and <see cref="EventReceived"/> fire there, and a view model
|
||||
/// marshals to the dispatcher. Nothing here touches WPF.
|
||||
/// </remarks>
|
||||
public sealed class AgentConnection : IAsyncDisposable
|
||||
{
|
||||
private readonly IAgentLauncher _launcher;
|
||||
private readonly Func<PipeClient> _pipes;
|
||||
private readonly AgentConnectionOptions _options;
|
||||
private readonly string _appVersion;
|
||||
private readonly Lock _lock = new();
|
||||
private readonly SemaphoreSlim _retryNow = new(0);
|
||||
private PipeClient? _client;
|
||||
private long _rounds;
|
||||
private long _launches;
|
||||
|
||||
public AgentConnection(IAgentLauncher launcher, Func<PipeClient> pipes, AgentConnectionOptions options, string appVersion)
|
||||
{
|
||||
_launcher = launcher ?? throw new ArgumentNullException(nameof(launcher));
|
||||
_pipes = pipes ?? throw new ArgumentNullException(nameof(pipes));
|
||||
_options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
_appVersion = appVersion ?? throw new ArgumentNullException(nameof(appVersion));
|
||||
}
|
||||
|
||||
public event EventHandler? Changed;
|
||||
|
||||
/// <summary>Every Agent → UI event, as it arrives; the payload is decoded by whoever needs it.</summary>
|
||||
public event EventHandler<AgentEventArgs>? EventReceived;
|
||||
|
||||
public AgentConnectionState State { get; private set; } = AgentConnectionState.Connecting;
|
||||
|
||||
public HelloAck? Hello { get; private set; }
|
||||
|
||||
public StatusAck? Status { get; private set; }
|
||||
|
||||
/// <summary>Connect rounds completed (a test's clock).</summary>
|
||||
public long Rounds => Interlocked.Read(ref _rounds);
|
||||
|
||||
/// <summary>How many times the Agent was started from beside this executable.</summary>
|
||||
public long Launches => Interlocked.Read(ref _launches);
|
||||
|
||||
/// <summary>Skip the wait before the next round (the banner's Retry).</summary>
|
||||
public void RetryNow() => _retryNow.Release();
|
||||
|
||||
/// <summary>Loop until cancelled.</summary>
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
await RoundAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interlocked.Increment(ref _rounds);
|
||||
}
|
||||
|
||||
await WaitForRetryAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Ask the Agent for its status now; null when not connected or when the request failed.</summary>
|
||||
public async Task<StatusAck?> RefreshStatusAsync(CancellationToken ct = default)
|
||||
{
|
||||
PipeClient? client = _client;
|
||||
if (client is null || State != AgentConnectionState.Connected)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
StatusAck status = await client.GetStatusAsync(_options.RequestTimeout, ct).ConfigureAwait(false);
|
||||
Set(AgentConnectionState.Connected, Hello, status);
|
||||
return status;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or TimeoutException or IpcRequestException or ObjectDisposedException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
PipeClient? client = Interlocked.Exchange(ref _client, null);
|
||||
if (client is not null)
|
||||
{
|
||||
await client.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
_retryNow.Dispose();
|
||||
}
|
||||
|
||||
private async Task RoundAsync(CancellationToken ct)
|
||||
{
|
||||
Set(AgentConnectionState.Connecting, null, null);
|
||||
PipeClient? client = await TryConnectAsync(ct).ConfigureAwait(false);
|
||||
if (client is null && _launcher.CanLaunch)
|
||||
{
|
||||
Set(AgentConnectionState.Starting, null, null);
|
||||
if (_launcher.TryStart())
|
||||
{
|
||||
Interlocked.Increment(ref _launches);
|
||||
client = await TryConnectAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (client is null)
|
||||
{
|
||||
Set(_launcher.CanLaunch ? AgentConnectionState.Offline : AgentConnectionState.Missing, null, null);
|
||||
return;
|
||||
}
|
||||
|
||||
_client = client;
|
||||
try
|
||||
{
|
||||
HelloAck hello = await client.HelloAsync(_appVersion, _options.RequestTimeout, ct).ConfigureAwait(false);
|
||||
StatusAck status = await client.GetStatusAsync(_options.RequestTimeout, ct).ConfigureAwait(false);
|
||||
Set(AgentConnectionState.Connected, hello, status);
|
||||
Log.Information("agent: connected (agent {Version}, pid {Pid}, telemetry {Telemetry})", hello.AgentVersion, hello.Pid, hello.TelemetrySource);
|
||||
await PumpAsync(client, ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or TimeoutException or IpcRequestException or ObjectDisposedException or IpcFramingException)
|
||||
{
|
||||
Log.Warning("agent: connection lost ({Kind}: {Message})", ex.GetType().Name, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_client = null;
|
||||
await client.DisposeAsync().ConfigureAwait(false);
|
||||
Set(AgentConnectionState.Offline, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<PipeClient?> TryConnectAsync(CancellationToken ct)
|
||||
{
|
||||
for (int attempt = 0; attempt < _options.ConnectAttempts; attempt++)
|
||||
{
|
||||
PipeClient client = _pipes();
|
||||
try
|
||||
{
|
||||
await client.ConnectAsync(_options.ConnectTimeout, ct).ConfigureAwait(false);
|
||||
return client;
|
||||
}
|
||||
catch (Exception ex) when (ex is TimeoutException or IOException or UnauthorizedAccessException)
|
||||
{
|
||||
await client.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await Task.Delay(_options.ConnectBackoff, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Events until the pipe drops, with a keepalive ping whenever the stream has been quiet for the interval.</summary>
|
||||
private async Task PumpAsync(PipeClient client, CancellationToken ct)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
ValueTask<IpcEnvelope> read = client.Events.ReadAsync(ct);
|
||||
Task<IpcEnvelope> readTask = read.AsTask();
|
||||
Task first = await Task.WhenAny(readTask, Task.Delay(_options.Keepalive, ct)).ConfigureAwait(false);
|
||||
if (first != readTask)
|
||||
{
|
||||
await client.PingAsync(_options.RequestTimeout, ct).ConfigureAwait(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
IpcEnvelope envelope;
|
||||
try
|
||||
{
|
||||
envelope = await readTask.ConfigureAwait(false);
|
||||
}
|
||||
catch (System.Threading.Channels.ChannelClosedException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EventReceived?.Invoke(this, new AgentEventArgs(envelope));
|
||||
}
|
||||
}
|
||||
|
||||
private async Task WaitForRetryAsync(CancellationToken ct)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _retryNow.WaitAsync(_options.RetryInterval, ct).ConfigureAwait(false);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void Set(AgentConnectionState state, HelloAck? hello, StatusAck? status)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
State = state;
|
||||
Hello = hello;
|
||||
Status = status;
|
||||
}
|
||||
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>Runs <see cref="AgentConnection"/> for the life of the host.</summary>
|
||||
internal sealed class AgentConnectionHostedService(AgentConnection connection) : BackgroundService
|
||||
{
|
||||
protected override Task ExecuteAsync(CancellationToken stoppingToken) => connection.RunAsync(stoppingToken);
|
||||
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await base.StopAsync(cancellationToken).ConfigureAwait(false);
|
||||
await connection.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary><c>07_IPC</c> §Client behavior's numbers, overridable so a test does not wait on the product's clock.</summary>
|
||||
public sealed record AgentConnectionOptions
|
||||
{
|
||||
/// <summary>"Connect with 250 ms × 8 backoff".</summary>
|
||||
public int ConnectAttempts { get; init; } = 8;
|
||||
|
||||
public TimeSpan ConnectBackoff { get; init; } = TimeSpan.FromMilliseconds(250);
|
||||
|
||||
public TimeSpan ConnectTimeout { get; init; } = TimeSpan.FromSeconds(2);
|
||||
|
||||
/// <summary>After a round that found no Agent (started or not): how long before the next round.</summary>
|
||||
public TimeSpan RetryInterval { get; init; } = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary><c>Ping</c> cadence while connected (07_IPC: 15 s keepalive, client-driven).</summary>
|
||||
public TimeSpan Keepalive { get; init; } = TimeSpan.FromSeconds(15);
|
||||
|
||||
public TimeSpan RequestTimeout { get; init; } = TimeSpan.FromSeconds(10);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>What the status pill and the banner show (08_UI §Shell: "Agent state shown as a pill").</summary>
|
||||
public enum AgentConnectionState
|
||||
{
|
||||
/// <summary>A connect round is in progress.</summary>
|
||||
Connecting = 0,
|
||||
|
||||
/// <summary>No Agent answered; it was started from beside this executable and a new round runs.</summary>
|
||||
Starting,
|
||||
|
||||
/// <summary><c>Hello</c> answered.</summary>
|
||||
Connected,
|
||||
|
||||
/// <summary>An Agent exists beside this executable and is not answering; rounds continue.</summary>
|
||||
Offline,
|
||||
|
||||
/// <summary>No Agent executable is beside this one; nothing to start, rounds continue in case one appears.</summary>
|
||||
Missing,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>One Agent → UI event off the pipe, undecoded: the envelope's <c>type</c> says which record the payload is.</summary>
|
||||
public sealed class AgentEventArgs(IpcEnvelope envelope) : EventArgs
|
||||
{
|
||||
public IpcEnvelope Envelope { get; } = envelope ?? throw new ArgumentNullException(nameof(envelope));
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Serilog;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>Starts the Agent beside this executable, as its own process — it must outlive the App (background capture).</summary>
|
||||
public sealed class AgentLauncher : IAgentLauncher
|
||||
{
|
||||
private static string AgentPath => Path.Combine(AppContext.BaseDirectory, "FrameLedger.Agent.exe");
|
||||
|
||||
public bool CanLaunch => File.Exists(AgentPath);
|
||||
|
||||
public bool TryStart()
|
||||
{
|
||||
if (!CanLaunch)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using Process? started = Process.Start(new ProcessStartInfo(AgentPath, "--serve")
|
||||
{
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
WorkingDirectory = AppContext.BaseDirectory,
|
||||
});
|
||||
Log.Information("agent: started {Path} --serve (pid {Pid})", AgentPath, started?.Id);
|
||||
return started is not null;
|
||||
}
|
||||
catch (Exception ex) when (ex is Win32Exception or InvalidOperationException or IOException)
|
||||
{
|
||||
Log.Warning(ex, "agent: could not start {Path}", AgentPath);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>How the pill and the banner show <see cref="AgentConnectionState"/> — one table, so the view models agree.</summary>
|
||||
public static class AgentStatusPresentation
|
||||
{
|
||||
/// <summary>The pill's text and colour.</summary>
|
||||
public static (string Text, ControlAppearance Appearance) Pill(AgentConnectionState state) => state switch
|
||||
{
|
||||
AgentConnectionState.Connected => (Strings.Agent_State_Connected, ControlAppearance.Success),
|
||||
AgentConnectionState.Connecting => (Strings.Agent_State_Connecting, ControlAppearance.Info),
|
||||
AgentConnectionState.Starting => (Strings.Agent_State_Starting, ControlAppearance.Info),
|
||||
AgentConnectionState.Offline => (Strings.Agent_State_Offline, ControlAppearance.Caution),
|
||||
AgentConnectionState.Missing => (Strings.Agent_State_Missing, ControlAppearance.Danger),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(state), state, "not a connection state"),
|
||||
};
|
||||
|
||||
/// <summary>The persistent <c>InfoBar</c>'s body (08_UI §Notifications: "Agent offline" is in-app, persistent), or null when no banner is due.</summary>
|
||||
public static string? Banner(AgentConnectionState state) => state switch
|
||||
{
|
||||
AgentConnectionState.Offline => Strings.Agent_Banner_Offline_Body,
|
||||
AgentConnectionState.Missing => Strings.Agent_Banner_Missing_Body,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>FR-10's theme choice, as <c>settings.ui.theme</c> stores it.</summary>
|
||||
public enum AppTheme
|
||||
{
|
||||
System = 0,
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The two appearance keys of the settings registry (HANDOFF §P3 decision D16): <c>ui.theme</c> —
|
||||
/// <c>system</c> · <c>light</c> · <c>dark</c> — and <c>ui.language</c> — <c>en</c> · <c>vi</c> · <c>ja</c>.
|
||||
/// Read once at startup (before any window, because resources are read at XAML load), written by the Settings
|
||||
/// page. The App owns <c>settings</c> under <c>06_DATA_MODEL</c> §Writer ownership.
|
||||
/// </summary>
|
||||
public sealed class AppearanceSettings(ISettingsStore settings)
|
||||
{
|
||||
public const string ThemeKey = "ui.theme";
|
||||
public const string LanguageKey = "ui.language";
|
||||
|
||||
public static IReadOnlyList<string> Languages { get; } = ["en", "vi", "ja"];
|
||||
|
||||
public AppTheme Theme { get; private set; } = AppTheme.System;
|
||||
|
||||
public string Language { get; private set; } = "en";
|
||||
|
||||
public async Task LoadAsync(CancellationToken ct = default)
|
||||
{
|
||||
Theme = ParseTheme(await settings.GetAsync(ThemeKey, ct).ConfigureAwait(false));
|
||||
Language = ParseLanguage(await settings.GetAsync(LanguageKey, ct).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
public async Task SetThemeAsync(AppTheme theme, CancellationToken ct = default)
|
||||
{
|
||||
Theme = theme;
|
||||
await settings.SetAsync(ThemeKey, ThemeText(theme), ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task SetLanguageAsync(string language, CancellationToken ct = default)
|
||||
{
|
||||
Language = ParseLanguage(language);
|
||||
await settings.SetAsync(LanguageKey, Language, ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>An unknown or absent value is the default, never an exception: a hand-edited row must not stop the App.</summary>
|
||||
public static AppTheme ParseTheme(string? value) => value switch
|
||||
{
|
||||
"light" => AppTheme.Light,
|
||||
"dark" => AppTheme.Dark,
|
||||
_ => AppTheme.System,
|
||||
};
|
||||
|
||||
public static string ThemeText(AppTheme theme) => theme switch
|
||||
{
|
||||
AppTheme.Light => "light",
|
||||
AppTheme.Dark => "dark",
|
||||
_ => "system",
|
||||
};
|
||||
|
||||
public static string ParseLanguage(string? value) =>
|
||||
value is not null && Languages.Contains(value, StringComparer.Ordinal) ? value : "en";
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Windows;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>Shows the shell once the host is up (the WPF UI template's idiom, under our own <see cref="ShellHost"/>).</summary>
|
||||
internal sealed class ApplicationHostService(ShellHost shell) : IHostedService
|
||||
{
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (System.Windows.Application.Current.Windows.OfType<MainWindow>().Any())
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
shell.Show();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// <c>07_IPC</c> §Client behavior: "on failure start the Agent, retry". The Agent is the one beside this
|
||||
/// executable — <c>12_BUILD</c> publishes both roots into one directory — and nothing else; the App never
|
||||
/// searches for one.
|
||||
/// </summary>
|
||||
public interface IAgentLauncher
|
||||
{
|
||||
/// <summary>Whether an Agent executable is beside this one at all.</summary>
|
||||
bool CanLaunch { get; }
|
||||
|
||||
/// <summary>Start <c>FrameLedger.Agent.exe --serve</c>, detached; false when it could not be started.</summary>
|
||||
bool TryStart();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The WPF UI theme calls behind a seam, so a view model is testable without an <c>Application</c>
|
||||
/// (<c>ApplicationThemeManager</c> touches <c>Application.Current.Resources</c>).
|
||||
/// </summary>
|
||||
public interface IThemeApplier
|
||||
{
|
||||
/// <summary>Apply <paramref name="theme"/>; <paramref name="window"/> is watched for system changes when the choice is System, and unwatched otherwise.</summary>
|
||||
void Apply(AppTheme theme, Window? window);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Pages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Wpf.Ui;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Owns the live <see cref="MainWindow"/>: shows the first one, rebuilds it on a language change
|
||||
/// (<c>09_I18N</c> §Mechanics: "re-create the main window shell; state preserved via VM"), and turns the
|
||||
/// user closing the live one into a host shutdown. The window is a transient service so a rebuild is a fresh
|
||||
/// XAML load in the new culture; the application's <c>ShutdownMode</c> is explicit so that closing the OLD
|
||||
/// window of a rebuild does not end the process.
|
||||
/// </summary>
|
||||
public sealed class ShellHost(IServiceProvider services, INavigationService navigation, IHostApplicationLifetime lifetime)
|
||||
{
|
||||
private MainWindow? _current;
|
||||
private Type _page = typeof(DashboardPage);
|
||||
|
||||
public void Show()
|
||||
{
|
||||
MainWindow window = services.GetRequiredService<MainWindow>();
|
||||
window.Closed += OnClosed;
|
||||
_current = window;
|
||||
window.Show();
|
||||
navigation.Navigate(_page);
|
||||
}
|
||||
|
||||
/// <summary>The page the shell will open on, kept across a rebuild.</summary>
|
||||
public void Remember(Type page) => _page = page;
|
||||
|
||||
/// <summary>A new window in the current UI culture; the old one closes after the new one is up.</summary>
|
||||
public void Rebuild()
|
||||
{
|
||||
MainWindow? old = _current;
|
||||
Show();
|
||||
old?.Close();
|
||||
}
|
||||
|
||||
public Window? Current => _current;
|
||||
|
||||
private void OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
// Only the live window's close is the user leaving; a rebuild's old window is not.
|
||||
if (ReferenceEquals(sender, _current))
|
||||
{
|
||||
_current = null;
|
||||
lifetime.StopApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>What the App says about itself in <c>Hello</c> and in About.</summary>
|
||||
internal static class UiIdentity
|
||||
{
|
||||
public static string Version { get; } =
|
||||
typeof(UiIdentity).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
|
||||
?? typeof(UiIdentity).Assembly.GetName().Version?.ToString()
|
||||
?? "0.0.0";
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.IO;
|
||||
using FrameLedger.Infrastructure.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Where the App reads and logs: the Agent's data directory (<c>01_ARCHITECTURE</c> §Data directory —
|
||||
/// <c>ledger.db</c> beside <c>logs\ui-*.log</c>). The App never chooses another location; the ledger is the
|
||||
/// Agent's, and <c>06_DATA_MODEL</c> §Writer ownership says which tables the App may write.
|
||||
/// </summary>
|
||||
internal static class UiPaths
|
||||
{
|
||||
public static string DataDirectory => LedgerPaths.DefaultDirectory;
|
||||
|
||||
public static string Database => LedgerPaths.DefaultDatabase;
|
||||
|
||||
public static string Logs => Path.Combine(DataDirectory, "logs");
|
||||
|
||||
public static void EnsureDirectories()
|
||||
{
|
||||
Directory.CreateDirectory(DataDirectory);
|
||||
Directory.CreateDirectory(Logs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The thread a view model was built on, captured as its <see cref="SynchronizationContext"/>: the pipe's
|
||||
/// events arrive on the thread pool, and property changes have to land on the dispatcher. Under WPF the
|
||||
/// context is the dispatcher's; in a test without one the action runs inline, so a view model can be exercised
|
||||
/// with no <c>Application</c> at all.
|
||||
/// </summary>
|
||||
public sealed class UiThread
|
||||
{
|
||||
private readonly SynchronizationContext? _context = SynchronizationContext.Current;
|
||||
|
||||
[SuppressMessage("Usage", "VSTHRD001:Avoid legacy thread switching APIs", Justification = "a WPF application has no JoinableTaskFactory; posting to the captured context is the documented way to reach the dispatcher from the thread pool, and it never blocks")]
|
||||
public void Post(Action action)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(action);
|
||||
if (_context is null)
|
||||
{
|
||||
action();
|
||||
return;
|
||||
}
|
||||
|
||||
_context.Post(static state => ((Action)state!)(), action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Windows;
|
||||
using Wpf.Ui.Appearance;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// <c>16_WPFUI_SYNTAX</c> §Theme rules: manual Light/Dark through <c>ApplicationThemeManager.Apply</c>; System
|
||||
/// through <c>SystemThemeWatcher.Watch</c> on the window — which needs an HWND, so the caller passes the window
|
||||
/// from its <c>Loaded</c> handler and never from a constructor — and <c>UnWatch</c> when switching to manual.
|
||||
/// </summary>
|
||||
public sealed class WpfThemeApplier : IThemeApplier
|
||||
{
|
||||
public void Apply(AppTheme theme, Window? window)
|
||||
{
|
||||
switch (theme)
|
||||
{
|
||||
case AppTheme.System:
|
||||
ApplicationThemeManager.Apply(SystemIsDark() ? ApplicationTheme.Dark : ApplicationTheme.Light, WindowBackdropType.Mica, true);
|
||||
if (window is { IsLoaded: true })
|
||||
{
|
||||
SystemThemeWatcher.Watch(window, WindowBackdropType.Mica, true);
|
||||
}
|
||||
|
||||
break;
|
||||
case AppTheme.Light:
|
||||
case AppTheme.Dark:
|
||||
if (window is not null)
|
||||
{
|
||||
SystemThemeWatcher.UnWatch(window);
|
||||
}
|
||||
|
||||
ApplicationThemeManager.Apply(theme == AppTheme.Dark ? ApplicationTheme.Dark : ApplicationTheme.Light, WindowBackdropType.Mica, true);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(theme), theme, "not a theme");
|
||||
}
|
||||
}
|
||||
|
||||
private static bool SystemIsDark() => ApplicationThemeManager.GetSystemTheme() is SystemTheme.Dark or SystemTheme.HCBlack or SystemTheme.Glow or SystemTheme.CapturedMotion;
|
||||
}
|
||||
Generated
+225
@@ -0,0 +1,225 @@
|
||||
// <auto-generated>
|
||||
// Generated by tools/resx-gen.ps1 from Strings.resx. DO NOT EDIT BY HAND:
|
||||
// run the tool, or `./build.ps1 check` will fail the resx-audit gate on the drift.
|
||||
// </auto-generated>
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
|
||||
namespace FrameLedger.App;
|
||||
|
||||
/// <summary>The user-visible strings (docs/09_I18N.md), one property per key, read through the current UI culture.</summary>
|
||||
[GeneratedCode("tools/resx-gen.ps1", "1")]
|
||||
public static class Strings
|
||||
{
|
||||
private static ResourceManager? _resourceManager;
|
||||
|
||||
/// <summary>The culture the properties read with; null means the current UI culture.</summary>
|
||||
public static CultureInfo? Culture { get; set; }
|
||||
|
||||
public static ResourceManager ResourceManager =>
|
||||
_resourceManager ??= new ResourceManager("FrameLedger.App.Strings", typeof(Strings).Assembly);
|
||||
|
||||
/// <summary>Every key, for an audit that walks them.</summary>
|
||||
public static IReadOnlyList<string> Keys { get; } =
|
||||
[
|
||||
nameof(About_Body_Format),
|
||||
nameof(About_Title),
|
||||
nameof(Agent_Banner_Missing_Body),
|
||||
nameof(Agent_Banner_Offline_Body),
|
||||
nameof(Agent_Banner_Offline_Title),
|
||||
nameof(Agent_Banner_Retry),
|
||||
nameof(Agent_State_Connected),
|
||||
nameof(Agent_State_Connecting),
|
||||
nameof(Agent_State_Missing),
|
||||
nameof(Agent_State_Offline),
|
||||
nameof(Agent_State_Starting),
|
||||
nameof(App_Title),
|
||||
nameof(Common_Cancel),
|
||||
nameof(Common_No),
|
||||
nameof(Common_NotAvailable),
|
||||
nameof(Common_Ok),
|
||||
nameof(Common_Yes),
|
||||
nameof(Compare_Empty),
|
||||
nameof(Compare_Header),
|
||||
nameof(Crash_Body),
|
||||
nameof(Crash_Title),
|
||||
nameof(Dashboard_Agent_Elevated),
|
||||
nameof(Dashboard_Agent_Header),
|
||||
nameof(Dashboard_Agent_Overlay),
|
||||
nameof(Dashboard_Agent_Sessions),
|
||||
nameof(Dashboard_Agent_State),
|
||||
nameof(Dashboard_Agent_Telemetry),
|
||||
nameof(Dashboard_Agent_Version),
|
||||
nameof(Dashboard_Empty),
|
||||
nameof(Dashboard_Header),
|
||||
nameof(Games_Empty),
|
||||
nameof(Games_Header),
|
||||
nameof(Logs_Empty),
|
||||
nameof(Logs_Header),
|
||||
nameof(Menu_File),
|
||||
nameof(Menu_File_AddGame),
|
||||
nameof(Menu_File_Exit),
|
||||
nameof(Menu_File_Export),
|
||||
nameof(Menu_File_ImportLibrary),
|
||||
nameof(Menu_Help),
|
||||
nameof(Menu_Help_About),
|
||||
nameof(Menu_Help_CheckUpdates),
|
||||
nameof(Menu_Help_Documentation),
|
||||
nameof(Menu_Help_ReportBug),
|
||||
nameof(Menu_Tools),
|
||||
nameof(Menu_Tools_AgentStatus),
|
||||
nameof(Menu_Tools_DbMaintenance),
|
||||
nameof(Menu_Tools_OpenDataFolder),
|
||||
nameof(Menu_Tools_UpdateRules),
|
||||
nameof(Menu_Tools_VulkanLayer),
|
||||
nameof(Nav_Compare),
|
||||
nameof(Nav_Dashboard),
|
||||
nameof(Nav_Games),
|
||||
nameof(Nav_Logs),
|
||||
nameof(Nav_Settings),
|
||||
nameof(NotYet_Body),
|
||||
nameof(NotYet_Title),
|
||||
nameof(Settings_Appearance_Header),
|
||||
nameof(Settings_Header),
|
||||
nameof(Settings_Language_Label),
|
||||
nameof(Settings_Language_Note),
|
||||
nameof(Settings_Theme_Dark),
|
||||
nameof(Settings_Theme_Label),
|
||||
nameof(Settings_Theme_Light),
|
||||
nameof(Settings_Theme_System),
|
||||
];
|
||||
|
||||
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);
|
||||
|
||||
public static string Agent_Banner_Missing_Body => ResourceManager.GetString(nameof(Agent_Banner_Missing_Body), Culture) ?? nameof(Agent_Banner_Missing_Body);
|
||||
|
||||
public static string Agent_Banner_Offline_Body => ResourceManager.GetString(nameof(Agent_Banner_Offline_Body), Culture) ?? nameof(Agent_Banner_Offline_Body);
|
||||
|
||||
public static string Agent_Banner_Offline_Title => ResourceManager.GetString(nameof(Agent_Banner_Offline_Title), Culture) ?? nameof(Agent_Banner_Offline_Title);
|
||||
|
||||
public static string Agent_Banner_Retry => ResourceManager.GetString(nameof(Agent_Banner_Retry), Culture) ?? nameof(Agent_Banner_Retry);
|
||||
|
||||
public static string Agent_State_Connected => ResourceManager.GetString(nameof(Agent_State_Connected), Culture) ?? nameof(Agent_State_Connected);
|
||||
|
||||
public static string Agent_State_Connecting => ResourceManager.GetString(nameof(Agent_State_Connecting), Culture) ?? nameof(Agent_State_Connecting);
|
||||
|
||||
public static string Agent_State_Missing => ResourceManager.GetString(nameof(Agent_State_Missing), Culture) ?? nameof(Agent_State_Missing);
|
||||
|
||||
public static string Agent_State_Offline => ResourceManager.GetString(nameof(Agent_State_Offline), Culture) ?? nameof(Agent_State_Offline);
|
||||
|
||||
public static string Agent_State_Starting => ResourceManager.GetString(nameof(Agent_State_Starting), Culture) ?? nameof(Agent_State_Starting);
|
||||
|
||||
public static string App_Title => ResourceManager.GetString(nameof(App_Title), Culture) ?? nameof(App_Title);
|
||||
|
||||
public static string Common_Cancel => ResourceManager.GetString(nameof(Common_Cancel), Culture) ?? nameof(Common_Cancel);
|
||||
|
||||
public static string Common_No => ResourceManager.GetString(nameof(Common_No), Culture) ?? nameof(Common_No);
|
||||
|
||||
public static string Common_NotAvailable => ResourceManager.GetString(nameof(Common_NotAvailable), Culture) ?? nameof(Common_NotAvailable);
|
||||
|
||||
public static string Common_Ok => ResourceManager.GetString(nameof(Common_Ok), Culture) ?? nameof(Common_Ok);
|
||||
|
||||
public static string Common_Yes => ResourceManager.GetString(nameof(Common_Yes), Culture) ?? nameof(Common_Yes);
|
||||
|
||||
public static string Compare_Empty => ResourceManager.GetString(nameof(Compare_Empty), Culture) ?? nameof(Compare_Empty);
|
||||
|
||||
public static string Compare_Header => ResourceManager.GetString(nameof(Compare_Header), Culture) ?? nameof(Compare_Header);
|
||||
|
||||
public static string Crash_Body => ResourceManager.GetString(nameof(Crash_Body), Culture) ?? nameof(Crash_Body);
|
||||
|
||||
public static string Crash_Title => ResourceManager.GetString(nameof(Crash_Title), Culture) ?? nameof(Crash_Title);
|
||||
|
||||
public static string Dashboard_Agent_Elevated => ResourceManager.GetString(nameof(Dashboard_Agent_Elevated), Culture) ?? nameof(Dashboard_Agent_Elevated);
|
||||
|
||||
public static string Dashboard_Agent_Header => ResourceManager.GetString(nameof(Dashboard_Agent_Header), Culture) ?? nameof(Dashboard_Agent_Header);
|
||||
|
||||
public static string Dashboard_Agent_Overlay => ResourceManager.GetString(nameof(Dashboard_Agent_Overlay), Culture) ?? nameof(Dashboard_Agent_Overlay);
|
||||
|
||||
public static string Dashboard_Agent_Sessions => ResourceManager.GetString(nameof(Dashboard_Agent_Sessions), Culture) ?? nameof(Dashboard_Agent_Sessions);
|
||||
|
||||
public static string Dashboard_Agent_State => ResourceManager.GetString(nameof(Dashboard_Agent_State), Culture) ?? nameof(Dashboard_Agent_State);
|
||||
|
||||
public static string Dashboard_Agent_Telemetry => ResourceManager.GetString(nameof(Dashboard_Agent_Telemetry), Culture) ?? nameof(Dashboard_Agent_Telemetry);
|
||||
|
||||
public static string Dashboard_Agent_Version => ResourceManager.GetString(nameof(Dashboard_Agent_Version), Culture) ?? nameof(Dashboard_Agent_Version);
|
||||
|
||||
public static string Dashboard_Empty => ResourceManager.GetString(nameof(Dashboard_Empty), Culture) ?? nameof(Dashboard_Empty);
|
||||
|
||||
public static string Dashboard_Header => ResourceManager.GetString(nameof(Dashboard_Header), Culture) ?? nameof(Dashboard_Header);
|
||||
|
||||
public static string Games_Empty => ResourceManager.GetString(nameof(Games_Empty), Culture) ?? nameof(Games_Empty);
|
||||
|
||||
public static string Games_Header => ResourceManager.GetString(nameof(Games_Header), Culture) ?? nameof(Games_Header);
|
||||
|
||||
public static string Logs_Empty => ResourceManager.GetString(nameof(Logs_Empty), Culture) ?? nameof(Logs_Empty);
|
||||
|
||||
public static string Logs_Header => ResourceManager.GetString(nameof(Logs_Header), Culture) ?? nameof(Logs_Header);
|
||||
|
||||
public static string Menu_File => ResourceManager.GetString(nameof(Menu_File), Culture) ?? nameof(Menu_File);
|
||||
|
||||
public static string Menu_File_AddGame => ResourceManager.GetString(nameof(Menu_File_AddGame), Culture) ?? nameof(Menu_File_AddGame);
|
||||
|
||||
public static string Menu_File_Exit => ResourceManager.GetString(nameof(Menu_File_Exit), Culture) ?? nameof(Menu_File_Exit);
|
||||
|
||||
public static string Menu_File_Export => ResourceManager.GetString(nameof(Menu_File_Export), Culture) ?? nameof(Menu_File_Export);
|
||||
|
||||
public static string Menu_File_ImportLibrary => ResourceManager.GetString(nameof(Menu_File_ImportLibrary), Culture) ?? nameof(Menu_File_ImportLibrary);
|
||||
|
||||
public static string Menu_Help => ResourceManager.GetString(nameof(Menu_Help), Culture) ?? nameof(Menu_Help);
|
||||
|
||||
public static string Menu_Help_About => ResourceManager.GetString(nameof(Menu_Help_About), Culture) ?? nameof(Menu_Help_About);
|
||||
|
||||
public static string Menu_Help_CheckUpdates => ResourceManager.GetString(nameof(Menu_Help_CheckUpdates), Culture) ?? nameof(Menu_Help_CheckUpdates);
|
||||
|
||||
public static string Menu_Help_Documentation => ResourceManager.GetString(nameof(Menu_Help_Documentation), Culture) ?? nameof(Menu_Help_Documentation);
|
||||
|
||||
public static string Menu_Help_ReportBug => ResourceManager.GetString(nameof(Menu_Help_ReportBug), Culture) ?? nameof(Menu_Help_ReportBug);
|
||||
|
||||
public static string Menu_Tools => ResourceManager.GetString(nameof(Menu_Tools), Culture) ?? nameof(Menu_Tools);
|
||||
|
||||
public static string Menu_Tools_AgentStatus => ResourceManager.GetString(nameof(Menu_Tools_AgentStatus), Culture) ?? nameof(Menu_Tools_AgentStatus);
|
||||
|
||||
public static string Menu_Tools_DbMaintenance => ResourceManager.GetString(nameof(Menu_Tools_DbMaintenance), Culture) ?? nameof(Menu_Tools_DbMaintenance);
|
||||
|
||||
public static string Menu_Tools_OpenDataFolder => ResourceManager.GetString(nameof(Menu_Tools_OpenDataFolder), Culture) ?? nameof(Menu_Tools_OpenDataFolder);
|
||||
|
||||
public static string Menu_Tools_UpdateRules => ResourceManager.GetString(nameof(Menu_Tools_UpdateRules), Culture) ?? nameof(Menu_Tools_UpdateRules);
|
||||
|
||||
public static string Menu_Tools_VulkanLayer => ResourceManager.GetString(nameof(Menu_Tools_VulkanLayer), Culture) ?? nameof(Menu_Tools_VulkanLayer);
|
||||
|
||||
public static string Nav_Compare => ResourceManager.GetString(nameof(Nav_Compare), Culture) ?? nameof(Nav_Compare);
|
||||
|
||||
public static string Nav_Dashboard => ResourceManager.GetString(nameof(Nav_Dashboard), Culture) ?? nameof(Nav_Dashboard);
|
||||
|
||||
public static string Nav_Games => ResourceManager.GetString(nameof(Nav_Games), Culture) ?? nameof(Nav_Games);
|
||||
|
||||
public static string Nav_Logs => ResourceManager.GetString(nameof(Nav_Logs), Culture) ?? nameof(Nav_Logs);
|
||||
|
||||
public static string Nav_Settings => ResourceManager.GetString(nameof(Nav_Settings), Culture) ?? nameof(Nav_Settings);
|
||||
|
||||
public static string NotYet_Body => ResourceManager.GetString(nameof(NotYet_Body), Culture) ?? nameof(NotYet_Body);
|
||||
|
||||
public static string NotYet_Title => ResourceManager.GetString(nameof(NotYet_Title), Culture) ?? nameof(NotYet_Title);
|
||||
|
||||
public static string Settings_Appearance_Header => ResourceManager.GetString(nameof(Settings_Appearance_Header), Culture) ?? nameof(Settings_Appearance_Header);
|
||||
|
||||
public static string Settings_Header => ResourceManager.GetString(nameof(Settings_Header), Culture) ?? nameof(Settings_Header);
|
||||
|
||||
public static string Settings_Language_Label => ResourceManager.GetString(nameof(Settings_Language_Label), Culture) ?? nameof(Settings_Language_Label);
|
||||
|
||||
public static string Settings_Language_Note => ResourceManager.GetString(nameof(Settings_Language_Note), Culture) ?? nameof(Settings_Language_Note);
|
||||
|
||||
public static string Settings_Theme_Dark => ResourceManager.GetString(nameof(Settings_Theme_Dark), Culture) ?? nameof(Settings_Theme_Dark);
|
||||
|
||||
public static string Settings_Theme_Label => ResourceManager.GetString(nameof(Settings_Theme_Label), Culture) ?? nameof(Settings_Theme_Label);
|
||||
|
||||
public static string Settings_Theme_Light => ResourceManager.GetString(nameof(Settings_Theme_Light), Culture) ?? nameof(Settings_Theme_Light);
|
||||
|
||||
public static string Settings_Theme_System => ResourceManager.GetString(nameof(Settings_Theme_System), Culture) ?? nameof(Settings_Theme_System);
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
日本語: machine-drafted (docs/09_I18N.md §Translation workflow), every entry marked <comment>review</comment>
|
||||
until a reviewer signs off. No Safety_* key lives in this family; those arrive in FrameLedger.Shared (P3 PR-4)
|
||||
marked "safety: human review required", and are shown in English until reviewed.
|
||||
-->
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} — 明示的に有効化したゲーム内でグラフィックス API をフックし、ゲーム性能を計測します。GPLv3。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Title" xml:space="preserve">
|
||||
<value>FrameLedger について</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_Banner_Missing_Body" xml:space="preserve">
|
||||
<value>このアプリの隣に FrameLedger.Agent.exe が見つかりません。セッションは閲覧できますが、ライブ状態とキャプチャ操作は利用できません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_Banner_Offline_Body" xml:space="preserve">
|
||||
<value>キャプチャエージェントが応答しません。ライブラリ、履歴、グラフは引き続き使えます。ライブ状態のみ利用できません。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_Banner_Offline_Title" xml:space="preserve">
|
||||
<value>キャプチャエージェントがオフライン</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_Banner_Retry" xml:space="preserve">
|
||||
<value>再試行</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_State_Connected" xml:space="preserve">
|
||||
<value>エージェント接続済み</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_State_Connecting" xml:space="preserve">
|
||||
<value>エージェントに接続中…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_State_Missing" xml:space="preserve">
|
||||
<value>エージェント未インストール</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_State_Offline" xml:space="preserve">
|
||||
<value>エージェントはオフライン</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Agent_State_Starting" xml:space="preserve">
|
||||
<value>エージェントを起動中…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="App_Title" xml:space="preserve">
|
||||
<value>FrameLedger</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Common_Cancel" xml:space="preserve">
|
||||
<value>キャンセル</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Common_No" xml:space="preserve">
|
||||
<value>いいえ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Common_NotAvailable" xml:space="preserve">
|
||||
<value>N/A</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Common_Ok" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Common_Yes" xml:space="preserve">
|
||||
<value>はい</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Compare_Empty" xml:space="preserve">
|
||||
<value>比較するセッションを 2〜5 個選んでください。ゲームが異なっても構いません。計測ティアが異なる場合は先に確認します。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Compare_Header" xml:space="preserve">
|
||||
<value>比較</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Crash_Body" xml:space="preserve">
|
||||
<value>FrameLedger は回復できないエラーに遭遇しました。詳細はログフォルダーにあります。キャプチャエージェントは動作を続けます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Crash_Title" xml:space="preserve">
|
||||
<value>FrameLedger が予期せず停止しました</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Elevated" xml:space="preserve">
|
||||
<value>管理者権限</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Header" xml:space="preserve">
|
||||
<value>キャプチャエージェント</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Overlay" xml:space="preserve">
|
||||
<value>オーバーレイのビルド</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Sessions" xml:space="preserve">
|
||||
<value>実行中のセッション</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_State" xml:space="preserve">
|
||||
<value>状態</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Telemetry" xml:space="preserve">
|
||||
<value>テレメトリソース</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Version" xml:space="preserve">
|
||||
<value>エージェントのバージョン</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Empty" xml:space="preserve">
|
||||
<value>まだセッションがありません。追跡中のゲームを起動すれば、あとは FrameLedger が行います。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Dashboard_Header" xml:space="preserve">
|
||||
<value>ダッシュボード</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Games_Empty" xml:space="preserve">
|
||||
<value>まだゲームがありません。「ファイル ▸ ゲームを追加…」から追加してください。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Games_Header" xml:space="preserve">
|
||||
<value>ゲーム</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Logs_Empty" xml:space="preserve">
|
||||
<value>ログビューアーは後のビルドで提供されます。ファイルはデータフォルダーの logs にあります。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Logs_Header" xml:space="preserve">
|
||||
<value>ログ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_File" xml:space="preserve">
|
||||
<value>ファイル(_F)</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_File_AddGame" xml:space="preserve">
|
||||
<value>ゲームを追加…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_File_Exit" xml:space="preserve">
|
||||
<value>終了(_X)</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_File_Export" xml:space="preserve">
|
||||
<value>エクスポート</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_File_ImportLibrary" xml:space="preserve">
|
||||
<value>ライブラリをインポート…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Help" xml:space="preserve">
|
||||
<value>ヘルプ(_H)</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Help_About" xml:space="preserve">
|
||||
<value>FrameLedger について</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Help_CheckUpdates" xml:space="preserve">
|
||||
<value>更新を確認</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Help_Documentation" xml:space="preserve">
|
||||
<value>ドキュメント</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Help_ReportBug" xml:space="preserve">
|
||||
<value>不具合を報告…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Tools" xml:space="preserve">
|
||||
<value>ツール(_T)</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Tools_AgentStatus" xml:space="preserve">
|
||||
<value>エージェントの状態…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Tools_DbMaintenance" xml:space="preserve">
|
||||
<value>データベースのメンテナンス…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Tools_OpenDataFolder" xml:space="preserve">
|
||||
<value>データフォルダーを開く</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Tools_UpdateRules" xml:space="preserve">
|
||||
<value>検出ルールを更新</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Tools_VulkanLayer" xml:space="preserve">
|
||||
<value>Vulkan レイヤーの登録…</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Nav_Compare" xml:space="preserve">
|
||||
<value>比較</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Nav_Dashboard" xml:space="preserve">
|
||||
<value>ダッシュボード</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Nav_Games" xml:space="preserve">
|
||||
<value>ゲーム</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Nav_Logs" xml:space="preserve">
|
||||
<value>ログ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Nav_Settings" xml:space="preserve">
|
||||
<value>設定</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="NotYet_Body" xml:space="preserve">
|
||||
<value>この機能は後のビルドで提供されます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="NotYet_Title" xml:space="preserve">
|
||||
<value>未実装</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Appearance_Header" xml:space="preserve">
|
||||
<value>外観</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Header" xml:space="preserve">
|
||||
<value>設定</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Language_Label" xml:space="preserve">
|
||||
<value>言語</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Language_Note" xml:space="preserve">
|
||||
<value>すぐに適用されます。ウィンドウは新しい言語で再構築されます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Theme_Dark" xml:space="preserve">
|
||||
<value>ダーク</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Theme_Label" xml:space="preserve">
|
||||
<value>テーマ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Theme_Light" xml:space="preserve">
|
||||
<value>ライト</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Settings_Theme_System" xml:space="preserve">
|
||||
<value>システムに従う</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,216 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
The App's user-visible strings, NEUTRAL = en (docs/09_I18N.md: en is written first and is authoritative).
|
||||
Keys are Area_Element_Qualifier, sorted; Strings.Designer.cs is GENERATED from this file by
|
||||
tools/resx-gen.ps1 and tools/resx-audit.ps1 fails the build when it is stale or when vi/ja drift.
|
||||
No Safety_* key lives here: those are FrameLedger.Shared's (P3 PR-4), reviewed as legal text.
|
||||
-->
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} — measures game performance by hooking graphics APIs inside games you explicitly enabled. GPLv3.</value>
|
||||
</data>
|
||||
<data name="About_Title" xml:space="preserve">
|
||||
<value>About FrameLedger</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Missing_Body" xml:space="preserve">
|
||||
<value>FrameLedger.Agent.exe was not found beside this application. Sessions are still readable; live status and capture control are not.</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Offline_Body" xml:space="preserve">
|
||||
<value>The capture agent is not answering. Your library, history and charts still work; only live status is unavailable.</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Offline_Title" xml:space="preserve">
|
||||
<value>Capture agent offline</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Retry" xml:space="preserve">
|
||||
<value>Retry</value>
|
||||
</data>
|
||||
<data name="Agent_State_Connected" xml:space="preserve">
|
||||
<value>Agent connected</value>
|
||||
</data>
|
||||
<data name="Agent_State_Connecting" xml:space="preserve">
|
||||
<value>Connecting to agent…</value>
|
||||
</data>
|
||||
<data name="Agent_State_Missing" xml:space="preserve">
|
||||
<value>Agent not installed</value>
|
||||
</data>
|
||||
<data name="Agent_State_Offline" xml:space="preserve">
|
||||
<value>Agent offline</value>
|
||||
</data>
|
||||
<data name="Agent_State_Starting" xml:space="preserve">
|
||||
<value>Starting agent…</value>
|
||||
</data>
|
||||
<data name="App_Title" xml:space="preserve">
|
||||
<value>FrameLedger</value>
|
||||
</data>
|
||||
<data name="Common_Cancel" xml:space="preserve">
|
||||
<value>Cancel</value>
|
||||
</data>
|
||||
<data name="Common_No" xml:space="preserve">
|
||||
<value>No</value>
|
||||
</data>
|
||||
<data name="Common_NotAvailable" xml:space="preserve">
|
||||
<value>N/A</value>
|
||||
</data>
|
||||
<data name="Common_Ok" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name="Common_Yes" xml:space="preserve">
|
||||
<value>Yes</value>
|
||||
</data>
|
||||
<data name="Compare_Empty" xml:space="preserve">
|
||||
<value>Pick two to five sessions to compare — cross-game is fine; mixed capture tiers ask first.</value>
|
||||
</data>
|
||||
<data name="Compare_Header" xml:space="preserve">
|
||||
<value>Compare</value>
|
||||
</data>
|
||||
<data name="Crash_Body" xml:space="preserve">
|
||||
<value>FrameLedger hit an error it could not recover from. The details are in the log folder; the capture agent keeps running.</value>
|
||||
</data>
|
||||
<data name="Crash_Title" xml:space="preserve">
|
||||
<value>FrameLedger stopped unexpectedly</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Elevated" xml:space="preserve">
|
||||
<value>Elevated</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Header" xml:space="preserve">
|
||||
<value>Capture agent</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Overlay" xml:space="preserve">
|
||||
<value>Overlay build</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Sessions" xml:space="preserve">
|
||||
<value>Running sessions</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_State" xml:space="preserve">
|
||||
<value>State</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Telemetry" xml:space="preserve">
|
||||
<value>Telemetry source</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Version" xml:space="preserve">
|
||||
<value>Agent version</value>
|
||||
</data>
|
||||
<data name="Dashboard_Empty" xml:space="preserve">
|
||||
<value>No sessions yet — launch a tracked game and FrameLedger will do the rest.</value>
|
||||
</data>
|
||||
<data name="Dashboard_Header" xml:space="preserve">
|
||||
<value>Dashboard</value>
|
||||
</data>
|
||||
<data name="Games_Empty" xml:space="preserve">
|
||||
<value>No games yet — add one with File ▸ Add game…</value>
|
||||
</data>
|
||||
<data name="Games_Header" xml:space="preserve">
|
||||
<value>Games</value>
|
||||
</data>
|
||||
<data name="Logs_Empty" xml:space="preserve">
|
||||
<value>The log viewer arrives with a later build; the files are in the data folder under logs.</value>
|
||||
</data>
|
||||
<data name="Logs_Header" xml:space="preserve">
|
||||
<value>Logs</value>
|
||||
</data>
|
||||
<data name="Menu_File" xml:space="preserve">
|
||||
<value>_File</value>
|
||||
</data>
|
||||
<data name="Menu_File_AddGame" xml:space="preserve">
|
||||
<value>Add game…</value>
|
||||
</data>
|
||||
<data name="Menu_File_Exit" xml:space="preserve">
|
||||
<value>E_xit</value>
|
||||
</data>
|
||||
<data name="Menu_File_Export" xml:space="preserve">
|
||||
<value>Export</value>
|
||||
</data>
|
||||
<data name="Menu_File_ImportLibrary" xml:space="preserve">
|
||||
<value>Import library…</value>
|
||||
</data>
|
||||
<data name="Menu_Help" xml:space="preserve">
|
||||
<value>_Help</value>
|
||||
</data>
|
||||
<data name="Menu_Help_About" xml:space="preserve">
|
||||
<value>About FrameLedger</value>
|
||||
</data>
|
||||
<data name="Menu_Help_CheckUpdates" xml:space="preserve">
|
||||
<value>Check for updates</value>
|
||||
</data>
|
||||
<data name="Menu_Help_Documentation" xml:space="preserve">
|
||||
<value>Documentation</value>
|
||||
</data>
|
||||
<data name="Menu_Help_ReportBug" xml:space="preserve">
|
||||
<value>Report a bug…</value>
|
||||
</data>
|
||||
<data name="Menu_Tools" xml:space="preserve">
|
||||
<value>_Tools</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_AgentStatus" xml:space="preserve">
|
||||
<value>Agent status…</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_DbMaintenance" xml:space="preserve">
|
||||
<value>Database maintenance…</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_OpenDataFolder" xml:space="preserve">
|
||||
<value>Open data folder</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_UpdateRules" xml:space="preserve">
|
||||
<value>Update detection rules</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_VulkanLayer" xml:space="preserve">
|
||||
<value>Vulkan layer registration…</value>
|
||||
</data>
|
||||
<data name="Nav_Compare" xml:space="preserve">
|
||||
<value>Compare</value>
|
||||
</data>
|
||||
<data name="Nav_Dashboard" xml:space="preserve">
|
||||
<value>Dashboard</value>
|
||||
</data>
|
||||
<data name="Nav_Games" xml:space="preserve">
|
||||
<value>Games</value>
|
||||
</data>
|
||||
<data name="Nav_Logs" xml:space="preserve">
|
||||
<value>Logs</value>
|
||||
</data>
|
||||
<data name="Nav_Settings" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name="NotYet_Body" xml:space="preserve">
|
||||
<value>This part of FrameLedger arrives with a later build.</value>
|
||||
</data>
|
||||
<data name="NotYet_Title" xml:space="preserve">
|
||||
<value>Not built yet</value>
|
||||
</data>
|
||||
<data name="Settings_Appearance_Header" xml:space="preserve">
|
||||
<value>Appearance</value>
|
||||
</data>
|
||||
<data name="Settings_Header" xml:space="preserve">
|
||||
<value>Settings</value>
|
||||
</data>
|
||||
<data name="Settings_Language_Label" xml:space="preserve">
|
||||
<value>Language</value>
|
||||
</data>
|
||||
<data name="Settings_Language_Note" xml:space="preserve">
|
||||
<value>Applies at once; the window is rebuilt in the new language.</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_Dark" xml:space="preserve">
|
||||
<value>Dark</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_Label" xml:space="preserve">
|
||||
<value>Theme</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_Light" xml:space="preserve">
|
||||
<value>Light</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_System" xml:space="preserve">
|
||||
<value>Follow system</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,211 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!-- Tiếng Việt: do maintainer soạn (docs/09_I18N.md §Translation workflow). Bộ khoá phải trùng Strings.resx; resx-audit kiểm tra. -->
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} — đo hiệu năng game bằng cách hook API đồ hoạ bên trong những game bạn đã bật rõ ràng. GPLv3.</value>
|
||||
</data>
|
||||
<data name="About_Title" xml:space="preserve">
|
||||
<value>Giới thiệu FrameLedger</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Missing_Body" xml:space="preserve">
|
||||
<value>Không tìm thấy FrameLedger.Agent.exe cạnh ứng dụng. Vẫn đọc được các phiên chơi; trạng thái trực tiếp và điều khiển thu thập thì không.</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Offline_Body" xml:space="preserve">
|
||||
<value>Capture agent không phản hồi. Thư viện, lịch sử và biểu đồ vẫn hoạt động; chỉ trạng thái trực tiếp là không có.</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Offline_Title" xml:space="preserve">
|
||||
<value>Capture agent ngoại tuyến</value>
|
||||
</data>
|
||||
<data name="Agent_Banner_Retry" xml:space="preserve">
|
||||
<value>Thử lại</value>
|
||||
</data>
|
||||
<data name="Agent_State_Connected" xml:space="preserve">
|
||||
<value>Đã kết nối agent</value>
|
||||
</data>
|
||||
<data name="Agent_State_Connecting" xml:space="preserve">
|
||||
<value>Đang kết nối agent…</value>
|
||||
</data>
|
||||
<data name="Agent_State_Missing" xml:space="preserve">
|
||||
<value>Chưa cài agent</value>
|
||||
</data>
|
||||
<data name="Agent_State_Offline" xml:space="preserve">
|
||||
<value>Agent ngoại tuyến</value>
|
||||
</data>
|
||||
<data name="Agent_State_Starting" xml:space="preserve">
|
||||
<value>Đang khởi động agent…</value>
|
||||
</data>
|
||||
<data name="App_Title" xml:space="preserve">
|
||||
<value>FrameLedger</value>
|
||||
</data>
|
||||
<data name="Common_Cancel" xml:space="preserve">
|
||||
<value>Huỷ</value>
|
||||
</data>
|
||||
<data name="Common_No" xml:space="preserve">
|
||||
<value>Không</value>
|
||||
</data>
|
||||
<data name="Common_NotAvailable" xml:space="preserve">
|
||||
<value>N/A</value>
|
||||
</data>
|
||||
<data name="Common_Ok" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
<data name="Common_Yes" xml:space="preserve">
|
||||
<value>Có</value>
|
||||
</data>
|
||||
<data name="Compare_Empty" xml:space="preserve">
|
||||
<value>Chọn hai đến năm phiên chơi để so sánh — khác game vẫn được; khác mức thu thập sẽ hỏi trước.</value>
|
||||
</data>
|
||||
<data name="Compare_Header" xml:space="preserve">
|
||||
<value>So sánh</value>
|
||||
</data>
|
||||
<data name="Crash_Body" xml:space="preserve">
|
||||
<value>FrameLedger gặp lỗi không khôi phục được. Chi tiết nằm trong thư mục log; capture agent vẫn chạy.</value>
|
||||
</data>
|
||||
<data name="Crash_Title" xml:space="preserve">
|
||||
<value>FrameLedger dừng đột ngột</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Elevated" xml:space="preserve">
|
||||
<value>Quyền nâng cao</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Header" xml:space="preserve">
|
||||
<value>Capture agent</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Overlay" xml:space="preserve">
|
||||
<value>Bản build overlay</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Sessions" xml:space="preserve">
|
||||
<value>Phiên chơi đang chạy</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_State" xml:space="preserve">
|
||||
<value>Trạng thái</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Telemetry" xml:space="preserve">
|
||||
<value>Nguồn telemetry</value>
|
||||
</data>
|
||||
<data name="Dashboard_Agent_Version" xml:space="preserve">
|
||||
<value>Phiên bản agent</value>
|
||||
</data>
|
||||
<data name="Dashboard_Empty" xml:space="preserve">
|
||||
<value>Chưa có phiên chơi nào — khởi chạy một game đang theo dõi, FrameLedger sẽ lo phần còn lại.</value>
|
||||
</data>
|
||||
<data name="Dashboard_Header" xml:space="preserve">
|
||||
<value>Bảng điều khiển</value>
|
||||
</data>
|
||||
<data name="Games_Empty" xml:space="preserve">
|
||||
<value>Chưa có game nào — thêm bằng Tệp ▸ Thêm game…</value>
|
||||
</data>
|
||||
<data name="Games_Header" xml:space="preserve">
|
||||
<value>Game</value>
|
||||
</data>
|
||||
<data name="Logs_Empty" xml:space="preserve">
|
||||
<value>Trình xem log sẽ có ở bản sau; các tệp nằm trong thư mục dữ liệu, mục logs.</value>
|
||||
</data>
|
||||
<data name="Logs_Header" xml:space="preserve">
|
||||
<value>Log</value>
|
||||
</data>
|
||||
<data name="Menu_File" xml:space="preserve">
|
||||
<value>_Tệp</value>
|
||||
</data>
|
||||
<data name="Menu_File_AddGame" xml:space="preserve">
|
||||
<value>Thêm game…</value>
|
||||
</data>
|
||||
<data name="Menu_File_Exit" xml:space="preserve">
|
||||
<value>T_hoát</value>
|
||||
</data>
|
||||
<data name="Menu_File_Export" xml:space="preserve">
|
||||
<value>Xuất</value>
|
||||
</data>
|
||||
<data name="Menu_File_ImportLibrary" xml:space="preserve">
|
||||
<value>Nhập thư viện…</value>
|
||||
</data>
|
||||
<data name="Menu_Help" xml:space="preserve">
|
||||
<value>Trợ _giúp</value>
|
||||
</data>
|
||||
<data name="Menu_Help_About" xml:space="preserve">
|
||||
<value>Giới thiệu FrameLedger</value>
|
||||
</data>
|
||||
<data name="Menu_Help_CheckUpdates" xml:space="preserve">
|
||||
<value>Kiểm tra cập nhật</value>
|
||||
</data>
|
||||
<data name="Menu_Help_Documentation" xml:space="preserve">
|
||||
<value>Tài liệu</value>
|
||||
</data>
|
||||
<data name="Menu_Help_ReportBug" xml:space="preserve">
|
||||
<value>Báo lỗi…</value>
|
||||
</data>
|
||||
<data name="Menu_Tools" xml:space="preserve">
|
||||
<value>_Công cụ</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_AgentStatus" xml:space="preserve">
|
||||
<value>Trạng thái agent…</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_DbMaintenance" xml:space="preserve">
|
||||
<value>Bảo trì cơ sở dữ liệu…</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_OpenDataFolder" xml:space="preserve">
|
||||
<value>Mở thư mục dữ liệu</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_UpdateRules" xml:space="preserve">
|
||||
<value>Cập nhật quy tắc nhận diện</value>
|
||||
</data>
|
||||
<data name="Menu_Tools_VulkanLayer" xml:space="preserve">
|
||||
<value>Đăng ký Vulkan layer…</value>
|
||||
</data>
|
||||
<data name="Nav_Compare" xml:space="preserve">
|
||||
<value>So sánh</value>
|
||||
</data>
|
||||
<data name="Nav_Dashboard" xml:space="preserve">
|
||||
<value>Bảng điều khiển</value>
|
||||
</data>
|
||||
<data name="Nav_Games" xml:space="preserve">
|
||||
<value>Game</value>
|
||||
</data>
|
||||
<data name="Nav_Logs" xml:space="preserve">
|
||||
<value>Log</value>
|
||||
</data>
|
||||
<data name="Nav_Settings" xml:space="preserve">
|
||||
<value>Cài đặt</value>
|
||||
</data>
|
||||
<data name="NotYet_Body" xml:space="preserve">
|
||||
<value>Phần này của FrameLedger sẽ có ở bản sau.</value>
|
||||
</data>
|
||||
<data name="NotYet_Title" xml:space="preserve">
|
||||
<value>Chưa xây dựng</value>
|
||||
</data>
|
||||
<data name="Settings_Appearance_Header" xml:space="preserve">
|
||||
<value>Giao diện</value>
|
||||
</data>
|
||||
<data name="Settings_Header" xml:space="preserve">
|
||||
<value>Cài đặt</value>
|
||||
</data>
|
||||
<data name="Settings_Language_Label" xml:space="preserve">
|
||||
<value>Ngôn ngữ</value>
|
||||
</data>
|
||||
<data name="Settings_Language_Note" xml:space="preserve">
|
||||
<value>Áp dụng ngay; cửa sổ được dựng lại bằng ngôn ngữ mới.</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_Dark" xml:space="preserve">
|
||||
<value>Tối</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_Label" xml:space="preserve">
|
||||
<value>Chủ đề</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_Light" xml:space="preserve">
|
||||
<value>Sáng</value>
|
||||
</data>
|
||||
<data name="Settings_Theme_System" xml:space="preserve">
|
||||
<value>Theo hệ thống</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,21 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<Style x:Key="PageRoot" TargetType="StackPanel">
|
||||
<Setter Property="Margin" Value="28,20,28,20" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="FieldLabel" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||
<Setter Property="Margin" Value="0,0,16,6" />
|
||||
<Setter Property="MinWidth" Value="140" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="FieldValue" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||
<Setter Property="Margin" Value="0,0,0,6" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>A value and the text it shows as, for a ComboBox bound by value.</summary>
|
||||
public sealed record Choice<T>(T Value, string Label);
|
||||
@@ -0,0 +1,11 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>Compare (08_UI §Compare) arrives with P3 PR-7; until then the page is its empty state.</summary>
|
||||
public sealed class CompareViewModel : ObservableObject
|
||||
{
|
||||
public static string Header => Strings.Compare_Header;
|
||||
|
||||
public static string EmptyText => Strings.Compare_Empty;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Globalization;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// The Dashboard's Agent status card (08_UI §Dashboard): what <c>HelloAck</c> and <c>StatusAck</c> said, every
|
||||
/// value <c>N/A</c> until the Agent answered — never a placeholder that reads as a measurement.
|
||||
/// </summary>
|
||||
public sealed partial class DashboardViewModel : ObservableObject, IDisposable
|
||||
{
|
||||
private readonly AgentConnection _agent;
|
||||
private readonly UiThread _ui = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private string _agentState = Strings.Agent_State_Connecting;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _agentVersion = Strings.Common_NotAvailable;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _telemetrySource = Strings.Common_NotAvailable;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _overlayBuildId = Strings.Common_NotAvailable;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _elevated = Strings.Common_NotAvailable;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _runningSessions = Strings.Common_NotAvailable;
|
||||
|
||||
public DashboardViewModel(AgentConnection agent)
|
||||
{
|
||||
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
|
||||
_agent.Changed += OnAgentChanged;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public static string Header => Strings.Dashboard_Header;
|
||||
|
||||
public static string AgentHeader => Strings.Dashboard_Agent_Header;
|
||||
|
||||
public static string EmptyText => Strings.Dashboard_Empty;
|
||||
|
||||
public void Dispose() => _agent.Changed -= OnAgentChanged;
|
||||
|
||||
private void OnAgentChanged(object? sender, EventArgs e) => _ui.Post(Refresh);
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
AgentState = AgentStatusPresentation.Pill(_agent.State).Text;
|
||||
HelloAck? hello = _agent.Hello;
|
||||
StatusAck? status = _agent.Status;
|
||||
AgentVersion = hello?.AgentVersion ?? Strings.Common_NotAvailable;
|
||||
TelemetrySource = hello?.TelemetrySource ?? Strings.Common_NotAvailable;
|
||||
OverlayBuildId = hello?.OverlayBuildId ?? Strings.Common_NotAvailable;
|
||||
Elevated = hello is null ? Strings.Common_NotAvailable : hello.Elevated ? Strings.Common_Yes : Strings.Common_No;
|
||||
RunningSessions = status?.ActiveSessions.Count.ToString(CultureInfo.CurrentCulture) ?? Strings.Common_NotAvailable;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>Games (08_UI §Games) arrives with P3 PR-5; this build shows the empty state so the shell is honest about what it has.</summary>
|
||||
public sealed class GamesViewModel : ObservableObject
|
||||
{
|
||||
public static string Header => Strings.Games_Header;
|
||||
|
||||
public static string EmptyText => Strings.Games_Empty;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>Logs (08_UI §Logs) arrives with P3 PR-8; until then the page is its empty state.</summary>
|
||||
public sealed class LogsViewModel : ObservableObject
|
||||
{
|
||||
public static string Header => Strings.Logs_Header;
|
||||
|
||||
public static string EmptyText => Strings.Logs_Empty;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FrameLedger.App.Services;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>The shell's state: the Agent pill, the offline banner, and the menu commands that exist in this build.</summary>
|
||||
public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
{
|
||||
private readonly AgentConnection _agent;
|
||||
private readonly ISnackbarService _snackbar;
|
||||
private readonly IHostApplicationLifetime _lifetime;
|
||||
private readonly UiThread _ui = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private string _agentStatusText = Strings.Agent_State_Connecting;
|
||||
|
||||
[ObservableProperty]
|
||||
private ControlAppearance _agentStatusAppearance = ControlAppearance.Info;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isAgentBannerVisible;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _agentBannerBody = string.Empty;
|
||||
|
||||
public MainWindowViewModel(AgentConnection agent, ISnackbarService snackbar, IHostApplicationLifetime lifetime)
|
||||
{
|
||||
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
|
||||
_snackbar = snackbar ?? throw new ArgumentNullException(nameof(snackbar));
|
||||
_lifetime = lifetime ?? throw new ArgumentNullException(nameof(lifetime));
|
||||
_agent.Changed += OnAgentChanged;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public static string Title => Strings.App_Title;
|
||||
|
||||
public void Dispose() => _agent.Changed -= OnAgentChanged;
|
||||
|
||||
private void OnAgentChanged(object? sender, EventArgs e) => _ui.Post(Refresh);
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
(string text, ControlAppearance appearance) = AgentStatusPresentation.Pill(_agent.State);
|
||||
AgentStatusText = text;
|
||||
AgentStatusAppearance = appearance;
|
||||
string? banner = AgentStatusPresentation.Banner(_agent.State);
|
||||
AgentBannerBody = banner ?? string.Empty;
|
||||
IsAgentBannerVisible = banner is not null;
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void RetryAgent() => _agent.RetryNow();
|
||||
|
||||
/// <summary>Exit is a host shutdown (App.RunAsync tears down and then ends the process), not a bare <c>Application.Shutdown</c>.</summary>
|
||||
[RelayCommand]
|
||||
private void Exit() => _lifetime.StopApplication();
|
||||
|
||||
[RelayCommand]
|
||||
private static void OpenDataFolder()
|
||||
{
|
||||
try
|
||||
{
|
||||
using Process? _ = Process.Start(new ProcessStartInfo("explorer.exe", UiPaths.DataDirectory) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex) when (ex is Win32Exception or InvalidOperationException)
|
||||
{
|
||||
Serilog.Log.Warning(ex, "ui: could not open the data folder");
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format string is a resource that follows the UI culture, which changes at runtime; a cached CompositeFormat would pin the first culture")]
|
||||
private static async Task AboutAsync()
|
||||
{
|
||||
var box = new MessageBox
|
||||
{
|
||||
Title = Strings.About_Title,
|
||||
Content = string.Format(CultureInfo.CurrentCulture, Strings.About_Body_Format, UiIdentity.Version),
|
||||
CloseButtonText = Strings.Common_Ok,
|
||||
};
|
||||
await box.ShowDialogAsync().ConfigureAwait(true);
|
||||
}
|
||||
|
||||
/// <summary>Every menu item of <c>08_UI</c> §Menu bar that a later slice builds says so, in a 4 s snackbar, rather than doing nothing.</summary>
|
||||
[RelayCommand]
|
||||
private void NotYet() =>
|
||||
_snackbar.Show(Strings.NotYet_Title, Strings.NotYet_Body, ControlAppearance.Secondary, new SymbolIcon(SymbolRegular.Info24), TimeSpan.FromSeconds(4));
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.ViewModels;
|
||||
|
||||
/// <summary>
|
||||
/// Settings, the part this build has (08_UI §Settings — Appearance): theme applies at once and persists;
|
||||
/// language persists and rebuilds the shell in the new culture (09_I18N §Mechanics).
|
||||
/// </summary>
|
||||
public sealed partial class SettingsViewModel : ObservableObject
|
||||
{
|
||||
private readonly AppearanceSettings _appearance;
|
||||
private readonly IThemeApplier _themes;
|
||||
private readonly ShellHost _shell;
|
||||
private readonly bool _loading = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private AppTheme _selectedTheme;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _selectedLanguage = "en";
|
||||
|
||||
public SettingsViewModel(AppearanceSettings appearance, IThemeApplier theme, ShellHost shell)
|
||||
{
|
||||
_appearance = appearance ?? throw new ArgumentNullException(nameof(appearance));
|
||||
_themes = theme ?? throw new ArgumentNullException(nameof(theme));
|
||||
_shell = shell ?? throw new ArgumentNullException(nameof(shell));
|
||||
SelectedTheme = appearance.Theme;
|
||||
SelectedLanguage = appearance.Language;
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
public static string Header => Strings.Settings_Header;
|
||||
|
||||
public static string AppearanceHeader => Strings.Settings_Appearance_Header;
|
||||
|
||||
public static string ThemeLabel => Strings.Settings_Theme_Label;
|
||||
|
||||
public static string LanguageLabel => Strings.Settings_Language_Label;
|
||||
|
||||
public static string LanguageNote => Strings.Settings_Language_Note;
|
||||
|
||||
public static IReadOnlyList<Choice<AppTheme>> Themes { get; } =
|
||||
[
|
||||
new(AppTheme.System, Strings.Settings_Theme_System),
|
||||
new(AppTheme.Light, Strings.Settings_Theme_Light),
|
||||
new(AppTheme.Dark, Strings.Settings_Theme_Dark),
|
||||
];
|
||||
|
||||
public static IReadOnlyList<Choice<string>> Languages { get; } =
|
||||
[
|
||||
new("en", "English"),
|
||||
new("vi", "Tiếng Việt"),
|
||||
new("ja", "日本語"),
|
||||
];
|
||||
|
||||
/// <summary>A pending write, for a test to await; the UI does not.</summary>
|
||||
public Task Pending { get; private set; } = Task.CompletedTask;
|
||||
|
||||
partial void OnSelectedThemeChanged(AppTheme value)
|
||||
{
|
||||
if (_loading)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_themes.Apply(value, _shell.Current);
|
||||
Pending = _appearance.SetThemeAsync(value);
|
||||
}
|
||||
|
||||
partial void OnSelectedLanguageChanged(string value)
|
||||
{
|
||||
if (_loading || string.Equals(value, _appearance.Language, StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pending = ApplyLanguageAsync(value);
|
||||
}
|
||||
|
||||
private async Task ApplyLanguageAsync(string value)
|
||||
{
|
||||
await _appearance.SetLanguageAsync(value).ConfigureAwait(true);
|
||||
App.ApplyCulture(_appearance.Language);
|
||||
_shell.Rebuild();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Ipc;
|
||||
using FrameLedger.Infrastructure.Ipc;
|
||||
using FrameLedger.Shared.Ipc;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// <c>07_IPC</c> §Client behavior as a state machine, against a real <see cref="PipeServer"/> in this process on
|
||||
/// a test-named pipe: connect rounds, starting the Agent when it is absent, <c>Hello</c> on connect, offline
|
||||
/// when the server goes, and connected again when it returns. The launcher is a fake that can start the server.
|
||||
/// </summary>
|
||||
public sealed class AgentConnectionTests : IAsyncDisposable
|
||||
{
|
||||
private static readonly TimeSpan _wait = TimeSpan.FromSeconds(15);
|
||||
private static readonly AgentIdentity _identity = new("agent-test", Environment.ProcessId, Elevated: false, "build-x", VulkanLayerRegistered: false, CpuTempAvailable: false);
|
||||
private static readonly AgentConnectionOptions _fast = new()
|
||||
{
|
||||
ConnectAttempts = 3,
|
||||
ConnectBackoff = TimeSpan.FromMilliseconds(30),
|
||||
ConnectTimeout = TimeSpan.FromMilliseconds(300),
|
||||
RetryInterval = TimeSpan.FromMilliseconds(200),
|
||||
Keepalive = TimeSpan.FromMilliseconds(400),
|
||||
RequestTimeout = TimeSpan.FromSeconds(5),
|
||||
};
|
||||
|
||||
private readonly string _pipeName = "FrameLedger.test." + Guid.NewGuid().ToString("N");
|
||||
private readonly CancellationTokenSource _stop = new();
|
||||
private readonly List<AgentConnectionState> _seen = [];
|
||||
private PipeServer? _server;
|
||||
private Task? _serving;
|
||||
private CancellationTokenSource? _serverStop;
|
||||
private AgentConnection? _connection;
|
||||
private Task? _running;
|
||||
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
|
||||
/// <summary>A launcher that can be told whether an Agent is beside the App, and whose start brings the server up.</summary>
|
||||
private sealed class FakeLauncher(Func<bool> start) : IAgentLauncher
|
||||
{
|
||||
public bool CanLaunch { get; set; }
|
||||
|
||||
public int Starts { get; private set; }
|
||||
|
||||
public bool TryStart()
|
||||
{
|
||||
Starts++;
|
||||
return start();
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await _stop.CancelAsync().ConfigureAwait(false);
|
||||
if (_running is not null)
|
||||
{
|
||||
Task running = _running;
|
||||
try
|
||||
{
|
||||
await running.ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (_connection is not null)
|
||||
{
|
||||
await _connection.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await StopServerAsync().ConfigureAwait(false);
|
||||
_stop.Dispose();
|
||||
}
|
||||
|
||||
private void StartServer()
|
||||
{
|
||||
_serverStop = new CancellationTokenSource();
|
||||
_server = new PipeServer(new PipeServerOptions { PipeName = _pipeName },
|
||||
new AgentRequestHandler(_identity, static () => "l1", static () => AgentStatus.Idle));
|
||||
_serving = _server.RunAsync(_serverStop.Token);
|
||||
}
|
||||
|
||||
private async Task StopServerAsync()
|
||||
{
|
||||
if (_serverStop is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _serverStop.CancelAsync().ConfigureAwait(false);
|
||||
Task? serving = _serving;
|
||||
if (serving is not null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await serving.ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
_server?.Dispose();
|
||||
_serverStop.Dispose();
|
||||
_serverStop = null;
|
||||
_server = null;
|
||||
_serving = null;
|
||||
}
|
||||
|
||||
private AgentConnection Start(FakeLauncher launcher)
|
||||
{
|
||||
_connection = new AgentConnection(launcher, () => new PipeClient(_pipeName), _fast, "app-test");
|
||||
_connection.Changed += (s, _) =>
|
||||
{
|
||||
lock (_seen)
|
||||
{
|
||||
_seen.Add(((AgentConnection)s!).State);
|
||||
}
|
||||
};
|
||||
_running = _connection.RunAsync(_stop.Token);
|
||||
return _connection;
|
||||
}
|
||||
|
||||
private static async Task WaitForAsync(Func<bool> condition, string because)
|
||||
{
|
||||
DateTimeOffset deadline = DateTimeOffset.UtcNow + _wait;
|
||||
while (!condition() && DateTimeOffset.UtcNow < deadline)
|
||||
{
|
||||
await Task.Delay(25, Ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
condition().Should().BeTrue(because);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WithNoAgentBesideTheAppTheStateIsMissingAndNothingIsStarted()
|
||||
{
|
||||
var launcher = new FakeLauncher(static () => false) { CanLaunch = false };
|
||||
AgentConnection c = Start(launcher);
|
||||
|
||||
await WaitForAsync(() => c.State == AgentConnectionState.Missing, "three attempts × 30 ms, nothing to start").ConfigureAwait(true);
|
||||
await WaitForAsync(() => c.Rounds >= 2, "rounds continue in case an Agent appears").ConfigureAwait(true);
|
||||
launcher.Starts.Should().Be(0);
|
||||
c.Hello.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ARunningAgentIsFoundHelloedAndReportedConnected()
|
||||
{
|
||||
StartServer();
|
||||
var launcher = new FakeLauncher(static () => false) { CanLaunch = true };
|
||||
AgentConnection c = Start(launcher);
|
||||
|
||||
await WaitForAsync(() => c.State == AgentConnectionState.Connected, "the server is up").ConfigureAwait(true);
|
||||
c.Hello!.AgentVersion.Should().Be("agent-test");
|
||||
c.Status!.State.Should().Be(AgentStatus.IdleState);
|
||||
launcher.Starts.Should().Be(0, "an answering Agent is never restarted");
|
||||
|
||||
// Keepalive: after a few intervals the connection is still connected (a ping that failed would drop it).
|
||||
await Task.Delay(_fast.Keepalive * 3, Ct).ConfigureAwait(true);
|
||||
c.State.Should().Be(AgentConnectionState.Connected);
|
||||
(await c.RefreshStatusAsync(Ct).ConfigureAwait(true)).Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WhenTheAgentIsAbsentItIsStartedFromBesideTheAppAndThenConnected()
|
||||
{
|
||||
// The fake launcher's "start" brings the server up, the way FrameLedger.Agent.exe --serve would.
|
||||
FakeLauncher? launcher = null;
|
||||
launcher = new FakeLauncher(() =>
|
||||
{
|
||||
StartServer();
|
||||
return true;
|
||||
})
|
||||
{ CanLaunch = true };
|
||||
AgentConnection c = Start(launcher);
|
||||
|
||||
await WaitForAsync(() => c.State == AgentConnectionState.Connected, "started, then connected on the second try").ConfigureAwait(true);
|
||||
launcher.Starts.Should().Be(1);
|
||||
c.Launches.Should().Be(1);
|
||||
lock (_seen)
|
||||
{
|
||||
_seen.Should().Contain(AgentConnectionState.Starting, "the pill said so on the way");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ALostAgentIsOfflineAndAReturningOneIsConnectedAgain()
|
||||
{
|
||||
StartServer();
|
||||
var launcher = new FakeLauncher(static () => false) { CanLaunch = true };
|
||||
AgentConnection c = Start(launcher);
|
||||
await WaitForAsync(() => c.State == AgentConnectionState.Connected, "up").ConfigureAwait(true);
|
||||
|
||||
await StopServerAsync().ConfigureAwait(true);
|
||||
await WaitForAsync(() => c.State is AgentConnectionState.Offline or AgentConnectionState.Connecting or AgentConnectionState.Starting, "the pipe dropped").ConfigureAwait(true);
|
||||
await WaitForAsync(() => c.Rounds >= 1, "a new round ran").ConfigureAwait(true);
|
||||
|
||||
StartServer();
|
||||
c.RetryNow();
|
||||
await WaitForAsync(() => c.State == AgentConnectionState.Connected && c.Hello is not null, "back").ConfigureAwait(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.Application.Persistence;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>The two appearance keys (settings registry, D16): tolerant reads, exact writes.</summary>
|
||||
public sealed class AppearanceSettingsTests
|
||||
{
|
||||
private sealed class FakeSettings : ISettingsStore
|
||||
{
|
||||
public Dictionary<string, string> Rows { get; } = new(StringComparer.Ordinal);
|
||||
|
||||
public ValueTask<string?> GetAsync(string key, CancellationToken ct = default) => ValueTask.FromResult(Rows.GetValueOrDefault(key));
|
||||
|
||||
public ValueTask SetAsync(string key, string value, CancellationToken ct = default)
|
||||
{
|
||||
Rows[key] = value;
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task NoRowsMeansSystemThemeAndEnglish()
|
||||
{
|
||||
var settings = new AppearanceSettings(new FakeSettings());
|
||||
await settings.LoadAsync(TestContext.Current.CancellationToken);
|
||||
settings.Theme.Should().Be(AppTheme.System);
|
||||
settings.Language.Should().Be("en");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AHandEditedUnknownValueIsTheDefaultNotAnException()
|
||||
{
|
||||
var store = new FakeSettings();
|
||||
store.Rows[AppearanceSettings.ThemeKey] = "purple";
|
||||
store.Rows[AppearanceSettings.LanguageKey] = "klingon";
|
||||
var settings = new AppearanceSettings(store);
|
||||
await settings.LoadAsync(TestContext.Current.CancellationToken);
|
||||
settings.Theme.Should().Be(AppTheme.System);
|
||||
settings.Language.Should().Be("en");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WritesLandUnderTheRegistrysKeysAndReadBack()
|
||||
{
|
||||
var store = new FakeSettings();
|
||||
var settings = new AppearanceSettings(store);
|
||||
await settings.SetThemeAsync(AppTheme.Dark, TestContext.Current.CancellationToken);
|
||||
await settings.SetLanguageAsync("ja", TestContext.Current.CancellationToken);
|
||||
|
||||
store.Rows.Should().Contain(AppearanceSettings.ThemeKey, "dark").And.Contain(AppearanceSettings.LanguageKey, "ja");
|
||||
|
||||
var again = new AppearanceSettings(store);
|
||||
await again.LoadAsync(TestContext.Current.CancellationToken);
|
||||
again.Theme.Should().Be(AppTheme.Dark);
|
||||
again.Language.Should().Be("ja");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(AppTheme.System, "system")]
|
||||
[InlineData(AppTheme.Light, "light")]
|
||||
[InlineData(AppTheme.Dark, "dark")]
|
||||
public void ThemeTextRoundTrips(AppTheme theme, string text)
|
||||
{
|
||||
AppearanceSettings.ThemeText(theme).Should().Be(text);
|
||||
AppearanceSettings.ParseTheme(text).Should().Be(theme);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>FrameLedger.App.Tests</RootNamespace>
|
||||
<!-- The App is a WPF WinExe with RuntimeIdentifier win-x64; a referencing project needs both so restore resolves one graph. -->
|
||||
<UseWPF>true</UseWPF>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\FrameLedger.App\FrameLedger.App.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="xunit.v3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" />
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
<PackageReference Include="coverlet.collector" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,76 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The generated accessor against the satellites the build produced: every key resolves in en, vi and ja
|
||||
/// (a missing satellite would fall back to English silently, and this is the one place that would show), and
|
||||
/// the accessor's key list is the resx's — the audit gate checks the same from the outside.
|
||||
/// </summary>
|
||||
public sealed class StringsTests
|
||||
{
|
||||
private static readonly string[] _cultures = ["en", "vi", "ja"];
|
||||
|
||||
[Theory]
|
||||
[InlineData("en")]
|
||||
[InlineData("vi")]
|
||||
[InlineData("ja")]
|
||||
public void EveryKeyResolvesToANonEmptyStringIn(string culture)
|
||||
{
|
||||
var ci = CultureInfo.GetCultureInfo(culture);
|
||||
foreach (string key in Strings.Keys)
|
||||
{
|
||||
Strings.ResourceManager.GetString(key, ci).Should().NotBeNullOrWhiteSpace($"{key} in {culture}");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheSatellitesAreReallyLoadedNotTheEnglishFallback()
|
||||
{
|
||||
string en = Strings.ResourceManager.GetString(nameof(Strings.Nav_Settings), CultureInfo.GetCultureInfo("en"))!;
|
||||
string vi = Strings.ResourceManager.GetString(nameof(Strings.Nav_Settings), CultureInfo.GetCultureInfo("vi"))!;
|
||||
string ja = Strings.ResourceManager.GetString(nameof(Strings.Nav_Settings), CultureInfo.GetCultureInfo("ja"))!;
|
||||
vi.Should().NotBe(en, "vi/FrameLedger.resources.dll must be beside the assembly");
|
||||
ja.Should().NotBe(en, "ja/FrameLedger.resources.dll must be beside the assembly");
|
||||
_cultures.Should().HaveCount(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheAccessorsKeysAreTheResxsKeys()
|
||||
{
|
||||
string resx = Path.Combine(RepoRoot(), "src", "FrameLedger.App", "Strings.resx");
|
||||
string[] keys = XDocument.Load(resx).Root!.Elements("data").Select(d => (string)d.Attribute("name")!).ToArray();
|
||||
Strings.Keys.Should().BeEquivalentTo(keys, "Strings.Designer.cs is generated from Strings.resx and committed; tools/resx-audit.ps1 fails on drift");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheCulturePropertyOverridesTheThread()
|
||||
{
|
||||
CultureInfo? previous = Strings.Culture;
|
||||
try
|
||||
{
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("vi");
|
||||
Strings.Nav_Settings.Should().Be("Cài đặt");
|
||||
Strings.Culture = CultureInfo.GetCultureInfo("en");
|
||||
Strings.Nav_Settings.Should().Be("Settings");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Strings.Culture = previous;
|
||||
}
|
||||
}
|
||||
|
||||
private static string RepoRoot()
|
||||
{
|
||||
string? dir = AppContext.BaseDirectory;
|
||||
while (dir is not null && !File.Exists(Path.Combine(dir, "FrameLedger.slnx")))
|
||||
{
|
||||
dir = Path.GetDirectoryName(dir);
|
||||
}
|
||||
|
||||
return dir ?? throw new InvalidOperationException("FrameLedger.slnx not found above the test binary");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
The resx gate docs/09_I18N.md promised: every key in every language, safety strings reviewed as legal
|
||||
text, and the generated accessor current.
|
||||
|
||||
.DESCRIPTION
|
||||
09_I18N §Translation workflow: "CI check (tools/resx-audit): every key present in all three files".
|
||||
This script did not exist for the first fourteen months the document named it; build.ps1 skipped the
|
||||
step loudly, and 13_CI_CD and CLAUDE.md both recorded the absence. It exists as of P3 PR-2 (2026-09-13),
|
||||
with the first .resx family.
|
||||
|
||||
Per FAMILY (a neutral Strings.resx and its Strings.<culture>.resx beside it, under src/):
|
||||
1. every key is a C# identifier, unique, and has a non-empty neutral value;
|
||||
2. every required culture file exists and carries EXACTLY the neutral key set — a missing key would
|
||||
silently fall back to English, an extra one would be dead text nobody can reach;
|
||||
3. 09_I18N §Safety-critical strings: a `Safety_*` key in `ja` must carry a comment saying either
|
||||
`safety: human review required` — and then its VALUE MUST BE THE ENGLISH VERBATIM, which is how
|
||||
"shown as en until signed" is true by construction rather than by a runtime fallback the key-set
|
||||
rule (2) forbids — or `safety: reviewed by <name>`; a machine-drafted ban warning with neither is
|
||||
the harm that section names, and it is red here;
|
||||
4. the committed Strings.Designer.cs is what tools/resx-gen.ps1 would write (the accessor is
|
||||
generated and committed; drift is the silent failure mode of "generated").
|
||||
|
||||
FAIL-CLOSED WHEN NOTHING IS FOUND: no family under src/ means the gate would be vacuous, so it is red
|
||||
rather than green — the same rule tools/package-closure-check.ps1 applies to a closure of two.
|
||||
|
||||
.PARAMETER SelfTest
|
||||
Runs the decision table in both directions on fixtures in a temp directory; at least four cases must
|
||||
go RED for the run to pass, so a check that stopped checking cannot report a clean self-test.
|
||||
#>
|
||||
[CmdletBinding(DefaultParameterSetName = 'Check')]
|
||||
param(
|
||||
[Parameter(ParameterSetName = 'Check')]
|
||||
[string]$Root = (Split-Path $PSScriptRoot -Parent),
|
||||
|
||||
[Parameter(ParameterSetName = 'Check')]
|
||||
[string[]]$Cultures = @('vi', 'ja'),
|
||||
|
||||
[Parameter(ParameterSetName = 'SelfTest', Mandatory = $true)]
|
||||
[switch]$SelfTest
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$script:Gen = Join-Path $PSScriptRoot 'resx-gen.ps1'
|
||||
$script:ReviewRequired = 'safety: human review required'
|
||||
$script:ReviewedBy = 'safety: reviewed by '
|
||||
$script:SafetyPrefix = 'Safety_'
|
||||
$script:ReviewedCulture = 'ja'
|
||||
|
||||
function Read-Resx([string]$path) {
|
||||
[xml]$doc = Get-Content -Raw $path
|
||||
$entries = @{}
|
||||
$order = New-Object System.Collections.Generic.List[string]
|
||||
$dups = New-Object System.Collections.Generic.List[string]
|
||||
foreach ($d in @($doc.root.data)) {
|
||||
if ($null -eq $d) { continue }
|
||||
$name = [string]$d.name
|
||||
if ($entries.ContainsKey($name)) { $dups.Add($name); continue }
|
||||
$value = if ($null -ne $d.value) { [string]$d.value } else { '' }
|
||||
$comment = if ($d.PSObject.Properties['comment'] -and $null -ne $d.comment) { [string]$d.comment } else { '' }
|
||||
$entries[$name] = @{ Value = $value; Comment = $comment }
|
||||
$order.Add($name)
|
||||
}
|
||||
return @{ Entries = $entries; Order = $order; Duplicates = $dups }
|
||||
}
|
||||
|
||||
<#
|
||||
Returns the list of problems for one family; empty means it passes. A list, not a boolean, so the
|
||||
live run can print every defect at once rather than the first one per build.
|
||||
#>
|
||||
function Test-ResxFamily([string]$neutralPath, [string[]]$cultures) {
|
||||
$problems = New-Object System.Collections.Generic.List[string]
|
||||
$rel = $neutralPath
|
||||
$neutral = Read-Resx $neutralPath
|
||||
foreach ($d in $neutral.Duplicates) { $problems.Add("$rel`: key '$d' appears twice") }
|
||||
foreach ($k in $neutral.Order) {
|
||||
if ($k -notmatch '^[A-Za-z][A-Za-z0-9_]*$') { $problems.Add("$rel`: key '$k' is not a C# identifier (09_I18N: Area_Element_Qualifier)") }
|
||||
if ([string]::IsNullOrWhiteSpace($neutral.Entries[$k].Value)) { $problems.Add("$rel`: key '$k' has an empty neutral value") }
|
||||
}
|
||||
|
||||
if ($neutral.Order.Count -eq 0) { $problems.Add("$rel`: no keys at all") }
|
||||
|
||||
$dir = Split-Path $neutralPath -Parent
|
||||
$base = [IO.Path]::GetFileNameWithoutExtension($neutralPath)
|
||||
foreach ($culture in $cultures) {
|
||||
$culturePath = Join-Path $dir "$base.$culture.resx"
|
||||
if (-not (Test-Path $culturePath)) {
|
||||
$problems.Add("$rel`: no $culture file ($base.$culture.resx) — 09_I18N requires en, vi, ja")
|
||||
continue
|
||||
}
|
||||
|
||||
$translated = Read-Resx $culturePath
|
||||
foreach ($d in $translated.Duplicates) { $problems.Add("$culturePath`: key '$d' appears twice") }
|
||||
foreach ($k in $neutral.Order) {
|
||||
if (-not $translated.Entries.ContainsKey($k)) { $problems.Add("$culturePath`: key '$k' is missing (it would fall back to English silently)") }
|
||||
}
|
||||
|
||||
foreach ($k in $translated.Order) {
|
||||
if (-not $neutral.Entries.ContainsKey($k)) { $problems.Add("$culturePath`: key '$k' does not exist in the neutral file (dead text)") }
|
||||
}
|
||||
|
||||
if ($culture -eq $script:ReviewedCulture) {
|
||||
foreach ($k in $neutral.Order) {
|
||||
if (-not $k.StartsWith($script:SafetyPrefix, [StringComparison]::Ordinal)) { continue }
|
||||
if (-not $translated.Entries.ContainsKey($k)) { continue }
|
||||
$comment = $translated.Entries[$k].Comment
|
||||
$pending = $comment.Contains($script:ReviewRequired, [StringComparison]::Ordinal)
|
||||
$reviewed = $comment.Contains($script:ReviewedBy, [StringComparison]::Ordinal)
|
||||
if (-not ($pending -or $reviewed)) {
|
||||
$problems.Add("$culturePath`: safety key '$k' carries neither '$($script:ReviewRequired)' nor '$($script:ReviewedBy)<name>' — 09_I18N §Safety-critical strings: a mistranslated ban warning is a real harm")
|
||||
}
|
||||
elseif ($pending -and -not $reviewed -and $translated.Entries[$k].Value -cne $neutral.Entries[$k].Value) {
|
||||
$problems.Add("$culturePath`: safety key '$k' is marked '$($script:ReviewRequired)' but carries text other than the English — until a reviewer signs, the value must be the en string verbatim (that is the fallback)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Path $script:Gen) {
|
||||
# The generator throws on a key it cannot name (caught above as a non-identifier) and exits 1 on drift.
|
||||
try {
|
||||
& $script:Gen -Resx $neutralPath -Check *> $null
|
||||
if ($LASTEXITCODE -ne 0) { $problems.Add("$rel`: $base.Designer.cs is missing or stale — run tools/resx-gen.ps1 -Resx $rel") }
|
||||
}
|
||||
catch {
|
||||
$problems.Add("$rel`: $($_.Exception.Message)")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$problems.Add("tools/resx-gen.ps1 is missing, so the accessor cannot be checked")
|
||||
}
|
||||
|
||||
# Callers wrap this in @(): PowerShell unrolls a returned List, and an empty one becomes $null.
|
||||
return $problems
|
||||
}
|
||||
|
||||
function Find-Families([string]$root) {
|
||||
$src = Join-Path $root 'src'
|
||||
if (-not (Test-Path $src)) { return @() }
|
||||
return @(Get-ChildItem $src -Recurse -Filter '*.resx' -File |
|
||||
Where-Object { $_.FullName -notmatch '\\(obj|bin)\\' } |
|
||||
Where-Object { $_.Name -notmatch '\.[a-z]{2}(-[A-Za-z]{2,4})?\.resx$' })
|
||||
}
|
||||
|
||||
function New-Fixture([string]$dir, [hashtable]$files) {
|
||||
New-Item -ItemType Directory -Force $dir | Out-Null
|
||||
foreach ($name in $files.Keys) {
|
||||
$data = ($files[$name] | ForEach-Object {
|
||||
$c = if ($_.ContainsKey('Comment')) { "<comment>$($_.Comment)</comment>" } else { '' }
|
||||
" <data name=""$($_.Key)"" xml:space=""preserve""><value>$($_.Value)</value>$c</data>"
|
||||
}) -join "`n"
|
||||
$xml = "<?xml version=""1.0"" encoding=""utf-8""?>`n<root>`n <resheader name=""resmimetype""><value>text/microsoft-resx</value></resheader>`n <resheader name=""version""><value>2.0</value></resheader>`n$data`n</root>`n"
|
||||
[IO.File]::WriteAllText((Join-Path $dir $name), $xml, [Text.UTF8Encoding]::new($false))
|
||||
}
|
||||
}
|
||||
|
||||
if ($SelfTest) {
|
||||
$temp = Join-Path ([IO.Path]::GetTempPath()) ("fl-resx-audit-" + [Guid]::NewGuid().ToString('N'))
|
||||
try {
|
||||
$en = @(@{ Key = 'Nav_Home'; Value = 'Home' }, @{ Key = 'Safety_Warn'; Value = 'May result in a permanent ban.' })
|
||||
$vi = @(@{ Key = 'Nav_Home'; Value = 'Trang chủ' }, @{ Key = 'Safety_Warn'; Value = 'Có thể dẫn đến khoá tài khoản vĩnh viễn.' })
|
||||
$jaMarked = @(@{ Key = 'Nav_Home'; Value = 'ホーム'; Comment = 'review' }, @{ Key = 'Safety_Warn'; Value = 'May result in a permanent ban.'; Comment = 'safety: human review required' })
|
||||
$jaMarkedButTranslated = @(@{ Key = 'Nav_Home'; Value = 'ホーム' }, @{ Key = 'Safety_Warn'; Value = '機械翻訳'; Comment = 'safety: human review required' })
|
||||
$jaReviewed = @(@{ Key = 'Nav_Home'; Value = 'ホーム' }, @{ Key = 'Safety_Warn'; Value = '永久BANの可能性があります。'; Comment = 'safety: reviewed by A. Reviewer' })
|
||||
$jaUnmarked = @(@{ Key = 'Nav_Home'; Value = 'ホーム' }, @{ Key = 'Safety_Warn'; Value = '機械翻訳' })
|
||||
|
||||
$cases = @(
|
||||
@{ Name = 'a complete family with the ja safety key marked for review passes'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaMarked }; Gen = $true; ExpectFailure = $false }
|
||||
@{ Name = 'a reviewed ja safety key passes'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaReviewed }; Gen = $true; ExpectFailure = $false }
|
||||
@{ Name = 'a ja safety key with no review comment FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaUnmarked }; Gen = $true; ExpectFailure = $true }
|
||||
@{ Name = 'a ja safety key marked for review that is not the English verbatim FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaMarkedButTranslated }; Gen = $true; ExpectFailure = $true }
|
||||
@{ Name = 'a key missing from vi FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = @($vi[0]); 'Strings.ja.resx' = $jaMarked }; Gen = $true; ExpectFailure = $true }
|
||||
@{ Name = 'a key only ja has FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaMarked + @(@{ Key = 'Nav_Extra'; Value = 'x' }) }; Gen = $true; ExpectFailure = $true }
|
||||
@{ Name = 'a missing culture file FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi }; Gen = $true; ExpectFailure = $true }
|
||||
@{ Name = 'an empty neutral value FAILS'; Files = @{ 'Strings.resx' = @(@{ Key = 'Nav_Home'; Value = '' }); 'Strings.vi.resx' = @(@{ Key = 'Nav_Home'; Value = 'x' }); 'Strings.ja.resx' = @(@{ Key = 'Nav_Home'; Value = 'x' }) }; Gen = $true; ExpectFailure = $true }
|
||||
@{ Name = 'a key that is not an identifier FAILS'; Files = @{ 'Strings.resx' = @(@{ Key = 'Nav-Home'; Value = 'x' }); 'Strings.vi.resx' = @(@{ Key = 'Nav-Home'; Value = 'x' }); 'Strings.ja.resx' = @(@{ Key = 'Nav-Home'; Value = 'x' }) }; Gen = $false; ExpectFailure = $true }
|
||||
@{ Name = 'a stale Designer FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaMarked }; Gen = $true; Stale = $true; ExpectFailure = $true }
|
||||
@{ Name = 'a missing Designer FAILS'; Files = @{ 'Strings.resx' = $en; 'Strings.vi.resx' = $vi; 'Strings.ja.resx' = $jaMarked }; Gen = $false; ExpectFailure = $true }
|
||||
)
|
||||
|
||||
$failures = 0
|
||||
$reds = 0
|
||||
$i = 0
|
||||
foreach ($case in $cases) {
|
||||
$dir = Join-Path $temp ("case" + ($i++))
|
||||
New-Fixture $dir $case.Files
|
||||
# No -Namespace: the check side derives it the same way (no csproj -> the directory name).
|
||||
if ($case.Gen) { & $script:Gen -Resx (Join-Path $dir 'Strings.resx') *> $null }
|
||||
if ($case.ContainsKey('Stale') -and $case.Stale) { Add-Content (Join-Path $dir 'Strings.Designer.cs') '// edited by hand' }
|
||||
$problems = @(Test-ResxFamily (Join-Path $dir 'Strings.resx') @('vi', 'ja'))
|
||||
$failed = $problems.Count -gt 0
|
||||
if ($failed) { $reds++ }
|
||||
if ($failed -eq $case.ExpectFailure) {
|
||||
Write-Host " ok $($case.Name)" -ForegroundColor DarkGray
|
||||
}
|
||||
else {
|
||||
$expected = if ($case.ExpectFailure) { 'a failure' } else { 'a pass' }
|
||||
Write-Host " FAIL $($case.Name) — expected $expected, got: $($problems -join '; ')" -ForegroundColor Red
|
||||
$failures++
|
||||
}
|
||||
}
|
||||
|
||||
if ($failures -gt 0 -or $reds -lt 4) {
|
||||
Write-Host "RESX AUDIT SELF-TEST FAILED: $failures wrong verdict(s), $reds red case(s) (at least 4 required)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "resx-audit self-test: $($cases.Count) cases, $reds red, both directions" -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
finally {
|
||||
Remove-Item -Recurse -Force $temp -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
$families = @(Find-Families $Root)
|
||||
if ($families.Count -eq 0) {
|
||||
Write-Host 'RESX AUDIT FAILED: no .resx family under src/ — the gate would be vacuous (09_I18N names three languages; the first family arrived with P3 PR-2)' -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
$all = New-Object System.Collections.Generic.List[string]
|
||||
foreach ($f in $families) {
|
||||
$problems = @(Test-ResxFamily $f.FullName $Cultures)
|
||||
foreach ($p in $problems) { $all.Add($p) }
|
||||
}
|
||||
|
||||
if ($all.Count -gt 0) {
|
||||
Write-Host "RESX AUDIT FAILED: $($all.Count) problem(s)" -ForegroundColor Red
|
||||
foreach ($p in $all) { Write-Host " $p" -ForegroundColor Red }
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "resx-audit: ok — $($families.Count) family(ies), cultures $($Cultures -join ', '), accessors current" -ForegroundColor Green
|
||||
exit 0
|
||||
@@ -0,0 +1,121 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Generates the strongly-typed accessor (Strings.Designer.cs) for a neutral .resx, or checks that the
|
||||
committed one is current.
|
||||
|
||||
.DESCRIPTION
|
||||
docs/09_I18N.md: user-visible text is reached "through a generated strongly-typed class; no string
|
||||
literals in XAML/C#". Visual Studio's ResXFileCodeGenerator is a design-time tool and `dotnet build`
|
||||
never runs it, and MSBuild on .NET Core cannot generate the class itself (GenerateResource's
|
||||
StronglyTypedLanguage is unsupported there). So the accessor is GENERATED BY THIS SCRIPT AND COMMITTED,
|
||||
and tools/resx-audit.ps1 fails the build when the committed file is not what this script would write —
|
||||
which is what makes "generated" true rather than a word in a comment.
|
||||
|
||||
One property per key, sorted, `ResourceManager.GetString(key, Culture)`. The resource base name is
|
||||
`<Namespace>.<ClassName>`, which is what the SDK embeds a `<ClassName>.resx` sitting in the project
|
||||
directory as. The namespace comes from the csproj in the same directory (<RootNamespace>, else the
|
||||
project file name); a directory with no csproj — the audit's self-test fixtures — uses the directory name.
|
||||
|
||||
.PARAMETER Resx
|
||||
The NEUTRAL resx (Strings.resx, never Strings.vi.resx).
|
||||
|
||||
.PARAMETER Check
|
||||
Do not write; exit 1 when the committed Designer differs from what would be written (or is absent).
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Resx,
|
||||
|
||||
[string]$Namespace,
|
||||
|
||||
[string]$ClassName,
|
||||
|
||||
[switch]$Check
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$resxPath = (Resolve-Path $Resx).Path
|
||||
$dir = Split-Path $resxPath -Parent
|
||||
if (-not $ClassName) { $ClassName = [IO.Path]::GetFileNameWithoutExtension($resxPath) }
|
||||
if ($ClassName -match '\.') { throw "resx-gen: '$Resx' looks like a culture-specific file; pass the neutral one" }
|
||||
|
||||
if (-not $Namespace) {
|
||||
$csproj = Get-ChildItem $dir -Filter '*.csproj' -File | Select-Object -First 1
|
||||
if ($csproj) {
|
||||
[xml]$proj = Get-Content -Raw $csproj.FullName
|
||||
$rootNs = $proj.SelectSingleNode('//RootNamespace')
|
||||
$Namespace = if ($rootNs -and $rootNs.InnerText.Trim()) { $rootNs.InnerText.Trim() } else { [IO.Path]::GetFileNameWithoutExtension($csproj.Name) }
|
||||
}
|
||||
else {
|
||||
$Namespace = Split-Path $dir -Leaf
|
||||
}
|
||||
}
|
||||
|
||||
[xml]$doc = Get-Content -Raw $resxPath
|
||||
$keys = @($doc.root.data | ForEach-Object { $_.name } | Sort-Object -Culture 'en-US' -CaseSensitive)
|
||||
foreach ($k in $keys) {
|
||||
if ($k -notmatch '^[A-Za-z][A-Za-z0-9_]*$') { throw "resx-gen: key '$k' is not a C# identifier" }
|
||||
}
|
||||
|
||||
$lines = New-Object System.Collections.Generic.List[string]
|
||||
$lines.Add('// <auto-generated>')
|
||||
$lines.Add("// Generated by tools/resx-gen.ps1 from $([IO.Path]::GetFileName($resxPath)). DO NOT EDIT BY HAND:")
|
||||
$lines.Add('// run the tool, or `./build.ps1 check` will fail the resx-audit gate on the drift.')
|
||||
$lines.Add('// </auto-generated>')
|
||||
$lines.Add('')
|
||||
$lines.Add('#nullable enable')
|
||||
$lines.Add('')
|
||||
$lines.Add('using System.CodeDom.Compiler;')
|
||||
$lines.Add('using System.Globalization;')
|
||||
$lines.Add('using System.Resources;')
|
||||
$lines.Add('')
|
||||
$lines.Add("namespace $Namespace;")
|
||||
$lines.Add('')
|
||||
$lines.Add('/// <summary>The user-visible strings (docs/09_I18N.md), one property per key, read through the current UI culture.</summary>')
|
||||
$lines.Add('[GeneratedCode("tools/resx-gen.ps1", "1")]')
|
||||
$lines.Add("public static class $ClassName")
|
||||
$lines.Add('{')
|
||||
$lines.Add(' private static ResourceManager? _resourceManager;')
|
||||
$lines.Add('')
|
||||
$lines.Add(' /// <summary>The culture the properties read with; null means the current UI culture.</summary>')
|
||||
$lines.Add(' public static CultureInfo? Culture { get; set; }')
|
||||
$lines.Add('')
|
||||
$lines.Add(' public static ResourceManager ResourceManager =>')
|
||||
$lines.Add(" _resourceManager ??= new ResourceManager(""$Namespace.$ClassName"", typeof($ClassName).Assembly);")
|
||||
$lines.Add('')
|
||||
$lines.Add(' /// <summary>Every key, for an audit that walks them.</summary>')
|
||||
$lines.Add(' public static IReadOnlyList<string> Keys { get; } =')
|
||||
$lines.Add(' [')
|
||||
foreach ($k in $keys) { $lines.Add(" nameof($k),") }
|
||||
$lines.Add(' ];')
|
||||
foreach ($k in $keys) {
|
||||
$lines.Add('')
|
||||
$lines.Add(" public static string $k => ResourceManager.GetString(nameof($k), Culture) ?? nameof($k);")
|
||||
}
|
||||
$lines.Add('}')
|
||||
$text = ($lines -join "`r`n") + "`r`n"
|
||||
|
||||
$outPath = Join-Path $dir "$ClassName.Designer.cs"
|
||||
if ($Check) {
|
||||
if (-not (Test-Path $outPath)) {
|
||||
Write-Host "resx-gen: $outPath is missing — run tools/resx-gen.ps1 -Resx $Resx" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
$existing = [IO.File]::ReadAllText($outPath) -replace "`r`n", "`n"
|
||||
if ($existing -ne ($text -replace "`r`n", "`n")) {
|
||||
Write-Host "resx-gen: $outPath is not what $([IO.Path]::GetFileName($resxPath)) generates — run tools/resx-gen.ps1 -Resx $Resx" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "resx-gen: $outPath is current ($($keys.Count) key(s))" -ForegroundColor DarkGray
|
||||
exit 0
|
||||
}
|
||||
|
||||
[IO.File]::WriteAllText($outPath, $text, [Text.UTF8Encoding]::new($false))
|
||||
Write-Host "resx-gen: wrote $outPath ($($keys.Count) key(s), namespace $Namespace)" -ForegroundColor Green
|
||||
exit 0
|
||||
Reference in new issue
Block a user