Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

"What's new" slides after an update, with an animated image player

KnifeLemoncbdf6aaea423
diff --git a/.gitattributes b/.gitattributes
index e4cd7dff..a717a890 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -24,3 +24,5 @@
*.shx binary
*.dbf binary
*.kmz binary
+*.webp binary
+*.gif binary
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c5e7cebd..5a3c754d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -113,6 +113,35 @@ Explorer and startup entries), adds the Explorer menu extension and the bundled
`installer/Filee.iss` with a pinned, portable Inno Setup, and uploads `Filee-X.Y.Z-win-Setup.exe`, the portable zip and
their SHA-256 sums with release notes generated from the merged pull requests.
+### "What's new" slides for a release
+
+A release with features worth showing gets slides, which Filee shows once after updating to it (see
+[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#whats-new-slides)). A release without slides shows nothing.
+
+1. Write the CHANGELOG section with its `<!-- update -->` lines first: the slides are the visual version of it.
+ Pick 5–7 features; put the small ones together on a last "And more" slide.
+2. Add `src/Filee.App/Assets/WhatsNew/<version>/slides.json` (copy the previous one): per slide an `id`, the
+ `media` file and the i18n keys `whats_new.<version with _>.<id>.title` / `.text`.
+3. Add the keys to **every** `src/Filee.App/Assets/i18n/*.json` (a title and one or two short sentences; Chinese
+ without fullwidth `;` / `:`).
+4. Add a `Generate_<version>` method to `tests/Filee.App.Tests/WhatsNewMedia.cs` with a scene per slide (real
+ windows driven frame by frame; start each clip on a frame that explains the slide on its own, since reduced
+ motion shows only that one) and run it:
+
+ ```
+ dotnet build tests/Filee.App.Tests
+ tests/Filee.App.Tests/bin/Debug/net10.0/Filee.App.Tests.exe -method "Filee.App.Tests.WhatsNewMedia.*" -explicit only
+ ```
+
+ `FILEE_WHATSNEW_ONLY=crop,theme` renders only those clips. Each file must stay under 400 KB (the test checks it,
+ and `WhatsNewTests` checks all of them together stay under 2 MB); look at the first frames in
+ `bin/.../screenshots/whatsnew-*.png` and at the window in `whatsnew-window-*.png`.
+5. Run `dotnet test`: `WhatsNewTests` checks that every slide's media and keys exist.
+
+To try it in the app, build with the new version (`dotnet run --project src/Filee.App -p:Version=X.Y.Z`) against a
+data folder whose settings say an older version was seen (`"whatsNewSeenVersion": "1.0.0"`, `FILEE_DATA_DIR`), or
+open About → "What's new".
+
To try the installer locally run `pwsh build/build-installer.ps1` (output in `Releases/`). Setup needs administrator
rights; `pwsh build/build-installer.ps1 -CheckOnly` only compiles the script. The installer's engine page and some of
its texts are generated from `EngineDownloads` and the app's translations (`build/tools/make-installer-engines.cs`);
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 05338e5b..bc010671 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -131,6 +131,41 @@ Bump `AppSettings.CurrentSchemaVersion` and add a step to `SettingsMigrations` w
`theme.json` (`CustomTheme`, see [CUSTOM-THEMES.md](CUSTOM-THEMES.md)) overrides them with theme dictionaries in
application resources, which are searched first.
+## "What's new" slides
+
+After an update, Filee shows the new version's features once as slides (an animation or picture, a title, a line or
+two). The pieces:
+
+- `Assets/WhatsNew/<version>/slides.json` lists the slides: `id`, `media` (a file next to it), and the i18n keys of
+ `title` and `text` (`whats_new.<version>.<id>.title`, in every language file). `SlideDeck` (Controls) reads every
+ manifest from the assembly's resources; a broken one is skipped.
+- `AnimatedImage` shows GIF, animated WebP or a still picture. Avalonia's `Image` shows only the first frame, so
+ `AnimatedImageDecoder` decodes frames with Skia's `SKCodec`, which also says which earlier frame each one is drawn
+ over (`RequiredFrame`, disposal included). The file is copied into an `SKData` and each frame is decoded straight
+ into a `WriteableBitmap`'s framebuffer: no managed buffer is ever handed to native code. `FrameTimeline` keeps the
+ frame durations (0–10 ms counts as 100 ms, as in browsers) and the loop count. The animation pauses while the
+ control is hidden or its window is minimized, shows the first frame with reduced motion (`AutoPlay`), and gives
+ the decoder and bitmap back when it leaves the visual tree or its source changes.
+- `SlideShow` is the deck itself (picture, texts, position dots), built in code so `Filee.Setup` can link the same
+ files for a slideshow on its progress page (`AutoAdvance`). All slides' texts sit in one grid cell, only the
+ current one visible, so the height is the tallest slide's and the window doesn't jump.
+- `WhatsNewWindow` adds the card, ✕, Previous / Next ("Get started" on the last slide), ←/→ and Esc.
+- `WhatsNewService` decides at start-up, before the first run is marked complete:
+ - a fresh install (first run not completed) needs no slides, as the first-run setup introduces Filee; its
+ version is stored as seen;
+ - otherwise `AppSettings.WhatsNewSeenVersion` (null in settings older than the slides, which means "updated")
+ is compared with the running version, and the newest deck after it, up to this version, is shown;
+ - the same version or a downgrade shows nothing and never lowers what was seen; an update without a deck is
+ stored as seen quietly.
+ The version is stored when the window opens. A start in the background (`--background` at sign-in, or the
+ Explorer menu) keeps the deck until `WindowService.ShowMain` raises `MainShown`; the installer starts an updated
+ Filee with `--background --whats-new`, which shows it at once. About → "What's new in Filee X" opens the newest
+ deck again.
+
+The `<!-- update -->` lines of CHANGELOG.md are the other half: the update card shows them for a version that isn't
+installed yet; the slides introduce the installed one. The demo animations are rendered by
+`tests/Filee.App.Tests/WhatsNewMedia.cs` from the real windows (see CONTRIBUTING.md, "Releasing").
+
## Command line and watch folders
- `Filee.Cli` (`filee-cli.exe`, run as `filee` through `cli\filee.cmd`, which Setup can put on PATH) composes the same
diff --git a/installer/Filee.iss b/installer/Filee.iss
index 473aa0d9..98d814ec 100644
--- a/installer/Filee.iss
+++ b/installer/Filee.iss
@@ -464,14 +464,14 @@ begin
end;
// Starts Filee as the signed-in user (not elevated) with the choices made in the wizard. An update starts it in
-// the tray, as it was running before.
+// the tray, as it was running before, and shows the new version's "What's new" slides (the user just updated).
procedure StartFilee;
var
Parameters: String;
ResultCode: Integer;
begin
if WasInstalled then
- Parameters := '--background'
+ Parameters := '--background --whats-new'
else
Parameters := '--install-engines=' + SelectedEngines +
' --start-with-windows=' + OnOff(WizardIsTaskSelected('startup')) +
diff --git a/src/Filee.App/App.axaml.cs b/src/Filee.App/App.axaml.cs
index 5ae7e683..2c24d28f 100644
--- a/src/Filee.App/App.axaml.cs
+++ b/src/Filee.App/App.axaml.cs
@@ -146,6 +146,11 @@ public partial class App : Application
AppHost.Get<WatchFolderService>().DisposeAsync().AsTask().Wait(TimeSpan.FromSeconds(5));
};
+ // Before HandleCommandLine marks the first run complete: a fresh install gets no slides. Without the main
+ // window (sign-in, the Explorer menu) they wait until the user opens Filee, unless the installer asked for them.
+ AppHost.Get<WhatsNewService>().CheckAtStartup(
+ background: Program.Options.Background && !Program.Options.ShowSettings && !Program.Options.WhatsNew
+ || Program.Options.ConvertFiles.Count > 0);
HandleCommandLine(Program.Options, firstLaunch: true);
if (OperatingSystem.IsMacOS())
this.TryGetFeature<IActivatableLifetime>()?.Activated += (_, e) =>
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/browser.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/browser.webp
new file mode 100644
index 00000000..d710ea37
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/browser.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp
new file mode 100644
index 00000000..c0509667
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/flip.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/flip.webp
new file mode 100644
index 00000000..5cf3f69d
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/flip.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/formats.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/formats.webp
new file mode 100644
index 00000000..fd12a052
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/formats.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/languages.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/languages.webp
new file mode 100644
index 00000000..7d09b3fb
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/languages.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/more.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/more.webp
new file mode 100644
index 00000000..adbe5e03
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/more.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json b/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
new file mode 100644
index 00000000..dd4f662f
--- /dev/null
+++ b/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
@@ -0,0 +1,12 @@
+{
+ "version": "2.0.0",
+ "slides": [
+ { "id": "browser", "media": "browser.webp", "poster": 52, "title": "whats_new.2_0_0.browser.title", "text": "whats_new.2_0_0.browser.text" },
+ { "id": "flip", "media": "flip.webp", "poster": 75, "title": "whats_new.2_0_0.flip.title", "text": "whats_new.2_0_0.flip.text" },
+ { "id": "formats", "media": "formats.webp", "title": "whats_new.2_0_0.formats.title", "text": "whats_new.2_0_0.formats.text" },
+ { "id": "crop", "media": "crop.webp", "title": "whats_new.2_0_0.crop.title", "text": "whats_new.2_0_0.crop.text" },
+ { "id": "theme", "media": "theme.webp", "title": "whats_new.2_0_0.theme.title", "text": "whats_new.2_0_0.theme.text" },
+ { "id": "languages", "media": "languages.webp", "title": "whats_new.2_0_0.languages.title", "text": "whats_new.2_0_0.languages.text" },
+ { "id": "more", "media": "more.webp", "title": "whats_new.2_0_0.more.title", "text": "whats_new.2_0_0.more.text" }
+ ]
+}
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/theme.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/theme.webp
new file mode 100644
index 00000000..a63e158c
Binary files /dev/null and b/src/Filee.App/Assets/WhatsNew/2.0.0/theme.webp differ
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json
index bfa0d9d6..eb2bae6c 100644
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@ -791,5 +791,25 @@
"watch.status_watching": "Watching",
"watch.status_starting": "Starting…",
"watch.status_error": "Can't watch this folder: {0}",
- "watch.cli_hint": "Also on the command line: filee watch <folder> --to <format>"
+ "watch.cli_hint": "Also on the command line: filee watch <folder> --to <format>",
+
+ "whats_new.title": "What's new in Filee {0}",
+ "whats_new.previous": "Previous",
+ "whats_new.next": "Next",
+ "whats_new.done": "Get started",
+ "whats_new.about_link": "What's new in Filee {0}",
+ "whats_new.2_0_0.browser.title": "Drop straight from your browser",
+ "whats_new.2_0_0.browser.text": "Hold the shortcut and drag a picture or a file link out of a web page. The donut opens, saves it and converts it.",
+ "whats_new.2_0_0.flip.title": "The donut has a back face",
+ "whats_new.2_0_0.flip.text": "Press Tab or turn the mouse wheel while the donut is open to flip it over to more presets.",
+ "whats_new.2_0_0.formats.title": "More formats",
+ "whats_new.2_0_0.formats.text": "Web archives (MHTML), OFD e-invoices, Shapefile, GeoJSON, KML and GPX maps, JPEG XR, FBX models and POTM templates.",
+ "whats_new.2_0_0.crop.title": "Crop before you convert",
+ "whats_new.2_0_0.crop.text": "The Crop slice opens your pictures one by one. Drag the frame, pick a ratio, and only that part is saved.",
+ "whats_new.2_0_0.theme.title": "Softer, and in your colours",
+ "whats_new.2_0_0.theme.text": "The donut's slices round off with Softness, and a theme.json file can recolour all of Filee.",
+ "whats_new.2_0_0.languages.title": "Filee speaks more languages",
+ "whats_new.2_0_0.languages.text": "Spanish, Hindi, Japanese and Russian join English, Korean, Chinese and Polish.",
+ "whats_new.2_0_0.more.title": "And a little more",
+ "whats_new.2_0_0.more.text": "Reset a single donut to its defaults, search your whole history, and convert Gujarati, Hindi or Arabic documents through LibreOffice."
}
diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.json
index e40089e3..04ccec81 100644
--- a/src/Filee.App/Assets/i18n/es.json
+++ b/src/Filee.App/Assets/i18n/es.json
@@ -771,5 +771,25 @@
"watch.status_watching": "Supervisando",
"watch.status_starting": "Iniciando…",
"watch.status_error": "No se puede supervisar esta carpeta: {0}",
- "watch.cli_hint": "También en la línea de comandos: filee watch <carpeta> --to <formato>"
+ "watch.cli_hint": "También en la línea de comandos: filee watch <carpeta> --to <formato>",
+
+ "whats_new.title": "Novedades de Filee {0}",
+ "whats_new.previous": "Anterior",
+ "whats_new.next": "Siguiente",
+ "whats_new.done": "Empezar",
+ "whats_new.about_link": "Novedades de Filee {0}",
+ "whats_new.2_0_0.browser.title": "Suelta directamente desde el navegador",
+ "whats_new.2_0_0.browser.text": "Mantén el atajo y arrastra una imagen o un enlace a un archivo desde una página web. El menú circular se abre, lo guarda y lo convierte.",
+ "whats_new.2_0_0.flip.title": "El menú circular tiene reverso",
+ "whats_new.2_0_0.flip.text": "Con el menú abierto, pulsa Tab o gira la rueda del ratón para darle la vuelta y ver más ajustes.",
+ "whats_new.2_0_0.formats.title": "Más formatos",
+ "whats_new.2_0_0.formats.text": "Archivos web (MHTML), facturas electrónicas OFD, mapas Shapefile, GeoJSON, KML y GPX, JPEG XR, modelos FBX y plantillas POTM.",
+ "whats_new.2_0_0.crop.title": "Recorta antes de convertir",
+ "whats_new.2_0_0.crop.text": "La porción Recortar abre tus imágenes una a una. Arrastra el marco, elige una proporción y solo se guarda esa parte.",
+ "whats_new.2_0_0.theme.title": "Más suave y con tus colores",
+ "whats_new.2_0_0.theme.text": "Las porciones del menú circular siguen el Redondeo, y un archivo theme.json puede cambiar los colores de todo Filee.",
+ "whats_new.2_0_0.languages.title": "Filee habla más idiomas",
+ "whats_new.2_0_0.languages.text": "El español, el hindi, el japonés y el ruso se suman al inglés, el coreano, el chino y el polaco.",
+ "whats_new.2_0_0.more.title": "Y un poco más",
+ "whats_new.2_0_0.more.text": "Restablece un solo menú circular, busca en todo tu historial y convierte documentos en guyaratí, hindi o árabe con LibreOffice."
}
diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.json
index 71e1683e..96147549 100644
--- a/src/Filee.App/Assets/i18n/hi.json
+++ b/src/Filee.App/Assets/i18n/hi.json
@@ -771,5 +771,25 @@
"watch.status_watching": "देख रहा है",
"watch.status_starting": "शुरू हो रहा है…",
"watch.status_error": "इस फ़ोल्डर को नहीं देखा जा सकता: {0}",
- "watch.cli_hint": "कमांड लाइन पर भी: filee watch <folder> --to <format>"
+ "watch.cli_hint": "कमांड लाइन पर भी: filee watch <folder> --to <format>",
+
+ "whats_new.title": "Filee {0} में नया क्या है",
+ "whats_new.previous": "पिछला",
+ "whats_new.next": "अगला",
+ "whats_new.done": "शुरू करें",
+ "whats_new.about_link": "Filee {0} में नया क्या है",
+ "whats_new.2_0_0.browser.title": "सीधे ब्राउज़र से छोड़ें",
+ "whats_new.2_0_0.browser.text": "शॉर्टकट दबाए रखें और किसी वेब पेज से चित्र या फ़ाइल का लिंक खींचें। डोनट खुलता है, उसे सहेजता है और बदल देता है।",
+ "whats_new.2_0_0.flip.title": "डोनट का अब पिछला हिस्सा भी है",
+ "whats_new.2_0_0.flip.text": "डोनट खुला हो तब Tab दबाएँ या माउस व्हील घुमाएँ, वह पलटकर और प्रीसेट दिखाता है।",
+ "whats_new.2_0_0.formats.title": "और फ़ॉर्मैट",
+ "whats_new.2_0_0.formats.text": "वेब आर्काइव (MHTML), OFD ई-इनवॉइस, Shapefile, GeoJSON, KML और GPX नक्शे, JPEG XR, FBX मॉडल और POTM टेम्पलेट।",
+ "whats_new.2_0_0.crop.title": "बदलने से पहले क्रॉप करें",
+ "whats_new.2_0_0.crop.text": "क्रॉप स्लाइस आपके चित्र एक-एक करके खोलता है। फ़्रेम खींचें, अनुपात चुनें, और सिर्फ़ वही हिस्सा सहेजा जाता है।",
+ "whats_new.2_0_0.theme.title": "ज़्यादा कोमल, आपके रंगों में",
+ "whats_new.2_0_0.theme.text": "डोनट की स्लाइसें कोमलता के साथ गोल होती हैं, और एक theme.json फ़ाइल पूरे Filee के रंग बदल सकती है।",
+ "whats_new.2_0_0.languages.title": "Filee अब और भाषाएँ बोलता है",
+ "whats_new.2_0_0.languages.text": "अंग्रेज़ी, कोरियाई, चीनी और पोलिश के साथ अब स्पैनिश, हिन्दी, जापानी और रूसी भी।",
+ "whats_new.2_0_0.more.title": "और भी थोड़ा",
+ "whats_new.2_0_0.more.text": "एक ही डोनट को डिफ़ॉल्ट पर रीसेट करें, पूरा इतिहास खोजें, और गुजराती, हिन्दी या अरबी दस्तावेज़ LibreOffice से बदलें।"
}
diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.json
index ac5aa270..d410f937 100644
--- a/src/Filee.App/Assets/i18n/ja.json
+++ b/src/Filee.App/Assets/i18n/ja.json
@@ -771,5 +771,25 @@
"watch.status_watching": "監視中",
"watch.status_starting": "開始中…",
"watch.status_error": "このフォルダーを監視できません:{0}",
- "watch.cli_hint": "コマンドラインからも使えます:filee watch <folder> --to <format>"
+ "watch.cli_hint": "コマンドラインからも使えます:filee watch <folder> --to <format>",
+
+ "whats_new.title": "Filee {0} の新機能",
+ "whats_new.previous": "前へ",
+ "whats_new.next": "次へ",
+ "whats_new.done": "はじめる",
+ "whats_new.about_link": "Filee {0} の新機能",
+ "whats_new.2_0_0.browser.title": "ブラウザーから直接ドロップ",
+ "whats_new.2_0_0.browser.text": "ショートカットを押しながら、Web ページの画像やファイルへのリンクをドラッグ。ドーナツメニューが開き、保存して変換します。",
+ "whats_new.2_0_0.flip.title": "ドーナツに裏面ができました",
+ "whats_new.2_0_0.flip.text": "ドーナツメニューを開いたまま Tab キーを押すかマウスホイールを回すと、裏返して別のプリセットを使えます。",
+ "whats_new.2_0_0.formats.title": "対応形式が増えました",
+ "whats_new.2_0_0.formats.text": "Web アーカイブ (MHTML)、OFD 電子請求書、Shapefile・GeoJSON・KML・GPX の地図、JPEG XR、FBX モデル、POTM テンプレート。",
+ "whats_new.2_0_0.crop.title": "変換の前にトリミング",
+ "whats_new.2_0_0.crop.text": "「トリミング」で画像を 1 枚ずつ開けます。枠をドラッグして比率を選ぶと、その部分だけを保存します。",
+ "whats_new.2_0_0.theme.title": "やわらかく、好きな色に",
+ "whats_new.2_0_0.theme.text": "ドーナツの各スライスが「角の丸み」に合わせて丸くなり、theme.json ファイルで Filee 全体の色を変えられます。",
+ "whats_new.2_0_0.languages.title": "対応言語が増えました",
+ "whats_new.2_0_0.languages.text": "英語、韓国語、中国語、ポーランド語に、スペイン語、ヒンディー語、日本語、ロシア語が加わりました。",
+ "whats_new.2_0_0.more.title": "ほかにも",
+ "whats_new.2_0_0.more.text": "ドーナツを 1 つだけ既定に戻す、履歴全体を検索する、グジャラート語・ヒンディー語・アラビア語の文書を LibreOffice で変換する、など。"
}
diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json
index 621daa87..624041ab 100644
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@ -791,5 +791,25 @@
"watch.status_watching": "감시 중",
"watch.status_starting": "시작하는 중…",
"watch.status_error": "이 폴더를 감시할 수 없어요: {0}",
- "watch.cli_hint": "명령줄에서도 쓸 수 있어요: filee watch <폴더> --to <형식>"
+ "watch.cli_hint": "명령줄에서도 쓸 수 있어요: filee watch <폴더> --to <형식>",
+
+ "whats_new.title": "Filee {0}의 새 기능",
+ "whats_new.previous": "이전",
+ "whats_new.next": "다음",
+ "whats_new.done": "시작하기",
+ "whats_new.about_link": "Filee {0}의 새 기능",
+ "whats_new.2_0_0.browser.title": "브라우저에서 바로 드롭",
+ "whats_new.2_0_0.browser.text": "단축키를 누른 채 웹 페이지의 그림이나 파일 링크를 끌어 보세요. 원형 툴바가 열리고, 저장한 뒤 변환해요.",
+ "whats_new.2_0_0.flip.title": "원형 툴바에 뒷면이 생겼어요",
+ "whats_new.2_0_0.flip.text": "툴바가 열려 있을 때 Tab 키를 누르거나 마우스 휠을 돌리면 뒤집혀서 다른 프리셋이 나와요.",
+ "whats_new.2_0_0.formats.title": "더 많은 형식",
+ "whats_new.2_0_0.formats.text": "웹 보관 파일(MHTML), OFD 전자 세금계산서, Shapefile·GeoJSON·KML·GPX 지도, JPEG XR, FBX 모델, POTM 서식 파일.",
+ "whats_new.2_0_0.crop.title": "변환하기 전에 자르기",
+ "whats_new.2_0_0.crop.text": "자르기 조각을 고르면 그림이 한 장씩 열려요. 틀을 끌고 비율을 고르면 그 부분만 저장해요.",
+ "whats_new.2_0_0.theme.title": "더 말랑하게, 내 색으로",
+ "whats_new.2_0_0.theme.text": "원형 툴바 조각이 말랑함에 맞춰 둥글어지고, theme.json 파일로 Filee 전체의 색을 바꿀 수 있어요.",
+ "whats_new.2_0_0.languages.title": "더 많은 언어",
+ "whats_new.2_0_0.languages.text": "영어, 한국어, 중국어, 폴란드어에 스페인어, 힌디어, 일본어, 러시아어가 더해졌어요.",
+ "whats_new.2_0_0.more.title": "그리고 조금 더",
+ "whats_new.2_0_0.more.text": "원형 툴바 하나만 기본값으로 초기화하고, 기록 전체를 검색하고, 구자라트어·힌디어·아랍어 문서를 LibreOffice로 변환할 수 있어요."
}
diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.json
index 71ed7976..eeae1029 100644
--- a/src/Filee.App/Assets/i18n/pl.json
+++ b/src/Filee.App/Assets/i18n/pl.json
@@ -791,5 +791,25 @@
"watch.status_watching": "Obserwuję",
"watch.status_starting": "Uruchamianie…",
"watch.status_error": "Nie można obserwować tego folderu: {0}",
- "watch.cli_hint": "Także w wierszu poleceń: filee watch <folder> --to <format>"
+ "watch.cli_hint": "Także w wierszu poleceń: filee watch <folder> --to <format>",
+
+ "whats_new.title": "Nowości w Filee {0}",
+ "whats_new.previous": "Wstecz",
+ "whats_new.next": "Dalej",
+ "whats_new.done": "Zaczynamy",
+ "whats_new.about_link": "Nowości w Filee {0}",
+ "whats_new.2_0_0.browser.title": "Upuszczanie prosto z przeglądarki",
+ "whats_new.2_0_0.browser.text": "Przytrzymaj skrót i przeciągnij obraz lub link do pliku ze strony internetowej. Pasek-pierścień się otworzy, zapisze plik i go przekonwertuje.",
+ "whats_new.2_0_0.flip.title": "Pasek-pierścień ma drugą stronę",
+ "whats_new.2_0_0.flip.text": "Gdy pierścień jest otwarty, naciśnij Tab lub obróć kółko myszy, aby go odwrócić i zobaczyć więcej ustawień.",
+ "whats_new.2_0_0.formats.title": "Więcej formatów",
+ "whats_new.2_0_0.formats.text": "Archiwa stron (MHTML), e-faktury OFD, mapy Shapefile, GeoJSON, KML i GPX, JPEG XR, modele FBX i szablony POTM.",
+ "whats_new.2_0_0.crop.title": "Kadrowanie przed konwersją",
+ "whats_new.2_0_0.crop.text": "Wycinek Kadruj otwiera obrazy po kolei. Przeciągnij ramkę, wybierz proporcje, a zapisana zostanie tylko ta część.",
+ "whats_new.2_0_0.theme.title": "Łagodniej i w Twoich kolorach",
+ "whats_new.2_0_0.theme.text": "Wycinki pierścienia zaokrąglają się zgodnie z Zaokrągleniem, a plik theme.json może zmienić kolory całego Filee.",
+ "whats_new.2_0_0.languages.title": "Filee mówi w większej liczbie języków",
+ "whats_new.2_0_0.languages.text": "Do angielskiego, koreańskiego, chińskiego i polskiego dołączają hiszpański, hindi, japoński i rosyjski.",
+ "whats_new.2_0_0.more.title": "I jeszcze trochę",
+ "whats_new.2_0_0.more.text": "Przywróć domyślne ustawienia jednego pierścienia, przeszukuj całą historię i konwertuj dokumenty w gudżarati, hindi lub arabskim przez LibreOffice."
}
diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.json
index 14d06c2c..3ece7aea 100644
--- a/src/Filee.App/Assets/i18n/ru.json
+++ b/src/Filee.App/Assets/i18n/ru.json
@@ -791,5 +791,25 @@
"watch.status_watching": "Идёт наблюдение",
"watch.status_starting": "Запуск…",
"watch.status_error": "Не удаётся следить за этой папкой: {0}",
- "watch.cli_hint": "Также из командной строки: filee watch <папка> --to <формат>"
+ "watch.cli_hint": "Также из командной строки: filee watch <папка> --to <формат>",
+
+ "whats_new.title": "Что нового в Filee {0}",
+ "whats_new.previous": "Назад",
+ "whats_new.next": "Далее",
+ "whats_new.done": "Начать",
+ "whats_new.about_link": "Что нового в Filee {0}",
+ "whats_new.2_0_0.browser.title": "Перетаскивайте прямо из браузера",
+ "whats_new.2_0_0.browser.text": "Зажмите сочетание клавиш и перетащите картинку или ссылку на файл с веб-страницы. Круговое меню откроется, сохранит файл и конвертирует его.",
+ "whats_new.2_0_0.flip.title": "У кругового меню есть обратная сторона",
+ "whats_new.2_0_0.flip.text": "Когда меню открыто, нажмите Tab или прокрутите колесо мыши, чтобы перевернуть его и увидеть другие пресеты.",
+ "whats_new.2_0_0.formats.title": "Больше форматов",
+ "whats_new.2_0_0.formats.text": "Веб-архивы (MHTML), электронные счета OFD, карты Shapefile, GeoJSON, KML и GPX, JPEG XR, модели FBX и шаблоны POTM.",
+ "whats_new.2_0_0.crop.title": "Обрезка перед конвертацией",
+ "whats_new.2_0_0.crop.text": "Сектор «Обрезать» открывает картинки по одной. Перетащите рамку, выберите пропорции, и сохранится только эта часть.",
+ "whats_new.2_0_0.theme.title": "Мягче и в ваших цветах",
+ "whats_new.2_0_0.theme.text": "Секторы кругового меню скругляются вместе с настройкой «Скругление», а файл theme.json может перекрасить весь Filee.",
+ "whats_new.2_0_0.languages.title": "Filee говорит на большем числе языков",
+ "whats_new.2_0_0.languages.text": "К английскому, корейскому, китайскому и польскому добавились испанский, хинди, японский и русский.",
+ "whats_new.2_0_0.more.title": "И ещё немного",
+ "whats_new.2_0_0.more.text": "Сбрасывайте одно круговое меню к настройкам по умолчанию, ищите по всей истории и конвертируйте документы на гуджарати, хинди и арабском через LibreOffice."
}
diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json
index 1350bbf1..4792a256 100644
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@ -791,5 +791,25 @@
"watch.status_watching": "正在监视",
"watch.status_starting": "正在启动…",
"watch.status_error": "无法监视此文件夹:{0}",
- "watch.cli_hint": "也可以在命令行中使用:filee watch <文件夹> --to <格式>"
+ "watch.cli_hint": "也可以在命令行中使用:filee watch <文件夹> --to <格式>",
+
+ "whats_new.title": "Filee {0} 新功能",
+ "whats_new.previous": "上一页",
+ "whats_new.next": "下一页",
+ "whats_new.done": "开始使用",
+ "whats_new.about_link": "Filee {0} 新功能",
+ "whats_new.2_0_0.browser.title": "直接从浏览器拖放",
+ "whats_new.2_0_0.browser.text": "按住快捷键,从网页拖出图片或文件链接。环形工具栏会打开,保存并转换它。",
+ "whats_new.2_0_0.flip.title": "环形工具栏有了背面",
+ "whats_new.2_0_0.flip.text": "工具栏打开时按 Tab 键或滚动鼠标滚轮,即可翻到背面使用更多预设。",
+ "whats_new.2_0_0.formats.title": "更多格式",
+ "whats_new.2_0_0.formats.text": "网页存档 (MHTML)、OFD 电子发票、Shapefile、GeoJSON、KML 和 GPX 地图、JPEG XR、FBX 模型和 POTM 模板。",
+ "whats_new.2_0_0.crop.title": "转换前先裁剪",
+ "whats_new.2_0_0.crop.text": "“裁剪”会逐张打开图片。拖动选框、选择比例,只保存选中的部分。",
+ "whats_new.2_0_0.theme.title": "更柔和,用你的颜色",
+ "whats_new.2_0_0.theme.text": "环形工具栏的扇区会随“圆角”变圆,用 theme.json 文件还能更改整个 Filee 的颜色。",
+ "whats_new.2_0_0.languages.title": "支持更多语言",
+ "whats_new.2_0_0.languages.text": "在英语、韩语、中文和波兰语之外,新增西班牙语、印地语、日语和俄语。",
+ "whats_new.2_0_0.more.title": "还有更多",
+ "whats_new.2_0_0.more.text": "可以只把一个环形工具栏恢复默认、搜索全部历史记录,并通过 LibreOffice 转换古吉拉特语、印地语或阿拉伯语文档。"
}
diff --git a/src/Filee.App/Controls/AnimatedImage.cs b/src/Filee.App/Controls/AnimatedImage.cs
new file mode 100644
index 00000000..219f9837
--- /dev/null
+++ b/src/Filee.App/Controls/AnimatedImage.cs
@@ -0,0 +1,268 @@
+// Shows an animated GIF or WebP (Avalonia's Image shows only the first frame) or a still picture. Used by the
+// "What's new" slides; Filee.Setup links this file for the slideshow on its progress page, so it needs nothing but
+// Avalonia and SkiaSharp.
+//
+// Frames are decoded on demand into one WriteableBitmap (native memory), so a long animation costs one frame of memory.
+// The animation runs only while the control is in a visible window, and everything is released when it leaves the
+// visual tree (the window closed or the slide changed) or its source changes.
+
+using System.Diagnostics;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Media;
+using Avalonia.Media.Imaging;
+using Avalonia.Platform;
+using Avalonia.Threading;
+
+namespace Filee.App.Controls;
+
+public sealed class AnimatedImage : Control
+{
+ /// <summary>The picture: an <c>avares://</c> resource or a <c>file://</c> path.</summary>
+ public static readonly StyledProperty<Uri?> SourceProperty =
+ AvaloniaProperty.Register<AnimatedImage, Uri?>(nameof(Source));
+
+ public static readonly StyledProperty<Stretch> StretchProperty =
+ AvaloniaProperty.Register<AnimatedImage, Stretch>(nameof(Stretch), Stretch.Uniform);
+
+ /// <summary>False shows <see cref="PosterFrame"/> only (reduced motion).</summary>
+ public static readonly StyledProperty<bool> AutoPlayProperty =
+ AvaloniaProperty.Register<AnimatedImage, bool>(nameof(AutoPlay), true);
+
+ /// <summary>The frame shown while not playing: one that explains the animation on its own (0 = the first).</summary>
+ public static readonly StyledProperty<int> PosterFrameProperty =
+ AvaloniaProperty.Register<AnimatedImage, int>(nameof(PosterFrame));
+
+ /// <summary>How often a paused animation looks whether it became visible again.</summary>
+ private static readonly TimeSpan PausedPoll = TimeSpan.FromMilliseconds(400);
+
+ private AnimatedImageDecoder? _decoder;
+ private WriteableBitmap? _bitmap;
+ private FrameTimeline? _timeline;
+ private DispatcherTimer? _timer;
+ private TimeSpan _lastTick;
+ private bool _attached;
+ private int _shown = -1;
+ private readonly Stopwatch _stopwatch = Stopwatch.StartNew();
+
+ static AnimatedImage()
+ {
+ AffectsRender<AnimatedImage>(StretchProperty);
+ AffectsMeasure<AnimatedImage>(StretchProperty);
+ }
+
+ public Uri? Source
+ {
+ get => GetValue(SourceProperty);
+ set => SetValue(SourceProperty, value);
+ }
+
+ public Stretch Stretch
+ {
+ get => GetValue(StretchProperty);
+ set => SetValue(StretchProperty, value);
+ }
+
+ public bool AutoPlay
+ {
+ get => GetValue(AutoPlayProperty);
+ set => SetValue(AutoPlayProperty, value);
+ }
+
+ public int PosterFrame
+ {
+ get => GetValue(PosterFrameProperty);
+ set => SetValue(PosterFrameProperty, value);
+ }
+
+ /// <summary>The clock the animation runs on (tests replace it).</summary>
+ internal Func<TimeSpan> Clock { get; set; }
+
+ /// <summary>The frame shown, -1 when nothing is loaded.</summary>
+ public int CurrentFrame => _decoder is null ? -1 : _shown;
+
+ /// <summary>Frames of the loaded picture, 0 when nothing is loaded.</summary>
+ public int FrameCount => _decoder?.FrameCount ?? 0;
+
+ /// <summary>Whether a picture is decoded and held in memory.</summary>
+ public bool HasPicture => _decoder is not null;
+
+ /// <summary>Whether the animation is running (not paused, finished or a still picture).</summary>
+ public bool IsPlaying => _timer is { IsEnabled: true } && ShouldPlay();
+
+ /// <summary>Pixel size of the picture.</summary>
+ public PixelSize PixelSize => _decoder is null ? default : new PixelSize(_decoder.Width, _decoder.Height);
+
+ public AnimatedImage() => Clock = () => _stopwatch.Elapsed;
+
+ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnAttachedToVisualTree(e);
+ _attached = true;
+ Load();
+ }
+
+ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnDetachedFromVisualTree(e);
+ _attached = false;
+ Release();
+ }
+
+ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
+ {
+ base.OnPropertyChanged(change);
+ if (change.Property == SourceProperty)
+ {
+ Release();
+ if (_attached)
+ Load();
+ InvalidateMeasure();
+ InvalidateVisual();
+ }
+ else if (change.Property == AutoPlayProperty || change.Property == PosterFrameProperty)
+ {
+ // Reduced motion shows the poster, not wherever the animation happened to be; playing starts from the top.
+ if (_timeline is { } timeline)
+ {
+ timeline.Reset();
+ ShowFrame(AutoPlay ? 0 : Poster);
+ _lastTick = Clock();
+ }
+ Schedule();
+ }
+ else if (change.Property == IsVisibleProperty)
+ Schedule();
+ }
+
+ private void Load()
+ {
+ if (Source is not { } source || _decoder is not null)
+ return;
+ try
+ {
+ using var stream = Open(source);
+ _decoder = stream is null ? null : AnimatedImageDecoder.Open(stream);
+ }
+ catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or InvalidOperationException)
+ {
+ // A missing or unreadable picture leaves the control empty; the slide still has its text.
+ _decoder = null;
+ }
+ if (_decoder is null)
+ return;
+ _bitmap = new WriteableBitmap(new PixelSize(_decoder.Width, _decoder.Height), new Vector(96, 96),
+ PixelFormat.Bgra8888, AlphaFormat.Premul);
+ _timeline = new FrameTimeline(_decoder.Durations, _decoder.RepetitionCount);
+ if (!ShowFrame(0, freshBuffer: true) || !AutoPlay && Poster > 0 && !ShowFrame(Poster))
+ {
+ Release();
+ return;
+ }
+ _lastTick = Clock();
+ Schedule();
+ }
+
+ private static Stream? Open(Uri source) =>
+ source.Scheme switch
+ {
+ "avares" => AssetLoader.Exists(source) ? AssetLoader.Open(source) : null,
+ "file" => File.OpenRead(source.LocalPath),
+ _ => null,
+ };
+
+ /// <summary>Gives back the decoder and the frame memory; the next attach (or source) loads again.</summary>
+ private void Release()
+ {
+ _timer?.Stop();
+ _timer = null;
+ _timeline = null;
+ _decoder?.Dispose();
+ _decoder = null;
+ _bitmap?.Dispose();
+ _bitmap = null;
+ _shown = -1;
+ }
+
+ /// <summary><see cref="PosterFrame"/> within the picture's frames.</summary>
+ private int Poster => _decoder is null ? 0 : Math.Clamp(PosterFrame, 0, _decoder.FrameCount - 1);
+
+ private bool ShowFrame(int frame, bool freshBuffer = false)
+ {
+ if (_decoder is null || _bitmap is null)
+ return false;
+ if (frame == _shown && !freshBuffer)
+ return true;
+ bool decoded;
+ using (var buffer = _bitmap.Lock())
+ decoded = _decoder.Decode(frame, buffer.Address, buffer.RowBytes, freshBuffer);
+ _shown = decoded ? frame : -1;
+ InvalidateVisual();
+ return decoded;
+ }
+
+ /// <summary>
+ /// Whether the animation should run now: playing is allowed, there is something left to play, and the control is
+ /// on screen (visible, in a window that is shown and not minimized).
+ /// </summary>
+ private bool ShouldPlay() =>
+ AutoPlay && _decoder is { IsAnimated: true } && _timeline is { IsFinished: false } && IsOnScreen();
+
+ private bool IsOnScreen() =>
+ IsEffectivelyVisible && TopLevel.GetTopLevel(this) is { } top
+ && top.IsVisible && top is not Window { WindowState: WindowState.Minimized };
+
+ /// <summary>Starts, re-times or stops the timer for the next frame.</summary>
+ private void Schedule()
+ {
+ var animated = AutoPlay && _decoder is { IsAnimated: true } && _timeline is { IsFinished: false };
+ if (!animated)
+ {
+ _timer?.Stop();
+ return;
+ }
+ var wait = IsOnScreen() ? _timeline!.UntilNextFrame : PausedPoll;
+ if (wait == Timeout.InfiniteTimeSpan)
+ {
+ _timer?.Stop();
+ return;
+ }
+ if (_timer is null)
+ {
+ _timer = new DispatcherTimer(DispatcherPriority.Render);
+ _timer.Tick += (_, _) => Tick();
+ }
+ _timer.Interval = wait < TimeSpan.FromMilliseconds(5) ? TimeSpan.FromMilliseconds(5) : wait;
+ _timer.Start();
+ }
+
+ /// <summary>One step of the animation: the time since the last step moves the clock on, unless it is paused.</summary>
+ internal void Tick()
+ {
+ var now = Clock();
+ var elapsed = now - _lastTick;
+ _lastTick = now;
+ // Paused (hidden or minimized): the time passes without moving the animation, so it goes on where it stopped.
+ if (_timeline is not null && ShouldPlay() && _timeline.Advance(elapsed))
+ ShowFrame(_timeline.Frame);
+ Schedule();
+ }
+
+ protected override Size MeasureOverride(Size availableSize) =>
+ _bitmap is null ? default : Stretch.CalculateSize(availableSize, _bitmap.Size);
+
+ protected override Size ArrangeOverride(Size finalSize) =>
+ _bitmap is null ? finalSize : Stretch.CalculateSize(finalSize, _bitmap.Size);
+
+ public override void Render(DrawingContext context)
+ {
+ if (_bitmap is not { } bitmap || Bounds.Width <= 0 || Bounds.Height <= 0)
+ return;
+ var viewport = new Rect(Bounds.Size);
+ var scale = Stretch.CalculateScaling(Bounds.Size, bitmap.Size);
+ var scaled = bitmap.Size * scale;
+ var destination = viewport.CenterRect(new Rect(scaled)).Intersect(viewport);
+ var source = new Rect(bitmap.Size).CenterRect(new Rect(destination.Size / scale));
+ context.DrawImage(bitmap, source, destination);
+ }
+}
diff --git a/src/Filee.App/Controls/AnimatedImageDecoder.cs b/src/Filee.App/Controls/AnimatedImageDecoder.cs
new file mode 100644
index 00000000..88cd39f7
--- /dev/null
+++ b/src/Filee.App/Controls/AnimatedImageDecoder.cs
@@ -0,0 +1,220 @@
+// Frames of an animated GIF or WebP (or a still picture) for AnimatedImage, decoded by Skia's codec, and the clock
+// that says which frame is due. Kept free of app services: Filee.Setup links this file too (its progress slideshow).
+//
+// Native memory only: the encoded file is copied into an SKData (memory Skia owns) and frames are decoded straight into
+// the caller's pixel buffer (a WriteableBitmap's framebuffer, also native). No managed array is ever handed to Skia.
+
+using SkiaSharp;
+
+namespace Filee.App.Controls;
+
+/// <summary>
+/// Decodes the frames of one picture into a caller-owned BGRA (premultiplied) buffer. Skia's frame info says which
+/// earlier frame a frame is drawn over (<see cref="SKCodecFrameInfo.RequiredFrame"/>, which already accounts for the
+/// previous frame's disposal); the decoder keeps track of the frame the buffer holds and decodes the missing ones first.
+/// </summary>
+public sealed class AnimatedImageDecoder : IDisposable
+{
+ /// <summary>Larger pictures are refused (a slide's demo is a few hundred pixels wide).</summary>
+ public const long MaxPixels = 4096L * 4096L;
+
+ private SKData? _data;
+ private SKCodec? _codec;
+ private readonly SKCodecFrameInfo[] _frames;
+ private readonly int[] _durations;
+
+ /// <summary>The frame the caller's buffer holds, -1 when unknown.</summary>
+ private int _inBuffer = -1;
+
+ private AnimatedImageDecoder(SKData data, SKCodec codec)
+ {
+ _data = data;
+ _codec = codec;
+ Width = codec.Info.Width;
+ Height = codec.Info.Height;
+ // A still picture has no frame info: it is one frame.
+ _frames = codec.FrameCount > 1 ? codec.FrameInfo : [];
+ _durations = _frames.Length == 0 ? [0] : _frames.Select(f => NormalizeDuration(f.Duration)).ToArray();
+ RepetitionCount = _frames.Length > 1 ? codec.RepetitionCount : 0;
+ }
+
+ /// <summary>
+ /// Reads <paramref name="stream"/> (GIF, WebP, PNG, JPEG, …). Null when Skia can't read it or it is larger than
+ /// <see cref="MaxPixels"/>.
+ /// </summary>
+ public static AnimatedImageDecoder? Open(Stream stream)
+ {
+ // SKData.Create copies the stream into memory Skia allocates and frees.
+ var data = SKData.Create(stream);
+ if (data is null)
+ return null;
+ var codec = SKCodec.Create(data);
+ if (codec is null || codec.Info.Width <= 0 || codec.Info.Height <= 0 || (long)codec.Info.Width * codec.Info.Height > MaxPixels)
+ {
+ codec?.Dispose();
+ data.Dispose();
+ return null;
+ }
+ return new AnimatedImageDecoder(data, codec);
+ }
+
+ public int Width { get; }
+ public int Height { get; }
+
+ /// <summary>Number of frames; 1 for a still picture.</summary>
+ public int FrameCount => _durations.Length;
+
+ public bool IsAnimated => FrameCount > 1;
+
+ /// <summary>How often the animation repeats after the first play: -1 forever, 0 plays once (Skia's meaning).</summary>
+ public int RepetitionCount { get; }
+
+ /// <summary>How long each frame shows, in milliseconds (see <see cref="NormalizeDuration"/>).</summary>
+ public IReadOnlyList<int> Durations => _durations;
+
+ /// <summary>The pixel layout <see cref="Decode"/> writes: BGRA, premultiplied alpha.</summary>
+ public SKImageInfo Info => new(Width, Height, SKColorType.Bgra8888, SKAlphaType.Premul);
+
+ public bool IsDisposed => _codec is null;
+
+ /// <summary>
+ /// Browsers show frames that claim 0 or 10 ms for 100 ms (old GIFs rely on it); anything else shows at least 20 ms.
+ /// </summary>
+ public static int NormalizeDuration(int milliseconds) => milliseconds <= 10 ? 100 : Math.Max(20, milliseconds);
+
+ /// <summary>
+ /// Decodes <paramref name="frame"/> into <paramref name="pixels"/> (<see cref="Info"/>, <paramref name="rowBytes"/>
+ /// per row), which must stay valid for the call only. The buffer is expected to hold what the last call left in it;
+ /// pass <paramref name="freshBuffer"/> for a new or changed one. False when the data is broken.
+ /// </summary>
+ public bool Decode(int frame, IntPtr pixels, int rowBytes, bool freshBuffer = false)
+ {
+ ObjectDisposedException.ThrowIf(_codec is null, this);
+ ArgumentOutOfRangeException.ThrowIfNegative(frame);
+ ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(frame, FrameCount);
+ if (pixels == IntPtr.Zero || rowBytes < Width * 4)
+ throw new ArgumentException("The buffer is too small for the picture.", nameof(rowBytes));
+ if (freshBuffer)
+ _inBuffer = -1;
+ if (frame == _inBuffer)
+ return true;
+
+ if (_frames.Length == 0)
+ return Draw(frame: 0, prior: -1, pixels, rowBytes);
+
+ // The frames to draw, oldest first: back through the required frames to one drawn on a clear canvas or the
+ // one already in the buffer.
+ var chain = new Stack<int>();
+ for (var f = frame; ;)
+ {
+ chain.Push(f);
+ var required = _frames[f].RequiredFrame;
+ if (required < 0 || required == _inBuffer)
+ break;
+ f = required;
+ }
+ while (chain.TryPop(out var f))
+ {
+ if (!Draw(f, _frames[f].RequiredFrame, pixels, rowBytes))
+ return false;
+ }
+ return true;
+ }
+
+ private bool Draw(int frame, int prior, IntPtr pixels, int rowBytes)
+ {
+ if (prior < 0)
+ {
+ // A frame of its own starts from a transparent canvas (it may cover only part of it).
+ using var pixmap = new SKPixmap(Info, pixels, rowBytes);
+ pixmap.Erase(SKColors.Transparent);
+ }
+ var options = _frames.Length == 0 ? new SKCodecOptions() : new SKCodecOptions(frame, prior);
+ var result = _codec!.GetPixels(Info, pixels, rowBytes, options);
+ if (result is not (SKCodecResult.Success or SKCodecResult.IncompleteInput))
+ {
+ _inBuffer = -1;
+ return false;
+ }
+ _inBuffer = frame;
+ return true;
+ }
+
+ public void Dispose()
+ {
+ _codec?.Dispose();
+ _codec = null;
+ _data?.Dispose();
+ _data = null;
+ _inBuffer = -1;
+ }
+}
+
+/// <summary>
+/// Which frame of an animation is due: frame durations, looping (<see cref="AnimatedImageDecoder.RepetitionCount"/>)
+/// and the last frame staying once the plays are over.
+/// </summary>
+public sealed class FrameTimeline
+{
+ private readonly IReadOnlyList<int> _durations;
+ private readonly int _plays;
+ private readonly double _loopMilliseconds;
+ private double _inFrame;
+ private int _played;
+
+ /// <param name="durations">Milliseconds per frame.</param>
+ /// <param name="repetitionCount">Repeats after the first play; negative repeats forever.</param>
+ public FrameTimeline(IReadOnlyList<int> durations, int repetitionCount)
+ {
+ if (durations.Count == 0)
+ throw new ArgumentException("An animation has at least one frame.", nameof(durations));
+ _durations = durations;
+ _plays = repetitionCount < 0 ? 0 : repetitionCount + 1;
+ _loopMilliseconds = durations.Sum(d => (double)Math.Max(1, d));
+ }
+
+ /// <summary>The frame to show.</summary>
+ public int Frame { get; private set; }
+
+ /// <summary>True once every play is over (never for an endless animation or a single frame that never changes).</summary>
+ public bool IsFinished { get; private set; }
+
+ /// <summary>Time left until the next frame is due; <see cref="Timeout.InfiniteTimeSpan"/> when none will be.</summary>
+ public TimeSpan UntilNextFrame => IsFinished || _durations.Count < 2
+ ? Timeout.InfiniteTimeSpan
+ : TimeSpan.FromMilliseconds(Math.Max(0, Math.Max(1, _durations[Frame]) - _inFrame));
+
+ /// <summary>Moves the clock on; true when another frame is due.</summary>
+ public bool Advance(TimeSpan elapsed)
+ {
+ if (IsFinished || _durations.Count < 2 || elapsed <= TimeSpan.Zero)
+ return false;
+ // A long pause (the PC slept) doesn't spin through many loops: at most one loop is caught up.
+ _inFrame += Math.Min(elapsed.TotalMilliseconds, _loopMilliseconds);
+ var before = Frame;
+ while (_inFrame >= Math.Max(1, _durations[Frame]))
+ {
+ _inFrame -= Math.Max(1, _durations[Frame]);
+ if (Frame + 1 < _durations.Count)
+ Frame++;
+ else if (_plays == 0 || ++_played < _plays)
+ Frame = 0;
+ else
+ {
+ IsFinished = true;
+ _inFrame = 0;
+ break;
+ }
+ }
+ return Frame != before;
+ }
+
+ /// <summary>Back to the first frame, every play still to come.</summary>
+ public void Reset()
+ {
+ Frame = 0;
+ _inFrame = 0;
+ _played = 0;
+ IsFinished = false;
+ }
+}
diff --git a/src/Filee.App/Controls/SlideDeck.cs b/src/Filee.App/Controls/SlideDeck.cs
new file mode 100644
index 00000000..65b23f9b
--- /dev/null
+++ b/src/Filee.App/Controls/SlideDeck.cs
@@ -0,0 +1,112 @@
+// The "What's new" slides of a version: Assets/WhatsNew/<version>/slides.json lists each slide's picture and the i18n
+// keys of its title and text. Shared with Filee.Setup (linked file, assets linked under the same path), which shows the
+// newest deck while it copies files.
+//
+// {
+// "version": "2.0.0",
+// "slides": [
+// { "id": "formats", "media": "formats.webp", "title": "whats_new.2_0_0.formats.title", "text": "whats_new.2_0_0.formats.text" },
+// { "id": "flip", "media": "flip.webp", "poster": 75, "title": "...", "text": "..." }
+// ]
+// }
+
+using System.Text.Json;
+using Avalonia.Platform;
+
+namespace Filee.App.Controls;
+
+/// <summary>
+/// One slide: a picture or animation, a title and a line or two of text (i18n keys). <paramref name="PosterFrame"/> is
+/// the frame shown with reduced motion (the first unless the manifest says <c>"poster"</c>).
+/// </summary>
+public sealed record Slide(string Id, Uri Media, string TitleKey, string TextKey, int PosterFrame = 0);
+
+/// <summary>The slides introducing <see cref="Version"/>.</summary>
+public sealed record SlideDeck(Version Version, IReadOnlyList<Slide> Slides)
+{
+ /// <summary>Where the decks live inside an assembly's resources.</summary>
+ public const string Folder = "Assets/WhatsNew";
+
+ /// <summary>"2.0" for 2.0.0, "2.1.3" otherwise: how the window names the version.</summary>
+ public string DisplayVersion => Version.Build > 0 ? Version.ToString(3) : Version.ToString(2);
+
+ /// <summary>
+ /// Every deck in the resources of <paramref name="assembly"/> ("Filee", "Filee.Setup"), oldest first. A broken
+ /// manifest is skipped: the slides are a nicety and must never stop Filee from starting.
+ /// </summary>
+ public static IReadOnlyList<SlideDeck> LoadAll(string assembly)
+ {
+ var root = new Uri($"avares://{assembly}/{Folder}/");
+ IEnumerable<Uri> assets;
+ try
+ {
+ assets = AssetLoader.GetAssets(root, null).ToList();
+ }
+ catch (Exception ex) when (ex is IOException or InvalidOperationException or ArgumentException)
+ {
+ return [];
+ }
+ var decks = new List<SlideDeck>();
+ foreach (var manifest in assets.Where(u => u.AbsolutePath.EndsWith("/slides.json", StringComparison.OrdinalIgnoreCase)))
+ {
+ try
+ {
+ using var reader = new StreamReader(AssetLoader.Open(manifest));
+ if (Parse(reader.ReadToEnd(), new Uri(manifest, ".")) is { } deck)
+ decks.Add(deck);
+ }
+ catch (Exception ex) when (ex is IOException or JsonException or InvalidOperationException or ArgumentException)
+ {
+ }
+ }
+ return decks.OrderBy(d => d.Version).ToList();
+ }
+
+ /// <summary>
+ /// The deck a manifest describes, its pictures relative to <paramref name="folder"/>. Null without a valid version
+ /// or slides; slides missing a field are left out.
+ /// </summary>
+ public static SlideDeck? Parse(string json, Uri folder)
+ {
+ using var document = JsonDocument.Parse(json, new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip });
+ var root = document.RootElement;
+ if (root.ValueKind != JsonValueKind.Object
+ || !root.TryGetProperty("version", out var versionText) || versionText.ValueKind != JsonValueKind.String
+ || TryParseVersion(versionText.GetString()) is not { } version
+ || !root.TryGetProperty("slides", out var list) || list.ValueKind != JsonValueKind.Array)
+ return null;
+ var slides = new List<Slide>();
+ foreach (var item in list.EnumerateArray())
+ {
+ if (Text(item, "id") is { } id && Text(item, "media") is { } media
+ && Text(item, "title") is { } title && Text(item, "text") is { } text
+ && !media.Contains("..", StringComparison.Ordinal) && !Path.IsPathRooted(media))
+ slides.Add(new Slide(id, new Uri(folder, media), title, text,
+ item.TryGetProperty("poster", out var poster) && poster.ValueKind == JsonValueKind.Number
+ && poster.TryGetInt32(out var frame) && frame > 0 ? frame : 0));
+ }
+ return slides.Count == 0 ? null : new SlideDeck(version, slides);
+ }
+
+ /// <summary>
+ /// The deck to show after an update from <paramref name="seen"/> (exclusive; null: none seen) to
+ /// <paramref name="current"/> (inclusive): the newest in between, or null.
+ /// </summary>
+ public static SlideDeck? Newest(IEnumerable<SlideDeck> decks, Version? seen, Version current) =>
+ decks.Where(d => (seen is null || d.Version > seen) && d.Version <= current).MaxBy(d => d.Version);
+
+ /// <summary>"2.0.0" / "v2.0" / "2.0.0-beta" → 2.0.0 (three parts, so 2.0 and 2.0.0 compare equal).</summary>
+ public static Version? TryParseVersion(string? text)
+ {
+ if (string.IsNullOrWhiteSpace(text))
+ return null;
+ var core = text.Trim().TrimStart('v', 'V').Split('-', '+')[0];
+ return Version.TryParse(core.Contains('.') ? core : core + ".0", out var parsed)
+ ? new Version(parsed.Major, parsed.Minor, Math.Max(0, parsed.Build))
+ : null;
+ }
+
+ private static string? Text(JsonElement item, string name) =>
+ item.ValueKind == JsonValueKind.Object && item.TryGetProperty(name, out var value) && value.ValueKind == JsonValueKind.String
+ && value.GetString() is { Length: > 0 } text ? text : null;
+}
diff --git a/src/Filee.App/Controls/SlideShow.cs b/src/Filee.App/Controls/SlideShow.cs
new file mode 100644
index 00000000..3a5192bd
--- /dev/null
+++ b/src/Filee.App/Controls/SlideShow.cs
@@ -0,0 +1,244 @@
+// A deck of slides: the picture or animation on top, the title and a line or two below, dots for the position.
+// Built in code (no XAML) so Filee.Setup can link it as it is; it uses only the Soft look's resources (SoftRadius,
+// AccentBrush, SurfaceAltBrush, …) and the h2 / muted text classes, which both apps define.
+//
+// Filee's "What's new" window adds Previous / Next around it; Setup's progress page sets AutoAdvance instead.
+
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
+using Avalonia.Input;
+using Avalonia.Layout;
+using Avalonia.Media;
+using Avalonia.Threading;
+
+namespace Filee.App.Controls;
+
+public sealed class SlideShow : UserControl
+{
+ public static readonly StyledProperty<bool> PlayAnimationsProperty =
+ AvaloniaProperty.Register<SlideShow, bool>(nameof(PlayAnimations), true);
+
+ public static readonly StyledProperty<double> MediaWidthProperty =
+ AvaloniaProperty.Register<SlideShow, double>(nameof(MediaWidth), 480);
+
+ public static readonly StyledProperty<double> MediaHeightProperty =
+ AvaloniaProperty.Register<SlideShow, double>(nameof(MediaHeight), 270);
+
+ public static readonly StyledProperty<TimeSpan?> AutoAdvanceProperty =
+ AvaloniaProperty.Register<SlideShow, TimeSpan?>(nameof(AutoAdvance));
+
+ private readonly Border _frame;
+ private readonly AnimatedImage _media;
+ private readonly Grid _texts;
+ private readonly StackPanel _dots;
+ private readonly List<(TextBlock Title, TextBlock Text, StackPanel Panel)> _slideTexts = [];
+ private IReadOnlyList<Slide> _slides = [];
+ private Func<string, string> _localize = key => key;
+ private DispatcherTimer? _advance;
+ private int _index;
+
+ public SlideShow()
+ {
+ _media = new AnimatedImage { Stretch = Stretch.Uniform };
+ RenderOptions.SetBitmapInterpolationMode(_media, Avalonia.Media.Imaging.BitmapInterpolationMode.HighQuality);
+ _frame = new Border
+ {
+ ClipToBounds = true,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Child = _media,
+ };
+ _frame.Bind(Border.CornerRadiusProperty, _frame.GetResourceObservable("SoftRadius"));
+ _frame.Bind(Border.BackgroundProperty, _frame.GetResourceObservable("SurfaceAltBrush"));
+ _frame.Bind(Border.BorderBrushProperty, _frame.GetResourceObservable("SubtleBorderBrush"));
+ _frame.BorderThickness = new Thickness(1);
+
+ // Every slide's text sits in the same cell, only the current one visible: the height is the tallest slide's,
+ // so the window doesn't jump from slide to slide.
+ _texts = new Grid { Margin = new Thickness(8, 18, 8, 0) };
+ _dots = new StackPanel
+ {
+ Orientation = Orientation.Horizontal,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ Spacing = 6,
+ Margin = new Thickness(0, 16, 0, 0),
+ };
+ Content = new StackPanel { Children = { _frame, _texts, _dots } };
+ UpdateMediaSize();
+ }
+
+ /// <summary>False shows each animation's first frame (reduced motion).</summary>
+ public bool PlayAnimations
+ {
+ get => GetValue(PlayAnimationsProperty);
+ set => SetValue(PlayAnimationsProperty, value);
+ }
+
+ /// <summary>Size of the picture area in pixels (16:9 by default); the pictures are scaled to fit.</summary>
+ public double MediaWidth
+ {
+ get => GetValue(MediaWidthProperty);
+ set => SetValue(MediaWidthProperty, value);
+ }
+
+ public double MediaHeight
+ {
+ get => GetValue(MediaHeightProperty);
+ set => SetValue(MediaHeightProperty, value);
+ }
+
+ /// <summary>Moves to the next slide after this long, back to the first after the last (Setup). Null: never.</summary>
+ public TimeSpan? AutoAdvance
+ {
+ get => GetValue(AutoAdvanceProperty);
+ set => SetValue(AutoAdvanceProperty, value);
+ }
+
+ public IReadOnlyList<Slide> Slides => _slides;
+
+ /// <summary>The slide shown.</summary>
+ public int Index => _index;
+
+ public bool IsFirst => _index == 0;
+ public bool IsLast => _index >= _slides.Count - 1;
+
+ /// <summary>The picture of the current slide (for tests and the media generator).</summary>
+ public AnimatedImage Media => _media;
+
+ /// <summary>Raised after the slide changed.</summary>
+ public event EventHandler? IndexChanged;
+
+ /// <summary>Shows <paramref name="slides"/> from the first, their texts looked up with <paramref name="localize"/>.</summary>
+ public void Show(IReadOnlyList<Slide> slides, Func<string, string> localize)
+ {
+ _slides = slides;
+ _localize = localize;
+ _texts.Children.Clear();
+ _slideTexts.Clear();
+ foreach (var _ in slides)
+ {
+ var title = new TextBlock { TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center };
+ title.Classes.Add("h2");
+ var text = new TextBlock { TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 6, 0, 0) };
+ text.Classes.Add("muted");
+ var panel = new StackPanel { Children = { title, text } };
+ _slideTexts.Add((title, text, panel));
+ _texts.Children.Add(panel);
+ }
+ _dots.Children.Clear();
+ for (var i = 0; i < slides.Count; i++)
+ {
+ var target = i;
+ var dot = new Border { Height = 8, CornerRadius = new CornerRadius(4), Cursor = new Cursor(StandardCursorType.Hand) };
+ dot.PointerPressed += (_, e) =>
+ {
+ GoTo(target);
+ e.Handled = true;
+ };
+ _dots.Children.Add(dot);
+ }
+ _dots.IsVisible = slides.Count > 1;
+ RefreshTexts();
+ _index = -1;
+ GoTo(0);
+ }
+
+ /// <summary>Looks the texts up again (the UI language changed).</summary>
+ public void RefreshTexts()
+ {
+ for (var i = 0; i < _slideTexts.Count && i < _slides.Count; i++)
+ {
+ _slideTexts[i].Title.Text = _localize(_slides[i].TitleKey);
+ _slideTexts[i].Text.Text = _localize(_slides[i].TextKey);
+ }
+ }
+
+ public bool Next() => GoTo(_index + 1);
+
+ public bool Previous() => GoTo(_index - 1);
+
+ /// <summary>Shows slide <paramref name="index"/>; false when there is no such slide or it is already shown.</summary>
+ public bool GoTo(int index)
+ {
+ if (index < 0 || index >= _slides.Count || index == _index)
+ return false;
+ _index = index;
+ _media.PosterFrame = _slides[index].PosterFrame;
+ _media.Source = _slides[index].Media;
+ for (var i = 0; i < _slideTexts.Count; i++)
+ {
+ var current = i == index;
+ var panel = _slideTexts[i].Panel;
+ panel.Opacity = current ? 1 : 0;
+ panel.IsHitTestVisible = current;
+ Avalonia.Automation.AutomationProperties.SetAccessibilityView(panel,
+ current ? Avalonia.Automation.AccessibilityView.Content : Avalonia.Automation.AccessibilityView.Raw);
+ }
+ UpdateDots();
+ RestartAdvance();
+ IndexChanged?.Invoke(this, EventArgs.Empty);
+ return true;
+ }
+
+ private void UpdateDots()
+ {
+ for (var i = 0; i < _dots.Children.Count; i++)
+ {
+ var dot = (Border)_dots.Children[i];
+ var current = i == _index;
+ dot.Width = current ? 22 : 8;
+ dot.Bind(Border.BackgroundProperty, dot.GetResourceObservable(current ? "AccentBrush" : "SubtleBorderBrush"));
+ dot.Opacity = current ? 1 : 0.9;
+ }
+ }
+
+ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
+ {
+ base.OnPropertyChanged(change);
+ if (change.Property == PlayAnimationsProperty)
+ _media.AutoPlay = PlayAnimations;
+ else if (change.Property == MediaWidthProperty || change.Property == MediaHeightProperty)
+ UpdateMediaSize();
+ else if (change.Property == AutoAdvanceProperty)
+ RestartAdvance();
+ }
+
+ protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnDetachedFromVisualTree(e);
+ _advance?.Stop();
+ }
+
+ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnAttachedToVisualTree(e);
+ RestartAdvance();
+ }
+
+ private void UpdateMediaSize()
+ {
+ _frame.Width = MediaWidth;
+ _frame.Height = MediaHeight;
+ }
+
+ private void RestartAdvance()
+ {
+ _advance?.Stop();
+ if (AutoAdvance is not { } interval || interval <= TimeSpan.Zero || _slides.Count < 2 || TopLevel.GetTopLevel(this) is null)
+ return;
+ _advance ??= new DispatcherTimer();
+ _advance.Interval = interval;
+ _advance.Tick -= OnAdvance;
+ _advance.Tick += OnAdvance;
+ _advance.Start();
+ }
+
+ private void OnAdvance(object? sender, EventArgs e)
+ {
+ if (!Next())
+ GoTo(0);
+ }
+
+ /// <summary>One automatic step, as the timer takes it (tests).</summary>
+ internal void AdvanceNow() => OnAdvance(this, EventArgs.Empty);
+}
diff --git a/src/Filee.App/Services/AppHost.cs b/src/Filee.App/Services/AppHost.cs
index 2294da85..f06ce0dc 100644
--- a/src/Filee.App/Services/AppHost.cs
+++ b/src/Filee.App/Services/AppHost.cs
@@ -71,6 +71,7 @@ public static class AppHost
services.AddSingleton<UpdateService>();
services.AddSingleton<MemoryTrimmer>();
services.AddSingleton<WindowService>();
+ services.AddSingleton<WhatsNewService>();
_services = services.BuildServiceProvider();
return _services;
diff --git a/src/Filee.App/Services/CommandLine.cs b/src/Filee.App/Services/CommandLine.cs
index d9a9c6f5..ac469e6d 100644
--- a/src/Filee.App/Services/CommandLine.cs
+++ b/src/Filee.App/Services/CommandLine.cs
@@ -1,6 +1,8 @@
// Command line options:
// Filee.exe open the main window
// Filee.exe --background start in the tray only (used by "start with Windows")
+// Filee.exe --whats-new with --background: show this version's "What's new" slides anyway, if they
+// are due (the installer after an update the user started)
// Filee.exe --settings open the main window
// Filee.exe --convert a b ... open the donut for these files (Explorer context menu / Send To)
// Filee.exe --convert-list <file> same, with one path per line in a UTF-8 file (Windows 11 Explorer menu, for
@@ -22,6 +24,7 @@ namespace Filee.App.Services;
/// <param name="InstallEngines">Engine packages chosen in the installer; null when the option is absent.</param>
/// <param name="StartWithWindows">Value of <c>--start-with-windows</c>; null when absent.</param>
/// <param name="ContextMenu">Value of <c>--context-menu</c>; null when absent.</param>
+/// <param name="WhatsNew"><c>--whats-new</c>: due slides show even when starting in the background.</param>
public sealed record CommandLine(
bool Background,
bool ShowSettings,
@@ -31,7 +34,8 @@ public sealed record CommandLine(
bool UninstallCleanup = false,
IReadOnlyList<string>? InstallEngines = null,
bool? StartWithWindows = null,
- bool? ContextMenu = null)
+ bool? ContextMenu = null,
+ bool WhatsNew = false)
{
/// <summary>File name prefix of list files written by FileeExplorerMenu.dll (LIST_PREFIX there) into %TEMP%.</summary>
public const string ListFilePrefix = "Filee-convert-";
@@ -49,6 +53,7 @@ public sealed record CommandLine(
List<string>? engines = null;
bool? startWithWindows = null;
bool? contextMenu = null;
+ var whatsNew = false;
foreach (var arg in args)
{
@@ -81,6 +86,9 @@ public sealed record CommandLine(
case "--background":
background = true;
break;
+ case "--whats-new":
+ whatsNew = true;
+ break;
case "--settings":
settings = true;
break;
@@ -97,7 +105,7 @@ public sealed record CommandLine(
break;
}
}
- return new CommandLine(background, settings, files, listFile, quit, cleanup, engines, startWithWindows, contextMenu);
+ return new CommandLine(background, settings, files, listFile, quit, cleanup, engines, startWithWindows, contextMenu, whatsNew);
}
/// <summary>"--Name=Value" → ("--name", "Value"); "--name" → ("--name", null).</summary>
diff --git a/src/Filee.App/Services/WhatsNewService.cs b/src/Filee.App/Services/WhatsNewService.cs
new file mode 100644
index 00000000..04db38b7
--- /dev/null
+++ b/src/Filee.App/Services/WhatsNewService.cs
@@ -0,0 +1,115 @@
+// "What's new" slides after an update: decides once per start whether this version's slides are due, shows them when
+// the user sees Filee, and remembers the version so they show once.
+//
+// How an update is told from a fresh install: the first-run flag. A start before FirstRunCompleted is a new install
+// (the first-run setup introduces Filee; the slides would only repeat it), so the current version counts as seen.
+// After that, WhatsNewSeenVersion says which version's slides were seen; null means the settings come from a Filee
+// older than the slides, i.e. it was updated. A version at or below the one seen (same version, downgrade) shows nothing
+// and never lowers what was seen.
+
+using Avalonia.Threading;
+using Filee.App.Controls;
+using Filee.Core.Settings;
+using Microsoft.Extensions.Logging;
+
+namespace Filee.App.Services;
+
+public sealed class WhatsNewService(UserDataStore store, WindowService windows, ILogger<WhatsNewService> log)
+{
+ private IReadOnlyList<SlideDeck>? _decks;
+
+ /// <summary>The assembly whose resources hold the decks.</summary>
+ internal const string Assembly = "Filee";
+
+ /// <summary>Every deck Filee ships, oldest first.</summary>
+ public IReadOnlyList<SlideDeck> Decks => _decks ??= SlideDeck.LoadAll(Assembly);
+
+ /// <summary>The version running now (three parts).</summary>
+ internal Version CurrentVersion { get; set; } = SlideDeck.TryParseVersion(UpdateService.CurrentVersion) ?? new Version(0, 0, 0);
+
+ /// <summary>The deck waiting for the user to open Filee (it started in the background).</summary>
+ public SlideDeck? Pending { get; private set; }
+
+ /// <summary>The newest deck up to this version: what About → "What's new" shows. Null when there is none.</summary>
+ public SlideDeck? Latest => SlideDeck.Newest(Decks, seen: null, CurrentVersion);
+
+ /// <summary>What a start should do about the slides.</summary>
+ /// <param name="Show">The deck to show, if any.</param>
+ /// <param name="Remember">A version to store as seen right away (a fresh install, or an update without slides).</param>
+ internal readonly record struct Decision(SlideDeck? Show, Version? Remember);
+
+ /// <summary>The rules described at the top of this file, without side effects.</summary>
+ internal static Decision Decide(string? seenSetting, bool firstRunCompleted, Version current, IEnumerable<SlideDeck> decks)
+ {
+ if (!firstRunCompleted)
+ return new Decision(null, current);
+ var seen = SlideDeck.TryParseVersion(seenSetting);
+ if (seen is not null && current <= seen)
+ return new Decision(null, null);
+ var deck = SlideDeck.Newest(decks, seen, current);
+ return deck is null ? new Decision(null, current) : new Decision(deck, null);
+ }
+
+ /// <summary>
+ /// Called once at start-up, before the first run is marked complete. <paramref name="background"/> (started at
+ /// sign-in, or after an update without <c>--whats-new</c>) keeps the slides until the main window opens.
+ /// </summary>
+ public void CheckAtStartup(bool background)
+ {
+ Decision decision;
+ try
+ {
+ decision = Decide(store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, CurrentVersion, Decks);
+ }
+ catch (Exception ex) when (ex is not OutOfMemoryException)
+ {
+ log.LogWarning(ex, "Could not read the What's new slides");
+ return;
+ }
+ if (decision.Remember is { } remember)
+ Remember(remember);
+ if (decision.Show is not { } deck)
+ return;
+ log.LogInformation("What's new in {Version} is due ({Seen} seen before)", deck.Version.ToString(3),
+ store.Settings.WhatsNewSeenVersion ?? "nothing");
+ if (background)
+ {
+ Pending = deck;
+ windows.MainShown += OnMainShown;
+ }
+ else
+ // After the main window: the slides go on top of it.
+ DispatcherTimer.RunOnce(() => Show(deck), TimeSpan.FromMilliseconds(600));
+ }
+
+ private void OnMainShown(object? sender, EventArgs e)
+ {
+ windows.MainShown -= OnMainShown;
+ if (Pending is { } deck)
+ {
+ Pending = null;
+ Dispatcher.UIThread.Post(() => Show(deck), DispatcherPriority.Background);
+ }
+ }
+
+ /// <summary>Shows <paramref name="deck"/> (the latest one when null) and remembers it as seen.</summary>
+ public void Show(SlideDeck? deck = null)
+ {
+ deck ??= Latest;
+ if (deck is null)
+ return;
+ Pending = null;
+ windows.ShowWhatsNew(deck);
+ Remember(CurrentVersion > deck.Version ? CurrentVersion : deck.Version);
+ }
+
+ /// <summary>Stores <paramref name="version"/> as seen, unless a newer one already is.</summary>
+ private void Remember(Version version)
+ {
+ var seen = SlideDeck.TryParseVersion(store.Settings.WhatsNewSeenVersion);
+ if (seen is not null && seen >= version)
+ return;
+ store.Settings.WhatsNewSeenVersion = version.ToString(3);
+ store.SaveSettings();
+ }
+}
diff --git a/src/Filee.App/Services/WindowService.cs b/src/Filee.App/Services/WindowService.cs
index b2dc013e..54eea3e7 100644
--- a/src/Filee.App/Services/WindowService.cs
+++ b/src/Filee.App/Services/WindowService.cs
@@ -25,6 +25,7 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Mem
private EngineUpdateNoticeWindow? _engineNotice;
private FeedbackNoticeWindow? _feedbackNotice;
private FormatRequestNoticeWindow? _formatRequestNotice;
+ private WhatsNewWindow? _whatsNew;
internal FormatRequestNoticeWindow? FormatRequestNotice => _formatRequestNotice;
@@ -93,8 +94,40 @@ public sealed class WindowService(ILocalizer loc, IServiceProvider services, Mem
if (_main.WindowState == WindowState.Minimized)
_main.WindowState = WindowState.Normal;
_main.Activate();
+ MainShown?.Invoke(this, EventArgs.Empty);
}
+ /// <summary>Raised whenever <see cref="ShowMain"/> showed the main window (the user opened Filee).</summary>
+ public event EventHandler? MainShown;
+
+ /// <summary>
+ /// Shows a version's "What's new" slides, centred on the main window when it is open; a second call replaces the
+ /// open window's slides.
+ /// </summary>
+ public void ShowWhatsNew(Controls.SlideDeck deck)
+ {
+ _whatsNew?.Close();
+ Motion.Refresh();
+ var window = new WhatsNewWindow(deck, loc);
+ window.Closed += (_, _) =>
+ {
+ if (_whatsNew == window)
+ _whatsNew = null;
+ trimmer.Request();
+ };
+ _whatsNew = window;
+ if (_main is { IsVisible: true } main && main.WindowState != WindowState.Minimized)
+ {
+ window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
+ window.Show(main);
+ }
+ else
+ window.Show();
+ window.Activate();
+ }
+
+ internal WhatsNewWindow? WhatsNew => _whatsNew;
+
/// <summary>Opens the optional-engine choice (first run); a second call brings the open window to front.</summary>
/// <summary>
/// Shows the engine choice. With <paramref name="install"/> (packages picked in the installer) the downloads start
diff --git a/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs b/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
index 22a84c49..dcfb250f 100644
--- a/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/AboutPageViewModel.cs
@@ -14,13 +14,17 @@ public sealed partial class AboutPageViewModel : ObservableObject, IDisposable
private readonly ILocalizer _loc;
private readonly UserDataStore _store;
private readonly UpdateService _updates;
+ private readonly WhatsNewService? _whatsNew;
- public AboutPageViewModel(ILocalizer loc, UserDataStore store, UpdateService updates)
+ public AboutPageViewModel(ILocalizer loc, UserDataStore store, UpdateService updates, WhatsNewService? whatsNew = null)
{
_loc = loc;
_store = store;
_updates = updates;
+ _whatsNew = whatsNew;
Version = loc.Format("about.version", UpdateService.CurrentVersion);
+ if (whatsNew?.Latest is { } deck)
+ WhatsNewText = loc.Format("whats_new.about_link", deck.DisplayVersion);
_checkForUpdates = store.Settings.CheckForUpdates;
ShowUpdateState(updates.LatestVersion);
updates.PropertyChanged += OnUpdatesChanged;
@@ -29,6 +33,14 @@ public sealed partial class AboutPageViewModel : ObservableObject, IDisposable
public string Version { get; }
public string RepositoryUrl { get; } = UpdateService.RepositoryUrl;
+ /// <summary>"What's new in Filee 2.0": the slides of the newest version up to this one; null when there are none.</summary>
+ public string? WhatsNewText { get; }
+
+ public bool HasWhatsNew => WhatsNewText is not null;
+
+ [RelayCommand]
+ private void ShowWhatsNew() => _whatsNew?.Show();
+
/// <summary>The page is rebuilt on every visit; the update service lives on.</summary>
public void Dispose() => _updates.PropertyChanged -= OnUpdatesChanged;
diff --git a/src/Filee.App/Views/Pages/AboutPage.axaml b/src/Filee.App/Views/Pages/AboutPage.axaml
index 138e267f..3b476cd1 100644
--- a/src/Filee.App/Views/Pages/AboutPage.axaml
+++ b/src/Filee.App/Views/Pages/AboutPage.axaml
@@ -20,6 +20,13 @@
<TextBlock Text="{Binding RepositoryUrl}" Foreground="{DynamicResource AccentBrush}" />
</StackPanel>
</Button>
+ <!-- This version's "What's new" slides again -->
+ <Button x:Name="WhatsNewLink" Classes="ghost" Padding="0" Command="{Binding ShowWhatsNewCommand}" IsVisible="{Binding HasWhatsNew}">
+ <StackPanel Orientation="Horizontal" Spacing="6">
+ <PathIcon Width="13" Height="13" Data="{StaticResource Icon.Info}" Foreground="{DynamicResource AccentBrush}" />
+ <TextBlock Text="{Binding WhatsNewText}" Foreground="{DynamicResource AccentBrush}" />
+ </StackPanel>
+ </Button>
</StackPanel>
</StackPanel>
</Border>
diff --git a/src/Filee.App/Views/WhatsNewWindow.axaml b/src/Filee.App/Views/WhatsNewWindow.axaml
new file mode 100644
index 00000000..9245273b
--- /dev/null
+++ b/src/Filee.App/Views/WhatsNewWindow.axaml
@@ -0,0 +1,42 @@
+<!-- "What's new" after an update (WhatsNewService), and again from About: the version's slides with Previous / Next,
+ dots for the position, "Get started" on the last slide and ✕ at the top right. ←/→ move, Esc closes. -->
+<Window xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:c="using:Filee.App.Controls"
+ x:Class="Filee.App.Views.WhatsNewWindow"
+ Title="Filee"
+ Icon="avares://Filee/Assets/Icons/filee.ico"
+ Width="560"
+ SizeToContent="Height"
+ CanResize="False"
+ WindowDecorations="None"
+ Background="Transparent"
+ TransparencyLevelHint="Transparent"
+ WindowStartupLocation="CenterScreen">
+ <Border Classes="card" Margin="12" Padding="20,14,20,18">
+ <StackPanel>
+ <!-- Header: drag here to move the window -->
+ <DockPanel x:Name="Header" Background="Transparent" Margin="0,0,0,12">
+ <Button x:Name="CloseButton" DockPanel.Dock="Right" Classes="icon" Padding="6" VerticalAlignment="Center"
+ Click="OnClose" ToolTip.Tip="{DynamicResource common.close}">
+ <PathIcon Width="12" Height="12" Data="{StaticResource Icon.Close}" />
+ </Button>
+ <StackPanel Orientation="Horizontal" Spacing="8" VerticalAlignment="Center">
+ <Image Source="avares://Filee/Assets/Icons/filee.png" Width="20" Height="20" />
+ <TextBlock x:Name="HeaderText" FontWeight="SemiBold" VerticalAlignment="Center" />
+ </StackPanel>
+ </DockPanel>
+
+ <!-- The whole width of the card (560 - 2 × 12 margin - 2 × 20 padding), 16:9 -->
+ <c:SlideShow x:Name="Slides" MediaWidth="496" MediaHeight="279" />
+
+ <!-- Previous on the left (hidden on the first slide), Next / Get started on the right -->
+ <Grid ColumnDefinitions="*,*" Margin="0,18,0,0">
+ <Button x:Name="PreviousButton" HorizontalAlignment="Left" MinWidth="96" HorizontalContentAlignment="Center"
+ Content="{DynamicResource whats_new.previous}" Click="OnPrevious" />
+ <Button x:Name="PrimaryButton" Grid.Column="1" Classes="accent" HorizontalAlignment="Right" MinWidth="112"
+ HorizontalContentAlignment="Center" IsDefault="True" Click="OnPrimary" />
+ </Grid>
+ </StackPanel>
+ </Border>
+</Window>
diff --git a/src/Filee.App/Views/WhatsNewWindow.axaml.cs b/src/Filee.App/Views/WhatsNewWindow.axaml.cs
new file mode 100644
index 00000000..a0aa58d9
--- /dev/null
+++ b/src/Filee.App/Views/WhatsNewWindow.axaml.cs
@@ -0,0 +1,102 @@
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Filee.App.Controls;
+using Filee.App.Services;
+using Filee.Core.Localization;
+
+namespace Filee.App.Views;
+
+/// <summary>The slides of one version (<see cref="SlideDeck"/>) with their buttons and keys.</summary>
+public partial class WhatsNewWindow : Window
+{
+ private readonly ILocalizer? _loc;
+ private readonly SlideDeck? _deck;
+
+ public WhatsNewWindow() => InitializeComponent();
+
+ public WhatsNewWindow(SlideDeck deck, ILocalizer loc) : this()
+ {
+ _deck = deck;
+ _loc = loc;
+ Motion.Track(this);
+ Slides.PlayAnimations = Motion.Enabled;
+ Slides.IndexChanged += (_, _) => UpdateButtons();
+ Slides.Show(deck.Slides, key => loc[key]);
+ ShowTexts();
+ Motion.Changed += OnMotionChanged;
+ loc.LanguageChanged += OnLanguageChanged;
+ Closed += (_, _) =>
+ {
+ Motion.Changed -= OnMotionChanged;
+ loc.LanguageChanged -= OnLanguageChanged;
+ };
+ Header.PointerPressed += OnHeaderPressed;
+ Opened += (_, _) => PrimaryButton.Focus();
+ }
+
+ /// <summary>The slideshow (tests).</summary>
+ internal SlideShow SlideShow => Slides;
+
+ private void ShowTexts()
+ {
+ if (_loc is null || _deck is null)
+ return;
+ Title = HeaderText.Text = _loc.Format("whats_new.title", _deck.DisplayVersion);
+ Slides.RefreshTexts();
+ UpdateButtons();
+ }
+
+ private void UpdateButtons()
+ {
+ if (_loc is null)
+ return;
+ // Hidden rather than collapsed, so "Next" stays where it is.
+ PreviousButton.Opacity = Slides.IsFirst ? 0 : 1;
+ PreviousButton.IsEnabled = !Slides.IsFirst;
+ PrimaryButton.Content = Slides.IsLast ? _loc["whats_new.done"] : _loc["whats_new.next"];
+ }
+
+ private void OnMotionChanged(object? sender, EventArgs e) => Slides.PlayAnimations = Motion.Enabled;
+
+ private void OnLanguageChanged(object? sender, EventArgs e) => ShowTexts();
+
+ private void OnPrevious(object? sender, RoutedEventArgs e) => Slides.Previous();
+
+ /// <summary>Next slide; on the last one it closes.</summary>
+ private void OnPrimary(object? sender, RoutedEventArgs e)
+ {
+ if (!Slides.Next())
+ Close();
+ }
+
+ private void OnClose(object? sender, RoutedEventArgs e) => Close();
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+ if (e.Handled)
+ return;
+ switch (e.Key)
+ {
+ case Key.Left:
+ Slides.Previous();
+ e.Handled = true;
+ break;
+ case Key.Right:
+ Slides.Next();
+ e.Handled = true;
+ break;
+ case Key.Escape:
+ Close();
+ e.Handled = true;
+ break;
+ }
+ }
+
+ private void OnHeaderPressed(object? sender, PointerPressedEventArgs e)
+ {
+ if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && e.Source is not Button)
+ BeginMoveDrag(e);
+ }
+}
diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.cs
index c91a6751..7e4cea46 100644
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@ -155,6 +155,12 @@ public sealed class AppSettings
/// <summary>Newest version the user was already told about, so the update notice shows once per release.</summary>
public string? NotifiedUpdateVersion { get; set; }
+ /// <summary>
+ /// The version whose "What's new" slides were last shown (or that was installed fresh, which needs none). Null in
+ /// settings from before the slides existed: Filee was updated from an older version.
+ /// </summary>
+ public string? WhatsNewSeenVersion { get; set; }
+
/// <summary>Engine package id → the new version the engine update notice was shown for (once per version).</summary>
public Dictionary<string, string> NotifiedEngineVersions { get; set; } = [];
diff --git a/tests/Filee.App.Tests/AnimatedImageTests.cs b/tests/Filee.App.Tests/AnimatedImageTests.cs
new file mode 100644
index 00000000..a8f1cd6b
--- /dev/null
+++ b/tests/Filee.App.Tests/AnimatedImageTests.cs
@@ -0,0 +1,229 @@
+// AnimatedImage: frames of GIF and animated WebP decoded by Skia (partial frames drawn over the ones before), the frame
+// clock (durations, loops, the last frame staying), pausing while hidden and giving the memory back when closed.
+// The pictures are made by Magick.NET in a temp folder for each test.
+
+using System.Runtime.InteropServices;
+using Avalonia.Controls;
+using Avalonia.Headless.XUnit;
+using Avalonia.Threading;
+using Filee.App.Controls;
+using ImageMagick;
+
+namespace Filee.App.Tests;
+
+[Collection("Motion")]
+public sealed class AnimatedImageTests : IDisposable
+{
+ private readonly string _folder = Directory.CreateTempSubdirectory("filee-animated-").FullName;
+
+ public void Dispose()
+ {
+ try
+ {
+ Directory.Delete(_folder, recursive: true);
+ }
+ catch (IOException) { }
+ }
+
+ /// <summary>
+ /// 20 × 20: red (100 ms), then a 10 × 10 green square at (10, 10) over it (200 ms), then all blue (300 ms).
+ /// </summary>
+ private string Animation(MagickFormat format, uint iterations = 0)
+ {
+ var path = Path.Combine(_folder, "anim." + format.ToString().ToLowerInvariant());
+ using var frames = new MagickImageCollection();
+ frames.Add(new MagickImage(MagickColors.Red, 20, 20) { AnimationDelay = 10, GifDisposeMethod = GifDisposeMethod.None });
+ var square = new MagickImage(MagickColors.Lime, 10, 10) { AnimationDelay = 20, GifDisposeMethod = GifDisposeMethod.None };
+ square.Page = new MagickGeometry(10, 10, 10, 10);
+ frames.Add(square);
+ frames.Add(new MagickImage(MagickColors.Blue, 20, 20) { AnimationDelay = 30, GifDisposeMethod = GifDisposeMethod.None });
+ foreach (var frame in frames)
+ frame.AnimationIterations = iterations;
+ if (format == MagickFormat.WebP)
+ frames.Write(path, new ImageMagick.Formats.WebPWriteDefines { Lossless = true });
+ else
+ frames.Write(path, format);
+ return path;
+ }
+
+ /// <summary>The BGRA pixel at (x, y) of a native buffer.</summary>
+ private static (byte B, byte G, byte R, byte A) Pixel(IntPtr buffer, int rowBytes, int x, int y)
+ {
+ var pixel = new byte[4];
+ Marshal.Copy(buffer + y * rowBytes + x * 4, pixel, 0, 4);
+ return (pixel[0], pixel[1], pixel[2], pixel[3]);
+ }
+
+ [Theory]
+ [InlineData(MagickFormat.Gif)]
+ [InlineData(MagickFormat.WebP)]
+ public void Frames_are_decoded_over_the_ones_they_need(MagickFormat format)
+ {
+ using var stream = File.OpenRead(Animation(format));
+ using var decoder = AnimatedImageDecoder.Open(stream);
+ Assert.NotNull(decoder);
+ Assert.Equal((20, 20), (decoder.Width, decoder.Height));
+ Assert.Equal(3, decoder.FrameCount);
+ Assert.Equal([100, 200, 300], decoder.Durations);
+ Assert.Equal(-1, decoder.RepetitionCount); // loops forever
+
+ var rowBytes = decoder.Width * 4;
+ var buffer = Marshal.AllocHGlobal(rowBytes * decoder.Height);
+ try
+ {
+ // Straight to the partial frame: the red frame under it is decoded first.
+ Assert.True(decoder.Decode(1, buffer, rowBytes, freshBuffer: true));
+ Assert.Equal((0, 0, 255, 255), Pixel(buffer, rowBytes, 2, 2));
+ Assert.Equal((0, 255, 0, 255), Pixel(buffer, rowBytes, 15, 15));
+
+ Assert.True(decoder.Decode(2, buffer, rowBytes));
+ Assert.Equal((255, 0, 0, 255), Pixel(buffer, rowBytes, 2, 2));
+
+ // Back to the start of the loop.
+ Assert.True(decoder.Decode(0, buffer, rowBytes));
+ Assert.Equal((0, 0, 255, 255), Pixel(buffer, rowBytes, 15, 15));
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(buffer);
+ }
+ decoder.Dispose();
+ Assert.True(decoder.IsDisposed);
+ Assert.Throws<ObjectDisposedException>(() => decoder.Decode(0, IntPtr.Zero, 0));
+ }
+
+ [Fact]
+ public void A_still_picture_is_one_frame_and_junk_is_refused()
+ {
+ var png = Path.Combine(_folder, "still.png");
+ using (var image = new MagickImage(MagickColors.Orange, 8, 4))
+ image.Write(png);
+ using (var stream = File.OpenRead(png))
+ using (var decoder = AnimatedImageDecoder.Open(stream))
+ {
+ Assert.NotNull(decoder);
+ Assert.False(decoder.IsAnimated);
+ Assert.Equal(1, decoder.FrameCount);
+ Assert.Equal(0, decoder.RepetitionCount);
+ }
+ using var junk = new MemoryStream("not a picture"u8.ToArray());
+ Assert.Null(AnimatedImageDecoder.Open(junk));
+ }
+
+ [Theory]
+ [InlineData(0, 100)]
+ [InlineData(10, 100)]
+ [InlineData(15, 20)]
+ [InlineData(70, 70)]
+ public void Frame_durations_follow_what_browsers_do(int claimed, int shown) =>
+ Assert.Equal(shown, AnimatedImageDecoder.NormalizeDuration(claimed));
+
+ [Fact]
+ public void The_timeline_steps_frames_by_their_durations_and_loops()
+ {
+ var timeline = new FrameTimeline([100, 200, 300], repetitionCount: -1);
+ Assert.False(timeline.Advance(TimeSpan.FromMilliseconds(99)));
+ Assert.Equal(0, timeline.Frame);
+ Assert.Equal(TimeSpan.FromMilliseconds(1), timeline.UntilNextFrame);
+ Assert.True(timeline.Advance(TimeSpan.FromMilliseconds(1)));
+ Assert.Equal(1, timeline.Frame);
+ Assert.True(timeline.Advance(TimeSpan.FromMilliseconds(450))); // past frame 1 (200) into frame 2
+ Assert.Equal(2, timeline.Frame);
+ Assert.Equal(TimeSpan.FromMilliseconds(50), timeline.UntilNextFrame);
+ Assert.True(timeline.Advance(TimeSpan.FromMilliseconds(50)));
+ Assert.Equal(0, timeline.Frame);
+ Assert.False(timeline.IsFinished);
+
+ // A long pause (sleep) catches up one loop at most, not hours of frames.
+ timeline.Advance(TimeSpan.FromHours(5));
+ Assert.InRange(timeline.Frame, 0, 2);
+ }
+
+ [Fact]
+ public void An_animation_that_plays_twice_stops_on_its_last_frame()
+ {
+ var timeline = new FrameTimeline([100, 100], repetitionCount: 1);
+ timeline.Advance(TimeSpan.FromMilliseconds(150));
+ timeline.Advance(TimeSpan.FromMilliseconds(200));
+ Assert.Equal(1, timeline.Frame);
+ Assert.False(timeline.IsFinished);
+ timeline.Advance(TimeSpan.FromMilliseconds(50));
+ Assert.True(timeline.IsFinished);
+ Assert.Equal(1, timeline.Frame);
+ Assert.Equal(Timeout.InfiniteTimeSpan, timeline.UntilNextFrame);
+ Assert.False(timeline.Advance(TimeSpan.FromSeconds(1)));
+
+ timeline.Reset();
+ Assert.Equal((0, false), (timeline.Frame, timeline.IsFinished));
+ Assert.Equal(Timeout.InfiniteTimeSpan, new FrameTimeline([100], -1).UntilNextFrame);
+ }
+
+ [AvaloniaFact]
+ public void The_control_plays_pauses_while_hidden_and_lets_go_when_closed()
+ {
+ TestServices.EnsureInitialized("en");
+ var now = TimeSpan.Zero;
+ var image = new AnimatedImage { Clock = () => now, Source = new Uri(Animation(MagickFormat.WebP)) };
+ var window = new Window { Content = image, Width = 120, Height = 120 };
+ window.Show();
+ Dispatcher.UIThread.RunJobs();
+
+ Assert.True(image.HasPicture);
+ Assert.Equal(new Avalonia.PixelSize(20, 20), image.PixelSize);
+ Assert.Equal(0, image.CurrentFrame);
+ Assert.True(image.IsPlaying);
+
+ now += TimeSpan.FromMilliseconds(120);
+ image.Tick();
+ Assert.Equal(1, image.CurrentFrame);
+
+ // Hidden: time passes, the animation stays where it is and goes on from there.
+ image.IsVisible = false;
+ Assert.False(image.IsPlaying);
+ now += TimeSpan.FromSeconds(10);
+ image.Tick();
+ Assert.Equal(1, image.CurrentFrame);
+ image.IsVisible = true;
+ now += TimeSpan.FromMilliseconds(190);
+ image.Tick();
+ Assert.Equal(2, image.CurrentFrame);
+
+ // Reduced motion: the poster frame, which stays.
+ image.AutoPlay = false;
+ Assert.Equal(0, image.CurrentFrame);
+ Assert.False(image.IsPlaying);
+ image.PosterFrame = 1;
+ Assert.Equal(1, image.CurrentFrame);
+ now += TimeSpan.FromSeconds(1);
+ image.Tick();
+ Assert.Equal(1, image.CurrentFrame);
+ image.PosterFrame = 99; // past the end: the last frame
+ Assert.Equal(2, image.CurrentFrame);
+ image.PosterFrame = 0;
+
+ // A new source replaces the old frames; closing the window frees them.
+ image.AutoPlay = true;
+ image.Source = new Uri(Animation(MagickFormat.Gif));
+ Assert.True(image.HasPicture);
+ Assert.Equal(3, image.FrameCount);
+ window.Close();
+ Dispatcher.UIThread.RunJobs();
+ Assert.False(image.HasPicture);
+ Assert.Equal(-1, image.CurrentFrame);
+ Assert.False(image.IsPlaying);
+ }
+
+ [AvaloniaFact]
+ public void A_missing_picture_leaves_the_control_empty()
+ {
+ TestServices.EnsureInitialized("en");
+ var image = new AnimatedImage { Source = new Uri(Path.Combine(_folder, "nothing.webp")) };
+ var window = new Window { Content = image, Width = 50, Height = 50 };
+ window.Show();
+ Dispatcher.UIThread.RunJobs();
+ Assert.False(image.HasPicture);
+ image.Source = new Uri("avares://Filee/Assets/WhatsNew/0.0.0/none.webp");
+ Assert.False(image.HasPicture);
+ window.Close();
+ }
+}
diff --git a/tests/Filee.App.Tests/WhatsNewMedia.cs b/tests/Filee.App.Tests/WhatsNewMedia.cs
new file mode 100644
index 00000000..c976507b
--- /dev/null
+++ b/tests/Filee.App.Tests/WhatsNewMedia.cs
@@ -0,0 +1,661 @@
+// Renders the demo animations of the "What's new" slides (src/Filee.App/Assets/WhatsNew/<version>/*.webp) with the
+// headless app: real windows, real donut animations, frame by frame, encoded as compact animated WebP by Magick.NET.
+// The files it writes are product assets; run it again when the UI they show changes. It is explicit, so a normal test
+// run skips it:
+//
+// dotnet build tests/Filee.App.Tests
+// tests/Filee.App.Tests/bin/Debug/net10.0/Filee.App.Tests.exe -method "Filee.App.Tests.WhatsNewMedia.*" -explicit only
+//
+// Each clip is drawn on a 768 × 432 canvas (16:9, shown at 496 × 279 in the window, sharp up to 150 % scaling) in the
+// light theme. The first frame of each clip is what reduced motion shows, so every clip starts on a meaningful picture.
+
+using Avalonia.Controls;
+using Avalonia.Headless;
+using Avalonia.Headless.XUnit;
+using Avalonia.Threading;
+using Avalonia.VisualTree;
+using Filee.App.Controls;
+using Filee.App.Services;
+using Filee.App.ViewModels;
+using Filee.App.ViewModels.Pages;
+using Filee.App.Views;
+using Filee.Core.Localization;
+using Filee.Core.Presets;
+using Filee.Core.Settings;
+using ImageMagick;
+using ImageMagick.Drawing;
+
+namespace Filee.App.Tests;
+
+[Collection("Motion")]
+public class WhatsNewMedia
+{
+ internal const int CanvasWidth = 768;
+ internal const int CanvasHeight = 432;
+ private const double Frame = 1 / 25.0;
+
+ /// <summary>The light theme's PageBrush: the canvas behind every clip.</summary>
+ private const string Page = "#F6F5F1";
+
+ /// <summary>Where the 2.0.0 slides live in the repository.</summary>
+ internal static string Folder(string version) =>
+ Path.Combine(RepositoryRoot, "src", "Filee.App", "Assets", "WhatsNew", version);
+
+ internal static string RepositoryRoot
+ {
+ get
+ {
+ var dir = new DirectoryInfo(AppContext.BaseDirectory);
+ while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "Filee.slnx")))
+ dir = dir.Parent;
+ return dir!.FullName;
+ }
+ }
+
+ [AvaloniaFact(Explicit = true)]
+ public void Generate_2_0_0()
+ {
+ TestServices.EnsureInitialized("en");
+ var folder = Folder("2.0.0");
+ Directory.CreateDirectory(folder);
+ var theme = AppHost.Get<ThemeService>();
+ // Animations on whatever this machine prefers: every theme applied here says ReduceMotion = false, since
+ // ThemeService.Apply reads the setting again.
+ Motion.Set(true);
+ // Times in the history as an English reader expects them, whatever the machine's region.
+ var culture = System.Globalization.CultureInfo.CurrentCulture;
+ System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
+ try
+ {
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, "en");
+ // browser.webp and flip.webp come from the demo-video generator (branch media/demo-videos: a scripted desktop
+ // with a browser and a file manager). These headless versions are written only when asked for by name
+ // (FILEE_WHATSNEW_ONLY=browser,flip).
+ Write(folder, "browser.webp", BrowserDrop, onRequestOnly: true);
+ Write(folder, "flip.webp", DonutFlip, onRequestOnly: true);
+ Write(folder, "formats.webp", FormatDonuts);
+ Write(folder, "crop.webp", Crop);
+ Write(folder, "theme.webp", Softness);
+ Write(folder, "languages.webp", () => Languages("2.0.0"));
+ Write(folder, "more.webp", () => More("2.0.0"));
+ }
+ finally
+ {
+ System.Globalization.CultureInfo.CurrentCulture = culture;
+ theme.Apply(new ThemeSettings(), "en");
+ TestServices.EnsureInitialized("en");
+ }
+ }
+
+ // ───────────────────────── Scenes ─────────────────────────
+
+ /// <summary>
+ /// A picture dropped from a browser (#261): the donut for it, "Drop → JPG", then the ring with the download badge
+ /// above it while the picture is saved, then the check. The badge shows what JobViewModel would write; the real
+ /// drag from a browser can't be made headless.
+ /// </summary>
+ private static Clip BrowserDrop()
+ {
+ var clip = new Clip();
+ // Where a browser picture stands before it is saved (BrowserDrags: placeholder paths named like the file).
+ var (window, vm) = OpenDonut([Path.Combine(Path.GetTempPath(), "Filee", "web", "drop", "1", "sunset.jpg")], clickMode: false);
+ var donut = window.DonutControl;
+ var badge = window.GetVisualDescendants().OfType<Border>().Single(b => b.Name == "DownloadBadge");
+ var badgeText = (TextBlock)badge.Child!;
+ var loc = AppHost.Get<ILocalizer>();
+ try
+ {
+ // Frame 0 (reduced motion): the open donut with "Drop → JPG".
+ donut.FinishAnimations();
+ Highlight(window, vm, 1);
+ clip.Add(Capture(window), 1400);
+
+ donut.BeginProgress();
+ badge.Transitions = null;
+ const long size = 3_100_000;
+ var shown = false;
+ for (var t = 0.0; t < 1.6; t += Frame)
+ {
+ if (t >= 0.3)
+ {
+ var part = Math.Min(1, (t - 0.3) / 1.2);
+ var done = (long)(size * part);
+ donut.SetProgress(part / 2); // saving is the first half of a browser file's progress
+ badgeText.Text = ViewModels.DownloadBadge.Format(loc, 2_400_000, new Filee.Core.Conversion.JobTransfer(done, size, 0, 1, done));
+ if (!shown)
+ {
+ (badge.Opacity, badge.RenderTransform, shown) = (1, null, true);
+ }
+ }
+ Step(donut);
+ clip.Add(Capture(window), (int)(Frame * 1000));
+ }
+ badge.Opacity = 0;
+ donut.SetProgress(1);
+ Run(clip, window, 0.6);
+ donut.CompleteProgress(DonutProgressOutcome.Succeeded, () => { });
+ Run(clip, window, 2.5, () => donut.ShownOutcome is not null);
+ // The check stays a moment before the clip starts over.
+ clip.Hold(1600);
+ }
+ finally
+ {
+ window.Close();
+ }
+ return clip;
+ }
+
+ /// <summary>
+ /// The donut's back face (#262): the images donut with "Tab ↻ back" in the hub turns over to its back face and,
+ /// after a moment, to the front again.
+ /// </summary>
+ private static Clip DonutFlip()
+ {
+ var clip = new Clip();
+ var (window, vm) = OpenDonut([@"C:\photos\a.jpg", @"C:\photos\b.jpg"], clickMode: true);
+ var donut = window.DonutControl;
+ try
+ {
+ donut.FinishAnimations();
+ Pump(); // the back face is checked once the front is on screen
+ Assert.True(vm.CanFlip);
+ Settle(donut);
+ // Frame 0: the front with its "Tab ↻ back" hint.
+ clip.Add(Capture(window), 1600);
+ for (var turn = 0; turn < 2; turn++)
+ {
+ Assert.True(donut.Flip());
+ for (var t = 0.0; t < DonutMenu.FlipDuration + Frame; t += Frame)
+ {
+ Step(donut);
+ clip.Add(Capture(window), (int)(Frame * 1000));
+ }
+ Settle(donut);
+ clip.Add(Capture(window), turn == 0 ? 1800 : 900);
+ }
+ }
+ finally
+ {
+ window.Close();
+ if (vm.IsBackFace)
+ vm.ToggleFace();
+ }
+ return clip;
+ }
+
+ /// <summary>The donut opening for one new format after another.</summary>
+ private static Clip FormatDonuts()
+ {
+ var clip = new Clip();
+ string[][] sets =
+ [
+ [@"C:\gis\roads.shp"],
+ [@"C:\invoices\invoice.ofd"],
+ [@"C:\web\article.mhtml"],
+ [@"C:\photos\scan.jxr"],
+ [@"C:\models\chair.fbx"],
+ [@"C:\slides\template.potm"],
+ ];
+ foreach (var files in sets)
+ {
+ var (window, vm) = OpenDonut(files, clickMode: true);
+ // As someone with the optional engines (LibreOffice) sees it, not greyed out for a missing engine.
+ vm.Items = vm.Items.Select(Enabled).ToList();
+ try
+ {
+ var donut = window.DonutControl;
+ if (clip.Count == 0)
+ {
+ // Frame 0: the first donut open, for reduced motion.
+ donut.FinishAnimations();
+ Highlight(window, vm, 0);
+ clip.Add(Capture(window), 900);
+ donut.SetExternalHighlight(-1);
+ }
+ donut.PlayOpenAnimation();
+ Run(clip, window, 0.4);
+ Highlight(window, vm, 0);
+ clip.Add(Capture(window), 1100);
+ }
+ finally
+ {
+ window.Close();
+ }
+ }
+ return clip;
+ }
+
+ /// <summary>The crop overlay: the frame closes in on part of a picture, then the square ratio is picked.</summary>
+ private static Clip Crop()
+ {
+ var clip = new Clip();
+ var folder = Directory.CreateTempSubdirectory("filee-whatsnew-crop-").FullName;
+ try
+ {
+ var picture = Path.Combine(folder, "harbour.jpg");
+ DrawLandscape(picture);
+ var preset = BuiltInData.CreatePresets().Single(p => p.Id == "tool-crop");
+ var vm = new CropOverlayViewModel([picture], preset, AppHost.Get<ILocalizer>(), AppHost.Get<UserDataStore>());
+ var window = new CropOverlayWindow
+ {
+ DataContext = vm,
+ Width = 960,
+ Height = 540,
+ Background = new Avalonia.Media.SolidColorBrush(Avalonia.Media.Color.Parse(Page)),
+ };
+ window.Show();
+ WaitFor(() => vm.PreviewImage is not null && !vm.IsBusy);
+ Pump();
+ var canvas = window.GetVisualDescendants().OfType<CropCanvas>().Single();
+ try
+ {
+ var from = new Avalonia.Rect(0.05, 0.05, 0.9, 0.9);
+ var to = new Avalonia.Rect(0.42, 0.18, 0.44, 0.62);
+ // Frame 0: the frame already on the part to keep.
+ canvas.NormalizedCropRect = to;
+ Pump();
+ clip.Add(Capture(window), 1200);
+ canvas.NormalizedCropRect = from;
+ Pump();
+ clip.Add(Capture(window), 600);
+ const int steps = 18;
+ for (var i = 1; i <= steps; i++)
+ {
+ var t = Ease(i / (double)steps);
+ canvas.NormalizedCropRect = Lerp(from, to, t);
+ Pump();
+ clip.Add(Capture(window), 40);
+ }
+ clip.Add(Capture(window), 700);
+ vm.SetAspect("1:1");
+ Pump();
+ clip.Add(Capture(window), 1600);
+ }
+ finally
+ {
+ window.Close();
+ }
+ }
+ finally
+ {
+ try
+ {
+ Directory.Delete(folder, recursive: true);
+ }
+ catch (IOException) { }
+ }
+ return clip;
+ }
+
+ /// <summary>The donut rounding off as Softness goes up, then a few accent colours.</summary>
+ private static Clip Softness()
+ {
+ var clip = new Clip();
+ var theme = AppHost.Get<ThemeService>();
+ var (window, vm) = OpenDonut([@"C:\photos\a.jpg", @"C:\photos\b.jpg"], clickMode: true);
+ try
+ {
+ window.DonutControl.FinishAnimations();
+ Highlight(window, vm, 2);
+ // Frame 0: soft, default colours.
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light, CornerRadius = 28 }, "en");
+ Pump();
+ clip.Add(Capture(window), 1000);
+ const int steps = 14;
+ for (var i = 0; i <= steps; i++)
+ {
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light, CornerRadius = 28.0 * i / steps }, "en");
+ Pump();
+ clip.Add(Capture(window), i == 0 ? 500 : 60);
+ }
+ clip.Add(Capture(window), 500);
+ foreach (var accent in new[] { "#1D9E75", "#D4537E", "#E8873A", "#7F77DD" })
+ {
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light, CornerRadius = 28, Accent = accent }, "en");
+ Pump();
+ clip.Add(Capture(window), 800);
+ }
+ }
+ finally
+ {
+ window.Close();
+ theme.Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, "en");
+ }
+ return clip;
+ }
+
+ /// <summary>The Home page in one language after another.</summary>
+ private static Clip Languages(string version)
+ {
+ var clip = new Clip();
+ foreach (var language in new[] { "es", "hi", "ja", "ru", "en", "ko", "zh-CN", "pl" })
+ {
+ TestServices.EnsureInitialized(language);
+ AppHost.Get<ThemeService>().Apply(new ThemeSettings { ReduceMotion = false, Mode = ThemeMode.Light }, language);
+ var vm = new MainWindowViewModel(AppHost.Services, AppHost.Get<ILocalizer>(), AppHost.Get<UpdateService>());
+ vm.Navigate("home");
+ var window = new MainWindow { DataContext = vm, Width = 960, Height = 540 };
+ window.Show();
+ Pump();
+ clip.Add(Capture(window, version), 1100);
+ window.Close();
+ vm.Dispose();
+ }
+ TestServices.EnsureInitialized("en");
+ return clip;
+ }
+
+ /// <summary>
+ /// "And more": the history search finding an old conversion as it is typed, then "Reset to default" beside a
+ /// built-in donut on the Toolbar page.
+ /// </summary>
+ private static Clip More(string version)
+ {
+ var clip = new Clip();
+ var store = AppHost.Get<UserDataStore>();
+ var loc = AppHost.Get<ILocalizer>();
+ store.ClearHistory();
+ store.History.AddRange(Enumerable.Range(0, store.Settings.EffectiveHistoryLimit).Select(i => new Filee.Core.History.HistoryEntry
+ {
+ FinishedAt = DateTime.Now.AddMinutes(-7 * i - 3),
+ PresetName = i == 150 ? "PDF" : i % 3 == 0 ? "JPG" : "PNG",
+ State = Filee.Core.Conversion.JobState.Completed,
+ Sources = i == 150 ? [@"C:\Work\Annual report.docx"] : [$@"C:\Photos\IMG_{4000 + i:0000}.heic"],
+ }));
+ var profiles = store.Profiles.Select(p => p.Clone()).ToList();
+ try
+ {
+ var vm = new MainWindowViewModel(AppHost.Services, loc, AppHost.Get<UpdateService>());
+ vm.Navigate("home");
+ var window = new MainWindow { DataContext = vm, Width = 960, Height = 540 };
+ window.Show();
+ Pump();
+ var home = (HomePageViewModel)vm.CurrentPage!;
+ // Frame 0: the old report found.
+ home.Search = "report";
+ Pump();
+ clip.Add(Capture(window, version), 1400);
+ home.Search = "";
+ Pump();
+ clip.Add(Capture(window, version), 700);
+ foreach (var typed in new[] { "r", "re", "rep", "repo", "repor", "report" })
+ {
+ home.Search = typed;
+ Pump();
+ clip.Add(Capture(window, version), 160);
+ }
+ clip.Add(Capture(window, version), 1400);
+
+ // A tall window shows the whole profile card; the clip shows its lower part, down to "Reset to default".
+ vm.Navigate("toolbar");
+ window.Width = 1240;
+ window.Height = 1700;
+ var page = (ToolbarPageViewModel)vm.CurrentPage!;
+ page.SelectedProfile = page.Profiles.Single(p => p.Profile.Id == "images");
+ Pump();
+ var actions = window.GetVisualDescendants().OfType<StackPanel>().Single(s => s.Name == "ProfileActions");
+ var card = window.GetVisualDescendants().OfType<Border>().Single(b => b.Name == "ProfileCard");
+ var cardAt = Avalonia.VisualExtensions.TranslatePoint(card, default, window)!.Value;
+ var actionsAt = Avalonia.VisualExtensions.TranslatePoint(actions, default, window)!.Value;
+ var bottom = actionsAt.Y + actions.Bounds.Height + 28;
+ var region = new Avalonia.Rect(Math.Max(0, cardAt.X - 8), Math.Max(0, bottom - 540), 960, 540);
+ clip.Add(Capture(window, version, region), 2200);
+ window.Close();
+ vm.Dispose();
+ }
+ finally
+ {
+ store.ClearHistory();
+ store.Profiles.Clear();
+ store.Profiles.AddRange(profiles);
+ }
+ return clip;
+ }
+
+ // ───────────────────────── Helpers ─────────────────────────
+
+ private static (RadialWindow Window, RadialViewModel Vm) OpenDonut(IReadOnlyList<string> files, bool clickMode)
+ {
+ var vm = AppHost.Get<RadialViewModel>();
+ if (!clickMode)
+ vm.ResetForDrag();
+ vm.Load(files, clickMode);
+ vm.FitToThisDonut();
+ // The headless platform has no transparent windows: the page colour instead of black around the donut.
+ var window = new RadialWindow { DataContext = vm, Background = new Avalonia.Media.SolidColorBrush(Avalonia.Media.Color.Parse(Page)) };
+ window.Show();
+ Pump();
+ return (window, vm);
+ }
+
+ private static DonutItem Enabled(DonutItem item) => new()
+ {
+ Id = item.Id,
+ Label = item.Label,
+ Caption = item.Caption,
+ Children = item.Children?.Select(Enabled).ToList(),
+ };
+
+ private static void Highlight(RadialWindow window, RadialViewModel vm, int index)
+ {
+ window.DonutControl.SetExternalHighlight(index);
+ vm.ShowHint(index, -1, centerHot: false);
+ Settle(window.DonutControl);
+ }
+
+ /// <summary>Lets the donut's springs (highlight, hub) come to rest, and draws it.</summary>
+ private static void Settle(DonutMenu donut)
+ {
+ for (var i = 0; i < 90; i++)
+ donut.Advance(1 / 60.0);
+ Dispatcher.UIThread.RunJobs();
+ }
+
+ /// <summary>One frame: the donut's clock moves on by <see cref="Frame"/>.</summary>
+ private static void Step(DonutMenu donut)
+ {
+ KeepFramesComing(donut);
+ donut.Advance(Frame);
+ Dispatcher.UIThread.RunJobs();
+ KeepFramesComing(donut);
+ }
+
+ /// <summary>Runs the donut's animations <paramref name="seconds"/> (or until <paramref name="until"/>), a frame every <see cref="Frame"/>.</summary>
+ private static void Run(Clip clip, RadialWindow window, double seconds, Func<bool>? until = null)
+ {
+ for (var t = 0.0; t < seconds && until?.Invoke() != true; t += Frame)
+ {
+ Step(window.DonutControl);
+ clip.Add(Capture(window), (int)(Frame * 1000));
+ }
+ }
+
+ private static void Pump()
+ {
+ for (var i = 0; i < 20; i++)
+ {
+ Dispatcher.UIThread.RunJobs();
+ AvaloniaHeadlessPlatform.ForceRenderTimerTick();
+ }
+ }
+
+ private static void WaitFor(Func<bool> condition)
+ {
+ for (var i = 0; i < 500 && !condition(); i++)
+ {
+ Dispatcher.UIThread.RunJobs();
+ Thread.Sleep(20);
+ }
+ Assert.True(condition());
+ }
+
+ private static double Ease(double t) => 1 - Math.Pow(1 - t, 3);
+
+ private static Avalonia.Rect Lerp(Avalonia.Rect a, Avalonia.Rect b, double t) => new(
+ a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t, a.Width + (b.Width - a.Width) * t, a.Height + (b.Height - a.Height) * t);
+
+ /// <summary>
+ /// A rendered frame of <paramref name="window"/> centred on the page-coloured canvas, scaled down to fit. With
+ /// <paramref name="version"/>, the sidebar shows that version instead of the one being built (the clips are made
+ /// before the version is bumped).
+ /// </summary>
+ private static MagickImage Capture(TopLevel window, string? version = null, Avalonia.Rect? region = null)
+ {
+ if (window is RadialWindow radial)
+ KeepFramesComing(radial.DonutControl);
+ try
+ {
+ return CaptureCore(window, version, region);
+ }
+ finally
+ {
+ if (window is RadialWindow after)
+ KeepFramesComing(after.DonutControl);
+ }
+ }
+
+ private static readonly System.Reflection.FieldInfo LastFrameTick =
+ typeof(DonutMenu).GetField("_lastTick", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
+ ?? throw new InvalidOperationException("DonutMenu._lastTick is gone: update WhatsNewMedia.KeepFramesComing");
+
+ /// <summary>
+ /// Taking a frame (PNG, compare) takes longer than the donut's stalled-frames watchdog waits (StalledLoopMs), which
+ /// would then jump every animation to its end. The clips step the clock themselves, so the watchdog is told that
+ /// frames are coming.
+ /// </summary>
+ private static void KeepFramesComing(DonutMenu donut) => LastFrameTick.SetValue(donut, Environment.TickCount64);
+
+ private static MagickImage CaptureCore(TopLevel window, string? version, Avalonia.Rect? region)
+ {
+ if (version is not null)
+ {
+ foreach (var text in window.GetVisualDescendants().OfType<TextBlock>())
+ if (text.Text?.Contains(UpdateService.CurrentVersion, StringComparison.Ordinal) == true)
+ text.Text = text.Text.Replace(UpdateService.CurrentVersion, version, StringComparison.Ordinal);
+ Dispatcher.UIThread.RunJobs();
+ AvaloniaHeadlessPlatform.ForceRenderTimerTick();
+ }
+ using var png = new MemoryStream();
+ if (window is RadialWindow)
+ {
+ // The donut is drawn straight from its state: the clips step its clock themselves, and the render timer
+ // would run its own frame loop as well.
+ window.UpdateLayout();
+ using var bitmap = new Avalonia.Media.Imaging.RenderTargetBitmap(
+ new Avalonia.PixelSize((int)Math.Ceiling(window.Bounds.Width), (int)Math.Ceiling(window.Bounds.Height)));
+ bitmap.Render(window);
+ bitmap.Save(png, new Avalonia.Media.Imaging.PngBitmapEncoderOptions());
+ }
+ else
+ {
+ using var frame = window.CaptureRenderedFrame();
+ Assert.NotNull(frame);
+ frame.Save(png, new Avalonia.Media.Imaging.PngBitmapEncoderOptions());
+ }
+ png.Position = 0;
+ using var shot = new MagickImage(png);
+ if (region is { } r)
+ {
+ var x = (int)Math.Clamp(r.X, 0, Math.Max(0, shot.Width - r.Width));
+ var y = (int)Math.Clamp(r.Y, 0, Math.Max(0, shot.Height - r.Height));
+ shot.Crop(new MagickGeometry(x, y, (uint)r.Width, (uint)r.Height));
+ shot.ResetPage();
+ }
+ var canvas = new MagickImage(new MagickColor(Page), CanvasWidth, CanvasHeight);
+ var scale = Math.Min(1, Math.Min((double)CanvasWidth / shot.Width, (double)CanvasHeight / shot.Height));
+ if (scale < 1)
+ {
+ shot.FilterType = FilterType.Lanczos;
+ shot.Resize((uint)Math.Round(shot.Width * scale), (uint)Math.Round(shot.Height * scale));
+ }
+ canvas.Composite(shot, Gravity.Center, CompositeOperator.Over);
+ return canvas;
+ }
+
+ /// <summary>A made-up photo (sky, sun, sea, hills) to crop: generated, so no picture is kept in the repository.</summary>
+ private static void DrawLandscape(string path)
+ {
+ using var image = new MagickImage("gradient:#8EC5FC-#F8D2A6", 1600, 1000);
+ new Drawables()
+ .FillColor(new MagickColor("#FFF2C2")).Circle(1080, 360, 1080, 460)
+ .FillColor(new MagickColor("#4F7CAC")).Rectangle(0, 640, 1600, 1000)
+ .FillColor(new MagickColor("#6C9A5B")).Polygon(new PointD(0, 700), new PointD(380, 470), new PointD(760, 690), new PointD(0, 760))
+ .FillColor(new MagickColor("#3F6E4A")).Polygon(new PointD(600, 700), new PointD(1000, 520), new PointD(1600, 700), new PointD(1600, 760), new PointD(600, 760))
+ .FillColor(new MagickColor("#F2F2F2")).Polygon(new PointD(1180, 760), new PointD(1260, 600), new PointD(1260, 760))
+ .FillColor(new MagickColor("#7A4E2D")).Rectangle(1150, 760, 1300, 790)
+ .Draw(image);
+ image.Quality = 92;
+ image.Write(path, MagickFormat.Jpeg);
+ }
+
+ /// <summary>
+ /// Renders and writes one clip. FILEE_WHATSNEW_ONLY (names without extension, comma-separated) limits a run to some
+ /// clips, e.g. <c>FILEE_WHATSNEW_ONLY=crop,theme</c>; <paramref name="onRequestOnly"/> clips (made elsewhere) are
+ /// written only when named there.
+ /// </summary>
+ private static void Write(string folder, string name, Func<Clip> render, bool onRequestOnly = false)
+ {
+ var only = Environment.GetEnvironmentVariable("FILEE_WHATSNEW_ONLY");
+ var named = !string.IsNullOrWhiteSpace(only)
+ && only.Split(',', StringSplitOptions.TrimEntries).Contains(Path.GetFileNameWithoutExtension(name), StringComparer.OrdinalIgnoreCase);
+ if (onRequestOnly ? !named : !string.IsNullOrWhiteSpace(only) && !named)
+ return;
+ using (var clip = render())
+ {
+ var path = Path.Combine(folder, name);
+ clip.WriteWebP(path);
+ // The first frame next to the screenshots, for review.
+ clip.SaveFirstFrame(Path.Combine(TestServices.ScreenshotDirectory, "whatsnew-" + Path.ChangeExtension(name, ".png")));
+ Assert.InRange(new FileInfo(path).Length, 1, 400 * 1024);
+ }
+ }
+
+ /// <summary>Frames with how long each shows; a frame identical to the one before only lengthens it.</summary>
+ private sealed class Clip : IDisposable
+ {
+ private readonly List<(MagickImage Image, int Milliseconds)> _frames = [];
+
+ public int Count => _frames.Count;
+
+ /// <summary>Shows the last frame <paramref name="milliseconds"/> longer.</summary>
+ public void Hold(int milliseconds) => _frames[^1] = (_frames[^1].Image, _frames[^1].Milliseconds + milliseconds);
+
+ public void Add(MagickImage image, int milliseconds)
+ {
+ if (_frames.Count > 0 && _frames[^1].Image.Compare(image, ErrorMetric.Absolute) == 0)
+ {
+ _frames[^1] = (_frames[^1].Image, _frames[^1].Milliseconds + milliseconds);
+ image.Dispose();
+ return;
+ }
+ _frames.Add((image, milliseconds));
+ }
+
+ public void WriteWebP(string path)
+ {
+ using var collection = new MagickImageCollection();
+ foreach (var (image, milliseconds) in _frames)
+ {
+ var copy = image.Clone();
+ // Delays are in 1/100 s; at least 2 so viewers don't speed the frame up.
+ copy.AnimationDelay = (uint)Math.Max(2, Math.Round(milliseconds / 10.0));
+ copy.AnimationTicksPerSecond = 100;
+ copy.Quality = 82;
+ collection.Add(copy);
+ }
+ var defines = new ImageMagick.Formats.WebPWriteDefines { Method = 6, Lossless = false, ThreadLevel = true };
+ if (_frames.Count > 1)
+ collection[0].Settings.SetDefine(MagickFormat.WebP, "mixed", "true");
+ collection.Write(path, defines);
+ }
+
+ public void SaveFirstFrame(string path) => _frames[0].Image.Write(path, MagickFormat.Png);
+
+ public void Dispose()
+ {
+ foreach (var (image, _) in _frames)
+ image.Dispose();
+ _frames.Clear();
+ }
+ }
+}
diff --git a/tests/Filee.App.Tests/WhatsNewTests.cs b/tests/Filee.App.Tests/WhatsNewTests.cs
new file mode 100644
index 00000000..22d79662
--- /dev/null
+++ b/tests/Filee.App.Tests/WhatsNewTests.cs
@@ -0,0 +1,479 @@
+// "What's new" slides: the manifests and their media, when the slides are due (update, fresh install, downgrade,
+// background start), the window's buttons and keys, and screenshots of the window.
+
+using System.Text.Json;
+using Avalonia.Controls;
+using Avalonia.Headless;
+using Avalonia.Headless.XUnit;
+using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Platform;
+using Avalonia.Threading;
+using Avalonia.VisualTree;
+using Filee.App.Controls;
+using Filee.App.Services;
+using Filee.App.ViewModels;
+using Filee.App.ViewModels.Pages;
+using Filee.App.Views;
+using Filee.App.Views.Pages;
+using Filee.Core.Localization;
+using Filee.Core.Settings;
+
+namespace Filee.App.Tests;
+
+// Motion: one test switches reduced motion, which the window reads when it opens.
+[Collection("Motion")]
+public class WhatsNewTests
+{
+ private static readonly Version V2 = new(2, 0, 0);
+
+ private static SlideDeck Deck(string version) =>
+ new(SlideDeck.TryParseVersion(version)!, [new Slide("a", new Uri("avares://Filee/a.webp"), "t", "x")]);
+
+ // ───────────────────────── Manifests ─────────────────────────
+
+ [AvaloniaFact]
+ public void The_2_0_0_deck_ships_with_its_media_and_texts()
+ {
+ TestServices.EnsureInitialized("en");
+ var decks = SlideDeck.LoadAll("Filee");
+ var deck = Assert.Single(decks, d => d.Version == V2);
+ Assert.InRange(deck.Slides.Count, 5, 7);
+ Assert.Equal(deck.Slides.Count, deck.Slides.Select(s => s.Id).Distinct().Count());
+ var english = LoadStrings("en");
+ foreach (var slide in deck.Slides)
+ {
+ Assert.True(AssetLoader.Exists(slide.Media), $"{slide.Media} is missing");
+ Assert.StartsWith("avares://Filee/Assets/WhatsNew/2.0.0/", slide.Media.ToString(), StringComparison.Ordinal);
+ Assert.Contains(slide.TitleKey, english.Keys);
+ Assert.Contains(slide.TextKey, english.Keys);
+ }
+ }
+
+ /// <summary>The media are product assets that ship in every installer: each small, all of them small together.</summary>
+ [Fact]
+ public void Slide_media_stay_small()
+ {
+ var root = Path.Combine(WhatsNewMedia.RepositoryRoot, "src", "Filee.App", "Assets", "WhatsNew");
+ var media = Directory.EnumerateFiles(root, "*", SearchOption.AllDirectories)
+ .Where(f => !f.EndsWith(".json", StringComparison.OrdinalIgnoreCase)).Select(f => new FileInfo(f)).ToList();
+ Assert.NotEmpty(media);
+ Assert.All(media, f => Assert.True(f.Length <= 400 * 1024, $"{f.Name} is {f.Length / 1024} KB"));
+ Assert.True(media.Sum(f => f.Length) <= 2 * 1024 * 1024, "the slides' media add up to more than 2 MB");
+ }
+
+ [Fact]
+ public void A_manifest_is_read_leniently_and_safely()
+ {
+ var folder = new Uri("avares://Filee/Assets/WhatsNew/3.1.0/");
+ var deck = SlideDeck.Parse("""
+ {
+ // comments and trailing commas are fine
+ "version": "v3.1",
+ "slides": [
+ { "id": "one", "media": "one.webp", "poster": 12, "title": "a.title", "text": "a.text" },
+ { "id": "no-text", "media": "two.webp", "title": "b.title" },
+ { "id": "escape", "media": "../../secret.png", "title": "c.title", "text": "c.text" },
+ { "id": "rooted", "media": "C:/x.png", "title": "d.title", "text": "d.text" },
+ ],
+ }
+ """, folder);
+
+ Assert.NotNull(deck);
+ Assert.Equal(new Version(3, 1, 0), deck.Version);
+ Assert.Equal("3.1", deck.DisplayVersion);
+ var slide = Assert.Single(deck.Slides);
+ Assert.Equal(new Uri("avares://Filee/Assets/WhatsNew/3.1.0/one.webp"), slide.Media);
+ Assert.Equal(("a.title", "a.text"), (slide.TitleKey, slide.TextKey));
+ Assert.Equal(12, slide.PosterFrame);
+
+ Assert.Null(SlideDeck.Parse("""{ "version": "soon", "slides": [ { "id": "a", "media": "a.webp", "title": "t", "text": "x" } ] }""", folder));
+ Assert.Null(SlideDeck.Parse("""{ "version": "3.0.0", "slides": [] }""", folder));
+ Assert.Null(SlideDeck.Parse("[]", folder));
+ Assert.Equal("2.1.3", Deck("2.1.3").DisplayVersion);
+ }
+
+ [Fact]
+ public void Versions_compare_by_three_parts()
+ {
+ Assert.Equal(V2, SlideDeck.TryParseVersion("2.0"));
+ Assert.Equal(V2, SlideDeck.TryParseVersion("v2.0.0-beta+abc"));
+ Assert.Equal(V2, SlideDeck.TryParseVersion("2"));
+ Assert.Null(SlideDeck.TryParseVersion(""));
+ Assert.Null(SlideDeck.TryParseVersion("next"));
+ }
+
+ // ───────────────────────── When the slides are due ─────────────────────────
+
+ private static readonly SlideDeck[] Decks = [Deck("2.0.0"), Deck("2.1.0"), Deck("2.2.0")];
+
+ [Fact]
+ public void A_fresh_install_shows_nothing_and_counts_its_version_as_seen()
+ {
+ var decision = WhatsNewService.Decide(null, firstRunCompleted: false, V2, Decks);
+ Assert.Null(decision.Show);
+ Assert.Equal(V2, decision.Remember);
+ }
+
+ [Fact]
+ public void An_update_from_before_the_slides_shows_this_versions_deck()
+ {
+ // Settings from 1.x have no WhatsNewSeenVersion, but the first run was long done.
+ var decision = WhatsNewService.Decide(null, firstRunCompleted: true, V2, Decks);
+ Assert.Equal(V2, decision.Show?.Version);
+ Assert.Null(decision.Remember); // remembered when the window shows, not before
+ Assert.Equal(V2, WhatsNewService.Decide("garbage", true, V2, Decks).Show?.Version);
+ }
+
+ [Fact]
+ public void Skipping_versions_shows_the_newest_deck_only()
+ {
+ Assert.Equal(new Version(2, 2, 0), WhatsNewService.Decide("2.0.0", true, new Version(2, 2, 1), Decks).Show?.Version);
+ Assert.Equal(new Version(2, 1, 0), WhatsNewService.Decide("2.0.0", true, new Version(2, 1, 5), Decks).Show?.Version);
+ }
+
+ [Fact]
+ public void An_update_without_slides_is_remembered_quietly()
+ {
+ var decision = WhatsNewService.Decide("2.2.0", true, new Version(2, 2, 1), Decks);
+ Assert.Null(decision.Show);
+ Assert.Equal(new Version(2, 2, 1), decision.Remember);
+ }
+
+ [Fact]
+ public void The_same_version_or_a_downgrade_shows_nothing_and_keeps_what_was_seen()
+ {
+ Assert.Equal(default, WhatsNewService.Decide("2.0.0", true, V2, Decks));
+ Assert.Equal(default, WhatsNewService.Decide("2.1.0", true, V2, Decks));
+ }
+
+ [AvaloniaFact]
+ public void Starting_in_the_background_waits_for_the_main_window()
+ {
+ TestServices.EnsureInitialized("en");
+ var (service, store, windows) = (AppHost.Get<WhatsNewService>(), AppHost.Get<UserDataStore>(), AppHost.Get<WindowService>());
+ var (seen, firstRun, version) = (store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, service.CurrentVersion);
+ try
+ {
+ service.CurrentVersion = V2;
+ store.Settings.FirstRunCompleted = true;
+ store.Settings.WhatsNewSeenVersion = null;
+
+ service.CheckAtStartup(background: true);
+ Pump();
+ Assert.Equal(V2, service.Pending?.Version);
+ Assert.Null(windows.WhatsNew);
+ Assert.Null(store.Settings.WhatsNewSeenVersion); // not seen yet: a quit now shows them next time
+
+ windows.ShowMain(); // the user opens Filee from the tray
+ Pump();
+ var window = Assert.IsType<WhatsNewWindow>(windows.WhatsNew);
+ Assert.True(window.IsVisible);
+ Assert.Null(service.Pending);
+ Assert.Equal("2.0.0", store.Settings.WhatsNewSeenVersion);
+ window.Close();
+
+ // Shown once: the next start has nothing to show.
+ service.CheckAtStartup(background: false);
+ Pump();
+ Assert.Null(service.Pending);
+ Assert.Null(windows.WhatsNew);
+ }
+ finally
+ {
+ windows.WhatsNew?.Close();
+ windows.Main?.Close();
+ (store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, service.CurrentVersion) = (seen, firstRun, version);
+ }
+ }
+
+ [AvaloniaFact]
+ public void A_fresh_install_is_marked_seen_without_a_window()
+ {
+ TestServices.EnsureInitialized("en");
+ var (service, store, windows) = (AppHost.Get<WhatsNewService>(), AppHost.Get<UserDataStore>(), AppHost.Get<WindowService>());
+ var (seen, firstRun, version) = (store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, service.CurrentVersion);
+ try
+ {
+ service.CurrentVersion = V2;
+ store.Settings.FirstRunCompleted = false;
+ store.Settings.WhatsNewSeenVersion = null;
+ service.CheckAtStartup(background: false);
+ Pump();
+ Assert.Null(windows.WhatsNew);
+ Assert.Null(service.Pending);
+ Assert.Equal("2.0.0", store.Settings.WhatsNewSeenVersion);
+ }
+ finally
+ {
+ (store.Settings.WhatsNewSeenVersion, store.Settings.FirstRunCompleted, service.CurrentVersion) = (seen, firstRun, version);
+ }
+ }
+
+ [Fact]
+ public void The_installer_can_ask_for_the_slides_after_an_update()
+ {
+ var options = CommandLine.Parse(["--background", "--whats-new"]);
+ Assert.True(options.Background);
+ Assert.True(options.WhatsNew);
+ Assert.False(CommandLine.Parse(["--background"]).WhatsNew);
+ }
+
+ // ───────────────────────── The window ─────────────────────────
+
+ private static WhatsNewWindow Open(string language = "en", Action? beforeOpening = null)
+ {
+ TestServices.EnsureInitialized(language);
+ beforeOpening?.Invoke();
+ var deck = SlideDeck.LoadAll("Filee").Single(d => d.Version == V2);
+ var window = new WhatsNewWindow(deck, AppHost.Get<ILocalizer>());
+ window.Show();
+ window.Activate();
+ Pump();
+ return window;
+ }
+
+ private static Button Named(Window window, string name) =>
+ window.GetVisualDescendants().OfType<Button>().Single(b => b.Name == name);
+
+ private static void Click(Button button)
+ {
+ button.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
+ Pump();
+ }
+
+ private static void Press(Window window, Key key)
+ {
+ window.KeyPress(key, RawInputModifiers.None, PhysicalKey.None, null);
+ if (window.IsVisible) // Esc closed it
+ window.KeyRelease(key, RawInputModifiers.None, PhysicalKey.None, null);
+ Pump();
+ }
+
+ [AvaloniaFact]
+ public void Next_and_previous_walk_the_slides_and_the_last_one_closes()
+ {
+ var window = Open();
+ var slides = window.SlideShow;
+ var (previous, primary) = (Named(window, "PreviousButton"), Named(window, "PrimaryButton"));
+ var loc = AppHost.Get<ILocalizer>();
+ try
+ {
+ Assert.Equal(0, slides.Index);
+ Assert.False(previous.IsEnabled);
+ Assert.Equal(0, previous.Opacity);
+ Assert.Equal(loc["whats_new.next"], primary.Content);
+ Assert.Equal(loc.Format("whats_new.title", "2.0"), window.Title);
+
+ Click(primary);
+ Assert.Equal(1, slides.Index);
+ Assert.True(previous.IsEnabled);
+ Click(previous);
+ Assert.Equal(0, slides.Index);
+
+ for (var i = 1; i < slides.Slides.Count; i++)
+ Click(primary);
+ Assert.True(slides.IsLast);
+ Assert.Equal(loc["whats_new.done"], primary.Content);
+ Assert.True(window.IsVisible);
+ Click(primary); // "Get started"
+ Assert.False(window.IsVisible);
+ }
+ finally
+ {
+ window.Close();
+ }
+ }
+
+ [AvaloniaFact]
+ public void Arrow_keys_move_and_escape_closes()
+ {
+ var window = Open();
+ try
+ {
+ Press(window, Key.Right);
+ Press(window, Key.Right);
+ Assert.Equal(2, window.SlideShow.Index);
+ Press(window, Key.Left);
+ Assert.Equal(1, window.SlideShow.Index);
+ Press(window, Key.Left);
+ Press(window, Key.Left); // stays on the first
+ Assert.Equal(0, window.SlideShow.Index);
+ Press(window, Key.Escape);
+ Assert.False(window.IsVisible);
+ }
+ finally
+ {
+ window.Close();
+ }
+ }
+
+ [AvaloniaFact]
+ public void The_close_button_closes_from_any_slide()
+ {
+ var window = Open();
+ try
+ {
+ window.SlideShow.GoTo(3);
+ Click(Named(window, "CloseButton"));
+ Assert.False(window.IsVisible);
+ }
+ finally
+ {
+ window.Close();
+ }
+ }
+
+ [AvaloniaFact]
+ public void Reduced_motion_shows_each_slides_poster_frame()
+ {
+ var before = Motion.Enabled;
+ var window = Open(beforeOpening: () => Motion.Set(false)); // after the theme, which applies the setting
+ try
+ {
+ var media = window.SlideShow.Media;
+ Assert.False(window.SlideShow.PlayAnimations);
+ Assert.True(media.HasPicture);
+ Assert.True(media.FrameCount > 1);
+ // The first slide names a poster frame: the donut open over the browser, not an empty desktop.
+ var poster = window.SlideShow.Slides[0].PosterFrame;
+ Assert.True(poster > 0);
+ Assert.Equal(poster, media.CurrentFrame);
+ Assert.False(media.IsPlaying);
+
+ Motion.Set(true);
+ Pump();
+ Assert.True(window.SlideShow.PlayAnimations);
+ Assert.True(media.IsPlaying);
+
+
+ // Switched off while open: back to the poster.
+ media.Tick();
+ Motion.Set(false);
+ Pump();
+ Assert.Equal(poster, media.CurrentFrame);
+ Assert.False(media.IsPlaying);
+ }
+ finally
+ {
+ window.Close();
+ Motion.Set(before);
+ }
+ }
+
+ [AvaloniaFact]
+ public void The_slides_keep_one_height_and_let_go_of_their_pictures_when_closed()
+ {
+ var window = Open("es");
+ var heights = new HashSet<double>();
+ for (var i = 0; i < window.SlideShow.Slides.Count; i++)
+ {
+ window.SlideShow.GoTo(i);
+ Pump();
+ heights.Add(window.Bounds.Height);
+ Assert.True(window.SlideShow.Media.HasPicture, $"slide {i} has no picture");
+ }
+ Assert.Single(heights);
+ var media = window.SlideShow.Media;
+ window.Close();
+ Pump();
+ Assert.False(media.HasPicture);
+ }
+
+ [AvaloniaFact]
+ public void About_offers_the_slides_again()
+ {
+ TestServices.EnsureInitialized("en");
+ var service = AppHost.Get<WhatsNewService>();
+ var store = AppHost.Get<UserDataStore>();
+ var (version, seen) = (service.CurrentVersion, store.Settings.WhatsNewSeenVersion);
+ try
+ {
+ service.CurrentVersion = new Version(2, 0, 3);
+ var vm = new MainWindowViewModel(AppHost.Services, AppHost.Get<ILocalizer>(), AppHost.Get<UpdateService>());
+ vm.Navigate("about");
+ var window = new MainWindow { DataContext = vm, Width = 1080, Height = 820 };
+ window.Show();
+ Pump();
+ var about = (AboutPageViewModel)vm.CurrentPage!;
+ Assert.Equal(AppHost.Get<ILocalizer>().Format("whats_new.about_link", "2.0"), about.WhatsNewText);
+ var link = Named(window, "WhatsNewLink");
+ Assert.True(link.IsEffectivelyVisible);
+ Save(window, "page-about-whats-new-en.png");
+
+ link.Command!.Execute(null);
+ Pump();
+ Assert.IsType<WhatsNewWindow>(AppHost.Get<WindowService>().WhatsNew);
+ Assert.Equal("2.0.3", store.Settings.WhatsNewSeenVersion);
+ AppHost.Get<WindowService>().WhatsNew!.Close();
+ window.Close();
+
+ // A version older than every deck has nothing to offer.
+ service.CurrentVersion = new Version(1, 12, 0);
+ using var older = new AboutPageViewModel(AppHost.Get<ILocalizer>(), store, AppHost.Get<UpdateService>(), service);
+ Assert.False(older.HasWhatsNew);
+ }
+ finally
+ {
+ (service.CurrentVersion, store.Settings.WhatsNewSeenVersion) = (version, seen);
+ }
+ }
+
+ // ───────────────────────── Screenshots ─────────────────────────
+
+ [AvaloniaTheory]
+ [InlineData("en", false)]
+ [InlineData("en", true)]
+ [InlineData("es", false)]
+ [InlineData("es", true)]
+ [InlineData("hi", false)]
+ [InlineData("ko", true)]
+ [InlineData("ja", false)]
+ [InlineData("zh-CN", false)]
+ [InlineData("pl", false)]
+ [InlineData("ru", false)]
+ [InlineData("ru", true)]
+ public void Window_renders(string language, bool dark)
+ {
+ TestServices.EnsureInitialized(language);
+ var theme = AppHost.Get<ThemeService>();
+ var window = Open(language, () => theme.Apply(new ThemeSettings { Mode = dark ? ThemeMode.Dark : ThemeMode.Light }, language));
+ var suffix = $"{language}-{(dark ? "dark" : "light")}";
+ try
+ {
+ Save(window, $"whatsnew-window-{suffix}-1.png");
+ window.SlideShow.GoTo(3);
+ Pump();
+ Save(window, $"whatsnew-window-{suffix}-4.png");
+ window.SlideShow.GoTo(window.SlideShow.Slides.Count - 1);
+ Pump();
+ Save(window, $"whatsnew-window-{suffix}-last.png");
+ }
+ finally
+ {
+ window.Close();
+ theme.Apply(new ThemeSettings(), "en");
+ }
+ }
+
+ private static Dictionary<string, string> LoadStrings(string code) =>
+ JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(
+ Path.Combine(WhatsNewMedia.RepositoryRoot, "src", "Filee.App", "Assets", "i18n", code + ".json")))!;
+
+ private static void Pump()
+ {
+ for (var i = 0; i < 20; i++)
+ {
+ Dispatcher.UIThread.RunJobs();
+ AvaloniaHeadlessPlatform.ForceRenderTimerTick();
+ }
+ }
+
+ private static void Save(TopLevel window, string name)
+ {
+ using var frame = window.CaptureRenderedFrame();
+ Assert.NotNull(frame);
+ using var stream = File.Create(Path.Combine(TestServices.ScreenshotDirectory, name));
+ frame.Save(stream, new Avalonia.Media.Imaging.PngBitmapEncoderOptions());
+ }
+}