merge: Archive manager after the visual, accessibility and RTL review

This commit is contained in:
Claude committed 2026-10-06 20:29:36 +00:00
commit 2d84811192
14 files changed
+737 -166

No files matched your search

+12 -1
View File
@@ -4,7 +4,7 @@
<resheader name="version"><value>2.0</value></resheader>
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<data name="Archive.Adopt.Copy" xml:space="preserve"><value>Copy into the layout…</value></data>
<data name="Archive.Adopt.Copy" xml:space="preserve"><value>Copy into archive…</value></data>
<data name="Archive.Adopt.InPlace" xml:space="preserve"><value>Index in place…</value></data>
<data name="Archive.Applied.one" xml:space="preserve"><value>{0:N0} sequence changed</value></data>
<data name="Archive.Applied.other" xml:space="preserve"><value>{0:N0} sequences changed</value></data>
@@ -37,6 +37,7 @@
<data name="Archive.Dialog.Cancel" xml:space="preserve"><value>Cancel</value></data>
<data name="Archive.Duplicates.Copies.one" xml:space="preserve"><value>{0:N0} copy</value></data>
<data name="Archive.Duplicates.Copies.other" xml:space="preserve"><value>{0:N0} copies</value></data>
<data name="Archive.Duplicates.Failed" xml:space="preserve"><value>The duplicate search stopped</value><comment>long</comment></data>
<data name="Archive.Duplicates.Folder" xml:space="preserve"><value>Folder</value></data>
<data name="Archive.Duplicates.Groups.one" xml:space="preserve"><value>{0:N0} group</value></data>
<data name="Archive.Duplicates.Groups.other" xml:space="preserve"><value>{0:N0} groups</value></data>
@@ -54,6 +55,11 @@
<data name="Archive.Error.SourceChanged" xml:space="preserve"><value>{0} changed after the plan was made.</value><comment>long: error sentence</comment></data>
<data name="Archive.Error.SourceGone" xml:space="preserve"><value>The card or folder {0} is no longer available.</value><comment>long: error sentence</comment></data>
<data name="Archive.Error.StalePlan" xml:space="preserve"><value>The archive changed after this plan was made.</value><comment>long: error sentence</comment></data>
<data name="Archive.Failed.Access" xml:space="preserve"><value>Titano was denied access to the archive.</value><comment>long</comment></data>
<data name="Archive.Failed.Files" xml:space="preserve"><value>A file of the archive could not be read or written.</value><comment>long</comment></data>
<data name="Archive.Failed.Gone" xml:space="preserve"><value>The sequence is no longer in the index.</value><comment>long</comment></data>
<data name="Archive.Failed.Index" xml:space="preserve"><value>The index could not be read or written.</value><comment>long</comment></data>
<data name="Archive.Failed.Retry" xml:space="preserve"><value>Retry</value></data>
<data name="Archive.Find.Cancel" xml:space="preserve"><value>Cancel</value></data>
<data name="Archive.Find.None" xml:space="preserve"><value>None found</value></data>
<data name="Archive.Find.Run" xml:space="preserve"><value>Find</value></data>
@@ -61,10 +67,13 @@
<data name="Archive.Health.AllVerified" xml:space="preserve"><value>Every sequence verified</value></data>
<data name="Archive.Health.AnalysedOk" xml:space="preserve"><value>Every sequence analysed</value></data>
<data name="Archive.Health.Damaged" xml:space="preserve"><value>{0} missing · {1} damaged</value></data>
<data name="Archive.Health.DuplicateGroups.one" xml:space="preserve"><value>{0:N0} duplicate group</value></data>
<data name="Archive.Health.DuplicateGroups.other" xml:space="preserve"><value>{0:N0} duplicate groups</value></data>
<data name="Archive.Health.Duplicates.one" xml:space="preserve"><value>{0:N0} duplicate frame</value></data>
<data name="Archive.Health.Duplicates.other" xml:space="preserve"><value>{0:N0} duplicate frames</value></data>
<data name="Archive.Health.Fix.Analyse" xml:space="preserve"><value>Analyse</value></data>
<data name="Archive.Health.Fix.Duplicates" xml:space="preserve"><value>Show</value></data>
<data name="Archive.Health.Fix.MarkDuplicates" xml:space="preserve"><value>Mark copies</value></data>
<data name="Archive.Health.Fix.Orphans" xml:space="preserve"><value>Find</value></data>
<data name="Archive.Health.Fix.Proxies" xml:space="preserve"><value>Build</value></data>
<data name="Archive.Health.Fix.Verify" xml:space="preserve"><value>Verify</value></data>
@@ -72,6 +81,7 @@
<data name="Archive.Health.NoDuplicates" xml:space="preserve"><value>No duplicate frames</value></data>
<data name="Archive.Health.NoProxies.one" xml:space="preserve"><value>{0:N0} sequence lacks proxies</value></data>
<data name="Archive.Health.NoProxies.other" xml:space="preserve"><value>{0:N0} sequences lack proxies</value></data>
<data name="Archive.Health.NoneFlagged" xml:space="preserve"><value>No copies flagged</value></data>
<data name="Archive.Health.NotAnalysed.one" xml:space="preserve"><value>{0:N0} sequence not analysed</value></data>
<data name="Archive.Health.NotAnalysed.other" xml:space="preserve"><value>{0:N0} sequences not analysed</value></data>
<data name="Archive.Health.ProxiesOk" xml:space="preserve"><value>Every sequence has proxies</value></data>
@@ -183,6 +193,7 @@
<data name="Archive.Toolbar.Verify" xml:space="preserve"><value>Verify</value></data>
<data name="Archive.Tree.Name" xml:space="preserve"><value>Archive tree</value></data>
<data name="Archive.Tree.Undated" xml:space="preserve"><value>Undated</value></data>
<data name="Archive.View.Health" xml:space="preserve"><value>Health</value></data>
<data name="Archive.View.Maintenance" xml:space="preserve"><value>Maintenance</value></data>
<data name="Archive.View.Name" xml:space="preserve"><value>View</value></data>
<data name="Archive.View.Overview" xml:space="preserve"><value>Overview</value></data>
+3
View File
@@ -39,6 +39,7 @@
<data name="Tooltips.Archive.FilterTag" xml:space="preserve"><value>Keep only the sequences with one tag</value></data>
<data name="Tooltips.Archive.Fix.Analyse" xml:space="preserve"><value>Queue the light analysis of these sequences</value></data>
<data name="Tooltips.Archive.Fix.Duplicates" xml:space="preserve"><value>Find the duplicate groups</value></data>
<data name="Tooltips.Archive.Fix.MarkDuplicates" xml:space="preserve"><value>Flag every copy after the first so renders skip it · runs maintenance</value></data>
<data name="Tooltips.Archive.Fix.Orphans" xml:space="preserve"><value>Find files and rows that do not match</value></data>
<data name="Tooltips.Archive.Fix.Proxies" xml:space="preserve"><value>Queue proxy generation for these sequences</value></data>
<data name="Tooltips.Archive.Fix.Verify" xml:space="preserve"><value>Re-hash the originals of these sequences</value></data>
@@ -69,6 +70,7 @@
<data name="Tooltips.Archive.Relink" xml:space="preserve"><value>Choose the new folder of an archive you moved; its sequences follow</value></data>
<data name="Tooltips.Archive.RenameApply" xml:space="preserve"><value>Make exactly these changes to folders, sidecars and index · resumes after a crash</value></data>
<data name="Tooltips.Archive.RetagApply" xml:space="preserve"><value>Change the tags of these sequences in sidecars and index</value></data>
<data name="Tooltips.Archive.Retry" xml:space="preserve"><value>Run the same action again</value></data>
<data name="Tooltips.Archive.Scan" xml:space="preserve"><value>Incremental scan: new, changed and removed files by modification time and size</value></data>
<data name="Tooltips.Archive.Set" xml:space="preserve"><value>The selected years and sequences (all when nothing is selected), narrowed by camera, status or tag</value></data>
<data name="Tooltips.Archive.SetAnalyse" xml:space="preserve"><value>Run the deep analysis on every sequence in the set</value></data>
@@ -86,6 +88,7 @@
<data name="Tooltips.Archive.TitleTemplate" xml:space="preserve"><value>Title template; the title token is the current title · checked as you type</value></data>
<data name="Tooltips.Archive.Verify" xml:space="preserve"><value>Re-hash every original and report bit rot · reads the whole archive</value></data>
<data name="Tooltips.Archive.YearRow" xml:space="preserve"><value>{0} · Right arrow opens the year, Left arrow closes it</value></data>
<data name="Tooltips.Archive.YearRowRtl" xml:space="preserve"><value>{0} · Left arrow opens the year, Right arrow closes it</value></data>
<data name="Tooltips.Common.Dismiss" xml:space="preserve"><value>Dismiss</value></data>
<data name="Tooltips.Common.DismissToast" xml:space="preserve"><value>Close this notice · Esc</value></data>
<data name="Tooltips.Common.OpenLogs" xml:space="preserve"><value>Open the folder with the log files</value></data>
+12 -1
View File
@@ -4,7 +4,7 @@
<resheader name="version"><value>2.0</value></resheader>
<resheader name="reader"><value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<resheader name="writer"><value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value></resheader>
<data name="Archive.Adopt.Copy" xml:space="preserve"><value>Copia nella struttura…</value></data>
<data name="Archive.Adopt.Copy" xml:space="preserve"><value>Copia nell'archivio…</value></data>
<data name="Archive.Adopt.InPlace" xml:space="preserve"><value>Indicizza sul posto…</value></data>
<data name="Archive.Applied.one" xml:space="preserve"><value>{0:N0} sequenza modificata</value></data>
<data name="Archive.Applied.other" xml:space="preserve"><value>{0:N0} sequenze modificate</value></data>
@@ -34,6 +34,7 @@
<data name="Archive.Dialog.Cancel" xml:space="preserve"><value>Annulla</value></data>
<data name="Archive.Duplicates.Copies.one" xml:space="preserve"><value>{0:N0} copia</value></data>
<data name="Archive.Duplicates.Copies.other" xml:space="preserve"><value>{0:N0} copie</value></data>
<data name="Archive.Duplicates.Failed" xml:space="preserve"><value>Ricerca dei doppioni interrotta</value></data>
<data name="Archive.Duplicates.Folder" xml:space="preserve"><value>Cartella</value></data>
<data name="Archive.Duplicates.Groups.one" xml:space="preserve"><value>{0:N0} gruppo</value></data>
<data name="Archive.Duplicates.Groups.other" xml:space="preserve"><value>{0:N0} gruppi</value></data>
@@ -50,6 +51,11 @@
<data name="Archive.Error.SourceChanged" xml:space="preserve"><value>{0} è cambiato dopo la creazione del piano.</value></data>
<data name="Archive.Error.SourceGone" xml:space="preserve"><value>La scheda o cartella {0} non è più disponibile.</value></data>
<data name="Archive.Error.StalePlan" xml:space="preserve"><value>L'archivio è cambiato dopo la creazione del piano.</value></data>
<data name="Archive.Failed.Access" xml:space="preserve"><value>Titano non ha accesso all'archivio.</value></data>
<data name="Archive.Failed.Files" xml:space="preserve"><value>Non è stato possibile leggere o scrivere un file dell'archivio.</value></data>
<data name="Archive.Failed.Gone" xml:space="preserve"><value>La sequenza non è più nell'indice.</value></data>
<data name="Archive.Failed.Index" xml:space="preserve"><value>Non è stato possibile leggere o scrivere l'indice.</value></data>
<data name="Archive.Failed.Retry" xml:space="preserve"><value>Riprova</value></data>
<data name="Archive.Find.Cancel" xml:space="preserve"><value>Annulla</value></data>
<data name="Archive.Find.None" xml:space="preserve"><value>Nessuno trovato</value></data>
<data name="Archive.Find.Run" xml:space="preserve"><value>Cerca</value></data>
@@ -57,10 +63,13 @@
<data name="Archive.Health.AllVerified" xml:space="preserve"><value>Tutte le sequenze verificate</value></data>
<data name="Archive.Health.AnalysedOk" xml:space="preserve"><value>Tutte le sequenze analizzate</value></data>
<data name="Archive.Health.Damaged" xml:space="preserve"><value>{0} mancanti · {1} danneggiati</value></data>
<data name="Archive.Health.DuplicateGroups.one" xml:space="preserve"><value>{0:N0} gruppo di doppioni</value></data>
<data name="Archive.Health.DuplicateGroups.other" xml:space="preserve"><value>{0:N0} gruppi di doppioni</value></data>
<data name="Archive.Health.Duplicates.one" xml:space="preserve"><value>{0:N0} fotogramma doppio</value></data>
<data name="Archive.Health.Duplicates.other" xml:space="preserve"><value>{0:N0} fotogrammi doppi</value></data>
<data name="Archive.Health.Fix.Analyse" xml:space="preserve"><value>Analizza</value></data>
<data name="Archive.Health.Fix.Duplicates" xml:space="preserve"><value>Mostra</value></data>
<data name="Archive.Health.Fix.MarkDuplicates" xml:space="preserve"><value>Segna copie</value></data>
<data name="Archive.Health.Fix.Orphans" xml:space="preserve"><value>Cerca</value></data>
<data name="Archive.Health.Fix.Proxies" xml:space="preserve"><value>Crea</value></data>
<data name="Archive.Health.Fix.Verify" xml:space="preserve"><value>Verifica</value></data>
@@ -68,6 +77,7 @@
<data name="Archive.Health.NoDuplicates" xml:space="preserve"><value>Nessun fotogramma doppio</value></data>
<data name="Archive.Health.NoProxies.one" xml:space="preserve"><value>{0:N0} sequenza senza proxy</value></data>
<data name="Archive.Health.NoProxies.other" xml:space="preserve"><value>{0:N0} sequenze senza proxy</value></data>
<data name="Archive.Health.NoneFlagged" xml:space="preserve"><value>Nessuna copia segnata</value></data>
<data name="Archive.Health.NotAnalysed.one" xml:space="preserve"><value>{0:N0} sequenza non analizzata</value></data>
<data name="Archive.Health.NotAnalysed.other" xml:space="preserve"><value>{0:N0} sequenze non analizzate</value></data>
<data name="Archive.Health.ProxiesOk" xml:space="preserve"><value>Ogni sequenza ha i proxy</value></data>
@@ -177,6 +187,7 @@
<data name="Archive.Toolbar.Verify" xml:space="preserve"><value>Verifica</value></data>
<data name="Archive.Tree.Name" xml:space="preserve"><value>Albero dell'archivio</value></data>
<data name="Archive.Tree.Undated" xml:space="preserve"><value>Senza data</value></data>
<data name="Archive.View.Health" xml:space="preserve"><value>Stato</value></data>
<data name="Archive.View.Maintenance" xml:space="preserve"><value>Manutenzione</value></data>
<data name="Archive.View.Name" xml:space="preserve"><value>Vista</value></data>
<data name="Archive.View.Overview" xml:space="preserve"><value>Panoramica</value></data>
+3
View File
@@ -39,6 +39,7 @@
<data name="Tooltips.Archive.FilterTag" xml:space="preserve"><value>Tieni solo le sequenze con un tag</value></data>
<data name="Tooltips.Archive.Fix.Analyse" xml:space="preserve"><value>Metti in coda l'analisi rapida di queste sequenze</value></data>
<data name="Tooltips.Archive.Fix.Duplicates" xml:space="preserve"><value>Trova i gruppi di doppioni</value></data>
<data name="Tooltips.Archive.Fix.MarkDuplicates" xml:space="preserve"><value>Segna ogni copia dopo la prima perché i render la saltino · esegue la manutenzione</value></data>
<data name="Tooltips.Archive.Fix.Orphans" xml:space="preserve"><value>Trova file e righe che non corrispondono</value></data>
<data name="Tooltips.Archive.Fix.Proxies" xml:space="preserve"><value>Metti in coda la creazione dei proxy per queste sequenze</value></data>
<data name="Tooltips.Archive.Fix.Verify" xml:space="preserve"><value>Ricalcola l'hash degli originali di queste sequenze</value></data>
@@ -69,6 +70,7 @@
<data name="Tooltips.Archive.Relink" xml:space="preserve"><value>Scegli la nuova cartella di un archivio spostato; le sequenze lo seguono</value></data>
<data name="Tooltips.Archive.RenameApply" xml:space="preserve"><value>Applica esattamente queste modifiche a cartelle, sidecar e indice · riprende dopo un arresto</value></data>
<data name="Tooltips.Archive.RetagApply" xml:space="preserve"><value>Cambia i tag di queste sequenze in sidecar e indice</value></data>
<data name="Tooltips.Archive.Retry" xml:space="preserve"><value>Esegui di nuovo la stessa azione</value></data>
<data name="Tooltips.Archive.Scan" xml:space="preserve"><value>Scansione incrementale: file nuovi, modificati e rimossi per data e dimensione</value></data>
<data name="Tooltips.Archive.Set" xml:space="preserve"><value>Anni e sequenze selezionati (tutti se nulla è selezionato), ristretti per fotocamera, stato o tag</value></data>
<data name="Tooltips.Archive.SetAnalyse" xml:space="preserve"><value>Esegui l'analisi profonda su ogni sequenza della selezione</value></data>
@@ -86,6 +88,7 @@
<data name="Tooltips.Archive.TitleTemplate" xml:space="preserve"><value>Modello del titolo; il segnaposto title è il titolo attuale · controllato mentre scrivi</value></data>
<data name="Tooltips.Archive.Verify" xml:space="preserve"><value>Ricalcola l'hash di ogni originale e segnala i danni · legge tutto l'archivio</value></data>
<data name="Tooltips.Archive.YearRow" xml:space="preserve"><value>{0} · Freccia destra apre l'anno, freccia sinistra lo chiude</value></data>
<data name="Tooltips.Archive.YearRowRtl" xml:space="preserve"><value>{0} · Freccia sinistra apre l'anno, freccia destra lo chiude</value></data>
<data name="Tooltips.Common.Dismiss" xml:space="preserve"><value>Chiudi</value></data>
<data name="Tooltips.Common.DismissToast" xml:space="preserve"><value>Chiudi questo avviso · Esc</value></data>
<data name="Tooltips.Common.OpenLogs" xml:space="preserve"><value>Apri la cartella dei file di log</value></data>
@@ -16,13 +16,15 @@ namespace Titano.App.Archiving;
/// <summary>
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs, the way out
/// stops it when it can be stopped, and is disabled otherwise; the close callback receives the dialog, so a late close
/// never closes another one.
/// never closes another one. A failure stays on screen as one sentence until the next attempt.
/// </summary>
public abstract class ArchiveDialogViewModel : LocalizedViewModel
{
private readonly Action<ArchiveDialogViewModel> _close;
private bool _isBusy;
private string? _busyText;
private string? _errorText;
private string? _errorToolTip;
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close)
{
@@ -61,11 +63,32 @@ public abstract class ArchiveDialogViewModel : LocalizedViewModel
public string? BusyText { get => _busyText; protected set => Set(ref _busyText, value); }
/// <summary>Why the last dry run or apply stopped (<see cref="ArchiveFailures.Cause"/>); null when nothing failed.</summary>
public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); }
/// <summary>The failure as the engine reported it, for the tooltip.</summary>
public string? ErrorToolTip { get => _errorToolTip; private set => Set(ref _errorToolTip, value); }
protected void Close() => _close(this);
protected void ShowError(Exception ex)
{
ErrorText = ArchiveFailures.Cause(ex);
ErrorToolTip = ex.Message;
}
protected void ClearError()
{
ErrorText = null;
ErrorToolTip = null;
}
}
/// <summary>A fact of the rebuild dialog ("Sidecars · 412").</summary>
public sealed record DialogFact(string Label, string Value);
/// <summary>A fact of the rebuild dialog ("Sidecars · 412"); a path stays left to right, a missing value says why in its tooltip.</summary>
public sealed record DialogFact(string Label, string Value, bool IsPath = false, string? Reason = null)
{
public string ToolTip => Reason ?? Value;
}
/// <summary>
/// "Rebuild index" (BRIEF §12.5): what the rebuild reads — the sidecars on disk, then a full metadata scan of folders
@@ -84,7 +107,7 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
Archive = archive;
Availability = availability;
Indexed = indexed;
_facts = Facts(null);
_facts = Facts(null, availability == ArchiveAvailability.Offline ? Loc.L("Archive.Error.Offline", Formatting.LeftToRight(archive.RootPath)) : null);
RebuildCommand = new AsyncRelayCommand(RebuildAsync, () => !IsBusy && availability == ArchiveAvailability.Online);
}
@@ -98,7 +121,10 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
public string RebuildToolTip => Availability == ArchiveAvailability.Online ? Loc.L("Tooltips.Archive.RebuildStart") : Loc.L("Archive.Blocked.NotOnline");
/// <summary>Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread).</summary>
/// <summary>
/// Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread). The counts
/// read "Counting…" only while the walk runs; an offline archive or a failed walk leaves "—" with the reason.
/// </summary>
public async Task CountAsync()
{
if (Availability == ArchiveAvailability.Offline) return;
@@ -107,11 +133,12 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
{
var root = Archive.RootPath;
var folders = await Task.Run(() => ArchiveScanner.FindSequenceFolders(new ArchivePaths(root)));
FactRows = Facts(folders);
FactRows = Facts(folders, null);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
Log.Warning("archive", "Counting sidecars failed", ex);
FactRows = Facts(null, ArchiveFailures.Cause(ex));
}
finally
{
@@ -120,19 +147,24 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
}
/// <summary>Shows counts computed elsewhere (capture).</summary>
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders);
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders, null);
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders)
/// <param name="folders">The counted folders; null while counting or when they cannot be counted.</param>
/// <param name="uncounted">Why the folders cannot be counted; null while counting.</param>
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders, string? uncounted)
{
var waiting = Loc.L("Archive.Rebuild.Counting");
DialogFact Count(string label, Func<SequenceFolder, bool> counted) =>
folders is not null ? new(label, Formatting.Count(folders.Count(counted)))
: uncounted is not null ? new(label, "—", Reason: uncounted)
: new(label, Loc.L("Archive.Rebuild.Counting"));
return
[
new(Loc.L("Archive.Rebuild.Archive"), Archive.Name),
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath),
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath, IsPath: true),
new(Loc.L("Archive.Rebuild.State"), Loc.L("Archive.Availability." + Availability)),
new(Loc.L("Archive.Rebuild.Indexed"), Loc.Plural("Shell.Status.Sequences", Indexed)),
new(Loc.L("Archive.Rebuild.Sidecars"), folders is null ? waiting : Formatting.Count(folders.Count(f => f.Sidecar is not null))),
new(Loc.L("Archive.Rebuild.Metadata"), folders is null ? waiting : Formatting.Count(folders.Count(f => f.Sidecar is null))),
Count(Loc.L("Archive.Rebuild.Sidecars"), f => f.Sidecar is not null),
Count(Loc.L("Archive.Rebuild.Metadata"), f => f.Sidecar is null),
];
}
@@ -163,6 +195,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
private readonly Func<int, Task> _applied;
private readonly DispatcherTimer _delay = new() { Interval = TimeSpan.FromMilliseconds(400) };
private RenamePlan? _plan;
private string? _planError;
private IReadOnlyList<RenameRow> _rows = [];
private CancellationTokenSource? _planning;
@@ -196,7 +229,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
private string? ApplyBlocker =>
IsBusy ? Loc.L("Archive.Blocked.Applying")
: Template.Error is { } error ? error
: _plan is null ? Loc.L("Archive.Blocked.Planning")
: _plan is null ? _planError ?? Loc.L("Archive.Blocked.Planning")
: _plan.Steps.Count == 0 ? Loc.L("Archive.Blocked.NoChanges")
: null;
@@ -221,14 +254,20 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
base.Dispose();
}
/// <summary>The dry run of the current template (the engine's plan; nothing changes on disk).</summary>
public async Task PlanAsync()
/// <summary>The dry run of the current template (the engine's plan; nothing changes on disk); it clears the last failure.</summary>
public Task PlanAsync()
{
ClearError();
return DryRunAsync();
}
private async Task DryRunAsync()
{
_planning?.Cancel();
_plan = null;
_planError = null;
Rows = [];
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
OnPlanChanged();
if (Template.HasErrors) return;
var cts = _planning = new CancellationTokenSource();
var template = Template.Text;
@@ -240,41 +279,57 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
if (cts.IsCancellationRequested) return;
_plan = plan;
Rows = MassRename.Rows(plan, Mode);
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
CommandManager.InvalidateRequerySuggested();
}
catch (OperationCanceledException) when (cts.IsCancellationRequested)
{
return;
}
catch (Exception ex) when (ex is ArgumentException or DatabaseException or FormatException)
{
Log.Warning("archive", "Rename plan failed", ex);
BusyText = ex.Message;
_planError = ArchiveFailures.Cause(ex);
ShowError(ex);
}
OnPlanChanged();
}
private void OnPlanChanged()
{
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
CommandManager.InvalidateRequerySuggested();
}
private async Task ApplyAsync()
{
if (_plan is not { } plan) return;
ClearError();
IsBusy = true;
var progress = new Progress<int>(n => BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count)));
// A tick posted before the apply ended must not bring its progress back.
var progress = new Progress<int>(n =>
{
if (IsBusy) BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count));
});
try
{
await Task.Run(() => _archives.ApplyRenameAsync(plan, progress));
Log.Info("archive", $"{Mode} applied to {plan.Steps.Count} sequence(s)");
await _applied(plan.Steps.Count);
Close();
return;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or ArchiveOfflineException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or DatabaseException)
{
Log.Warning("archive", "Rename failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
IsBusy = false;
BusyText = null;
}
// Part of the plan may have been applied, or the archive changed under it: the dry run shows what is left.
await DryRunAsync();
}
}
@@ -338,6 +393,7 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
var changes = Changes();
var run = _run = new CancellationTokenSource();
var done = 0;
ClearError();
IsBusy = true;
try
{
@@ -351,16 +407,17 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
await _applied(done);
Close();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException or ArchiveOfflineException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Retag failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
_run = null;
run.Dispose();
IsBusy = false;
BusyText = null;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using Titano.App.Infrastructure;
using Titano.Core.Archiving;
using Titano.Core.Localization;
using Titano.Data;
using Titano.Data.Archiving;
namespace Titano.App.Archiving;
/// <summary>
/// Why an Archive screen action stopped, as one localized sentence chosen by cause (BRIEF §0.2 rule 6). The
/// exception's own text, which may be technical or unlocalized, goes to the tooltip and the log only.
/// </summary>
public static class ArchiveFailures
{
public static string Cause(Exception ex) => ex switch
{
ArchiveOfflineException offline => Loc.L(offline.Availability == ArchiveAvailability.ReadOnly ? "Archive.Error.ReadOnly" : "Archive.Error.Offline",
Formatting.LeftToRight(offline.Root)),
// Already one localized sentence each.
LeaseUnavailableException or StaleRenamePlanException => ex.Message,
UnauthorizedAccessException => Loc.L("Archive.Failed.Access"),
DatabaseException => Loc.L("Archive.Failed.Index"),
ArgumentException => Loc.L("Archive.Failed.Gone"),
_ => Loc.L("Archive.Failed.Files"),
};
}
+32 -9
View File
@@ -23,6 +23,7 @@ public enum HealthAction
Proxies,
Analyse,
Duplicates,
MarkDuplicates,
Orphans,
}
@@ -44,7 +45,7 @@ public static class ArchiveFigures
var years = stats.ByYear.Select(y => y.Year).ToList();
var range = years.Count == 0 ? "—"
: years.Min() == years.Max() ? Year(years.Min())
: Loc.L("Archive.Tile.YearRange", Year(years.Min()), Year(years.Max()));
: Formatting.LeftToRight(Loc.L("Archive.Tile.YearRange", Year(years.Min()), Year(years.Max())));
var cameras = stats.ByCamera.Count(c => !string.IsNullOrWhiteSpace(c.Model) || !string.IsNullOrWhiteSpace(c.Make));
return
[
@@ -56,9 +57,22 @@ public static class ArchiveFigures
];
}
/// <summary>Culture month initials for the heatmap columns ("J F M …", "G F M …").</summary>
public static IReadOnlyList<string> MonthLabels() =>
[.. Loc.Culture.DateTimeFormat.AbbreviatedMonthNames.Take(12).Select(m => m.Length == 0 ? string.Empty : char.ToUpper(m[0], Loc.Culture).ToString())];
/// <summary>
/// The heatmap columns: month initials where the culture's month names start with a letter of a cased alphabet
/// ("J F M …", "G F M …"); month numbers in every other language, whose abbreviations are numbered ("1月",
/// "Tháng 1"), start alike or do not abbreviate to one letter (Thai, Arabic, Hebrew, Persian).
/// </summary>
public static IReadOnlyList<string> MonthLabels()
{
var culture = Loc.Culture;
var names = culture.DateTimeFormat.AbbreviatedMonthNames.Take(12).ToList();
return names.All(HasInitial)
? [.. names.Select(m => char.ToUpper(m[0], culture).ToString())]
: [.. Enumerable.Range(1, 12).Select(month => month.ToString("N0", culture))];
}
private static bool HasInitial(string month) =>
month.Length > 0 && char.IsLetter(month[0]) && char.ToUpperInvariant(month[0]) != char.ToLowerInvariant(month[0]) && !month.Any(char.IsDigit);
/// <summary>One row per year from the first to the last with photos, oldest first; months after <paramref name="today"/> are NaN.</summary>
public static IReadOnlyList<HeatRow> PhotosPerMonth(ArchiveStats stats, DateTime today)
@@ -125,8 +139,11 @@ public static class ArchiveFigures
_ => format.ToString().ToUpperInvariant(),
};
/// <summary>Index health (Archive.html): what needs attention, each with its fix.</summary>
public static IReadOnlyList<HealthLine> Health(ArchiveStats stats, int withoutProxies)
/// <summary>
/// Index health (Archive.html): what needs attention, each with its fix. Duplicates follow the last duplicates
/// search (<paramref name="duplicateGroups"/>, groups found by hash); before one, the copies already flagged.
/// </summary>
public static IReadOnlyList<HealthLine> Health(ArchiveStats stats, int withoutProxies, int? duplicateGroups = null)
{
var h = stats.Health;
var damaged = h.MissingFrames + h.CorruptFrames;
@@ -144,12 +161,18 @@ public static class ArchiveFigures
h.NotAnalyzed == 0
? new HealthLine(true, Loc.L("Archive.Health.AnalysedOk"), HealthAction.None)
: new HealthLine(false, Loc.Plural("Archive.Health.NotAnalysed", h.NotAnalyzed), HealthAction.Analyse),
h.DuplicateFrames == 0
? new HealthLine(true, Loc.L("Archive.Health.NoDuplicates"), HealthAction.None)
: new HealthLine(false, Loc.Plural("Archive.Health.Duplicates", h.DuplicateFrames), HealthAction.Duplicates),
Duplicates(h.DuplicateFrames, duplicateGroups),
];
}
private static HealthLine Duplicates(long flagged, int? groups) => groups switch
{
0 => new HealthLine(true, Loc.L("Archive.Health.NoDuplicates"), HealthAction.None),
{ } found => new HealthLine(false, Loc.Plural("Archive.Health.DuplicateGroups", found), HealthAction.MarkDuplicates),
null when flagged == 0 => new HealthLine(true, Loc.L("Archive.Health.NoneFlagged"), HealthAction.None),
null => new HealthLine(false, Loc.Plural("Archive.Health.Duplicates", flagged), HealthAction.Duplicates),
};
private static IReadOnlyList<BarValue> Shares(List<(string Name, long Photos)> ranked, int top, Func<int, string> restLabel, long total)
{
var bars = new List<BarValue>(top + 1);
+15 -6
View File
@@ -24,8 +24,18 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
public string ToggleToolTip => Loc.L(Node.IsExpanded ? "Tooltips.Archive.Collapse" : "Tooltips.Archive.Expand");
/// <summary>The row's figures; a year also says how the keyboard opens and closes it.</summary>
public string RowToolTip => IsYear ? Loc.L("Tooltips.Archive.YearRow", Detail) : Detail;
/// <summary>
/// The full title (the tree trims it) and its figures; a year also says how the keyboard opens and closes it, with
/// the arrow keys swapped in a right-to-left layout.
/// </summary>
public string RowToolTip
{
get
{
var text = Title + " · " + Detail;
return IsYear ? Loc.L(Loc.IsRightToLeft ? "Tooltips.Archive.YearRowRtl" : "Tooltips.Archive.YearRow", text) : text;
}
}
public ICommand ToggleCommand { get; } = new RelayCommand(() => toggle(node));
@@ -42,12 +52,12 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
public string AvailabilityToolTip => Loc.L("Tooltips.Archive.Availability." + availability);
}
/// <summary>A line of "Index health" with its fix.</summary>
/// <summary>A line of "Index health" with its fix: ● ok or ▲ needs attention.</summary>
public sealed class HealthLineViewModel(HealthLine line, ICommand? fix) : ObservableObject
{
public HealthLine Line { get; } = line;
public string Text => Line.Text;
public StatusKind Kind => Line.IsOk ? StatusKind.Done : StatusKind.Warning;
public bool IsOk => Line.IsOk;
public string KindToolTip => Loc.L(Line.IsOk ? "Tooltips.Archive.HealthOk" : "Tooltips.Archive.HealthWarning");
public bool HasFix => FixCommand is not null && Line.Action != HealthAction.None;
public ICommand? FixCommand { get; } = fix;
@@ -64,11 +74,10 @@ public sealed class DuplicateRowViewModel(DuplicateRow row, ICommand open, IComm
public ICommand RevealCommand { get; } = reveal;
}
/// <summary>An orphan line with its fix (index, reconcile, remove the row, scan).</summary>
/// <summary>An orphan line with its fix (index, reconcile, remove the row, scan); every kind is a ▲ warning the fix resolves.</summary>
public sealed class OrphanRowViewModel(OrphanRow row, ICommand fix) : ObservableObject
{
public OrphanRow Row { get; } = row;
public StatusKind Kind => Row.Kind is OrphanKind.MissingFiles or OrphanKind.MissingSequence ? StatusKind.Warning : StatusKind.Queued;
public string KindText => Loc.L("Archive.Orphans.Kind." + Row.Kind);
public ICommand FixCommand { get; } = fix;
public string FixText => Loc.L("Archive.Orphans.Fix." + Row.Kind);
+26 -6
View File
@@ -4,6 +4,7 @@ using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Archiving;
using Titano.Data.Repositories;
using Titano.Ui.Controls;
namespace Titano.App.Archiving;
@@ -30,11 +31,26 @@ public enum OrphanKind
public sealed record OrphanRow(OrphanKind Kind, string Title, string Detail, Guid? SequenceId);
/// <summary>A line of "Recent maintenance": date, operation and outcome.</summary>
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State);
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State)
{
/// <summary>The outcome's glyph and colour, as on the Jobs screen (paired with the word, never colour alone).</summary>
public StatusKind StateKind => State switch
{
JobState.Running => StatusKind.Running,
JobState.Queued => StatusKind.Queued,
JobState.Paused => StatusKind.Paused,
JobState.Done => StatusKind.Done,
JobState.Failed => StatusKind.Failed,
_ => StatusKind.Offline,
};
public string StateToolTip => Loc.L("Tooltips.Jobs.State." + State);
}
/// <summary>
/// The Maintenance view's reports (BRIEF §12.5): duplicates across sequences, orphans with their safe fixes, and the
/// recent archive jobs. Nothing here deletes a file; the only removal is of index rows whose sidecar is gone.
/// recent archive jobs. Nothing here deletes a file; the only removal is of index rows whose sidecar is gone. Folders
/// and paths are kept left to right inside right-to-left text (BRIEF §16).
/// </summary>
public static class MaintenanceReports
{
@@ -50,7 +66,8 @@ public static class MaintenanceReports
{
var first = g.Frames[0];
var name = first.RelativePath[(first.RelativePath.LastIndexOf('/') + 1)..];
var places = g.Frames.Select(f => Loc.L("Archive.Duplicates.Place", titles.GetValueOrDefault(f.SequenceId, f.RelativePath), f.RelativePath)).ToList();
var places = g.Frames.Select(f => Loc.L("Archive.Duplicates.Place", titles.GetValueOrDefault(f.SequenceId, f.RelativePath),
Formatting.LeftToRight(f.RelativePath))).ToList();
return new DuplicateRow(name, Loc.Plural("Archive.Duplicates.Copies", g.Frames.Count), places, first.SequenceId);
}),
];
@@ -63,16 +80,19 @@ public static class MaintenanceReports
foreach (var s in report.Sequences)
{
byFolder.TryGetValue(s.Folder, out var location);
var title = location?.Title ?? s.Folder;
var title = location?.Title ?? Formatting.LeftToRight(s.Folder);
if (s.UnindexedFiles.Count > 0)
rows.Add(new OrphanRow(OrphanKind.UnlistedFiles, title, Loc.Plural("Archive.Orphans.Unlisted", s.UnindexedFiles.Count), location?.Id));
if (s.MissingFiles.Count > 0)
rows.Add(new OrphanRow(OrphanKind.MissingFiles, title, Loc.Plural("Archive.Orphans.Missing", s.MissingFiles.Count), location?.Id));
}
foreach (var missing in report.MissingSequences)
rows.Add(new OrphanRow(OrphanKind.MissingSequence, missing.Title ?? missing.Folder, Loc.L("Archive.Orphans.NoSidecar", missing.Folder), missing.Id));
{
var folder = Formatting.LeftToRight(missing.Folder);
rows.Add(new OrphanRow(OrphanKind.MissingSequence, missing.Title ?? folder, Loc.L("Archive.Orphans.NoSidecar", folder), missing.Id));
}
foreach (var folder in report.UnindexedFolders)
rows.Add(new OrphanRow(OrphanKind.NewFolder, folder.Length == 0 ? "/" : folder, Loc.L("Archive.Orphans.NewFolder"), null));
rows.Add(new OrphanRow(OrphanKind.NewFolder, Formatting.LeftToRight(folder.Length == 0 ? "/" : folder), Loc.L("Archive.Orphans.NewFolder"), null));
return rows;
}
+204 -82
View File
@@ -5,8 +5,39 @@
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:ar="clr-namespace:Titano.App.Archiving"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:shell="clr-namespace:Titano.App.Shell">
<UserControl.Resources>
<!-- Keyboard focus drawn inside the row (DESIGN §4 ring): an outer ring would be clipped by the list's scroll viewer. -->
<Style x:Key="Focus.Inset">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{DynamicResource Brush.Accent}" BorderThickness="2" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
Lists keep their panel's fill while the screen behind a dialog is disabled: the system template would paint them
white. Rows and buttons dim themselves.
-->
<Style TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Padding="1" SnapsToDevicePixels="True">
<ScrollViewer Focusable="False" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Text.PanelHeading" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}">
<Setter Property="FontSize" Value="13" />
<Setter Property="VerticalAlignment" Value="Center" />
@@ -21,11 +52,39 @@
<!-- Rows that only show text: focusable, so the arrow keys move through a long list. -->
<Style x:Key="ListBoxItem.Preview" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding To}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding From}" />
</Style>
<!-- Report rows with their own buttons: Tab reaches every button. -->
<Style x:Key="ListBoxItem.Duplicate" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Row.Detail}" />
</Style>
<!-- Dialog labels: a column at least 116 px wide that grows with the longest label (DESIGN §2: no fixed-width labels). -->
<Style x:Key="Text.DialogLabel" TargetType="TextBlock" BasedOn="{StaticResource Text.Label}">
<Setter Property="TextTrimming" Value="None" />
</Style>
<!-- A status line screen readers announce when it changes. -->
<Style x:Key="Text.Live" TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="AutomationProperties.LiveSetting" Value="Polite" />
</Style>
<!-- A dialog's failure: one sentence in the error colour with its glyph, the engine's own text in the tooltip, announced at once. -->
<Style x:Key="Status.DialogError" TargetType="ui:StatusGlyph" BasedOn="{StaticResource {x:Type ui:StatusGlyph}}">
<Setter Property="Kind" Value="Error" />
<Setter Property="FontSize" Value="12" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Text" Value="{Binding ErrorText}" />
<Setter Property="ToolTip" Value="{Binding ErrorToolTip}" />
<Setter Property="AutomationProperties.LiveSetting" Value="Assertive" />
<Setter Property="infra:LiveRegion.Text" Value="{Binding ErrorText}" />
<Setter Property="Visibility" Value="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</Style>
<!-- A filter menu: its values, each checked while chosen. -->
<Style x:Key="MenuItem.Choice" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
@@ -52,21 +111,29 @@
<Border Style="{StaticResource Border.Dialog}" Width="520">
<StackPanel>
<TextBlock Text="{l:Loc Archive.Rebuild.Heading}" Style="{StaticResource Text.Title}" />
<ItemsControl ItemsSource="{Binding FactRows}" Focusable="False" Margin="0,14,0,0">
<ItemsControl ItemsSource="{Binding FactRows}" Focusable="False" Margin="0,14,0,0" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:DialogFact}">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" SharedSizeGroup="FactLabel" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.Label}" />
<TextBlock Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Value}" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.DialogLabel}" />
<TextBlock x:Name="Value" Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}"
Typography.NumeralAlignment="Tabular" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsPath}" Value="True">
<Setter TargetName="Value" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="Value" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}"
Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,18,0,0">
<Button Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True" IsCancel="True"
MinWidth="96" />
@@ -90,12 +157,14 @@
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Grid.Row="1" Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Archive.Rename.Template}" Style="{StaticResource Text.Label}" />
<TextBox Grid.Column="1" Style="{StaticResource TextBox.Mono}" Text="{Binding Template.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Template}" ToolTip="{Binding Template.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Rename.Template}" />
<TextBlock Text="{l:Loc Archive.Rename.Template}" Style="{StaticResource Text.DialogLabel}" />
<!-- A naming template keeps its tokens and separators in order in every language. -->
<TextBox Grid.Column="1" Style="{StaticResource TextBox.Mono}" FlowDirection="LeftToRight"
Text="{Binding Template.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Template}"
ToolTip="{Binding Template.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Rename.Template}" />
</Grid>
<TextBlock Grid.Row="2" Text="{Binding SummaryText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,12,0,6" Typography.NumeralAlignment="Tabular" />
<ListBox Grid.Row="3" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.Preview}" MinHeight="120"
@@ -108,19 +177,31 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding From}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{Binding From}" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.Forward}" Margin="10,0" Foreground="{DynamicResource Brush.TextFaint}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding To}" ToolTip="{Binding To}" />
<TextBlock x:Name="From" Style="{StaticResource Text.Cell}" Text="{Binding From}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{Binding From}" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.Forward}" Margin="10,0" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock x:Name="To" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding To}" ToolTip="{Binding To}" />
</Grid>
<DataTemplate.Triggers>
<!-- Move lists folders: paths stay left to right; Rename lists titles, which read in the language's direction. -->
<DataTrigger Binding="{Binding DataContext.Mode, RelativeSource={RelativeSource AncestorType=ListBox}}" Value="Folders">
<Setter TargetName="From" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="From" Property="HorizontalAlignment" Value="Left" />
<Setter TargetName="To" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="To" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="4" Margin="0,16,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Rename.Apply}" Command="{Binding ApplyCommand}"
ToolTip="{Binding ApplyToolTip}" MinWidth="96" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True"
IsCancel="True" MinWidth="96" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</Grid>
</Border>
@@ -132,17 +213,17 @@
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{l:Loc Archive.Retag.Add}" Style="{StaticResource Text.Label}" />
<TextBlock Text="{l:Loc Archive.Retag.Add}" Style="{StaticResource Text.DialogLabel}" />
<TextBox Grid.Column="1" Text="{Binding Add.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Add}"
ToolTip="{Binding Add.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Retag.Add}" />
<TextBlock Grid.Row="1" Text="{l:Loc Archive.Retag.Remove}" Style="{StaticResource Text.Label}" Margin="0,10,14,0" />
<TextBlock Grid.Row="1" Text="{l:Loc Archive.Retag.Remove}" Style="{StaticResource Text.DialogLabel}" Margin="0,10,14,0" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" Text="{Binding Remove.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Remove}" ToolTip="{Binding Remove.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Retag.Remove}" />
</Grid>
@@ -150,9 +231,12 @@
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Retag.Apply}" Command="{Binding ApplyCommand}"
ToolTip="{Binding ApplyToolTip}" MinWidth="96" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True"
IsCancel="True" MinWidth="96" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</StackPanel>
</Border>
@@ -180,10 +264,10 @@
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Duplicates}" Command="{Binding FindDuplicatesCommand}"
ToolTip="{Binding DuplicatesToolTip}" />
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Orphans}" Command="{Binding FindOrphansCommand}" ToolTip="{Binding OrphansToolTip}" />
<Button Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Adopt}">
<Button Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Adopt}" AutomationProperties.Name="{l:Loc Archive.Toolbar.AdoptMenu}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Archive.Toolbar.AdoptMenu}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
@@ -192,10 +276,11 @@
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button x:Name="MaintenanceButton" Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Maintenance}">
<Button x:Name="MaintenanceButton" Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Maintenance}"
AutomationProperties.Name="{l:Loc Archive.Toolbar.Maintenance}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Archive.Toolbar.Maintenance}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
@@ -215,8 +300,7 @@
<DockPanel Grid.Row="1" Margin="0,0,0,12" Visibility="{Binding HasArchive, Converter={StaticResource BoolToVisibility}}">
<v:SegmentedControl DockPanel.Dock="Left" SelectedIndex="{Binding ViewIndex}" AutomationProperties.Name="{l:Loc Archive.View.Name}">
<v:SegmentedItem Content="{l:Loc Archive.View.Overview}" ToolTip="{l:Loc Tooltips.Archive.Overview}" AutomationProperties.Name="{l:Loc Archive.View.Overview}" />
<v:SegmentedItem Content="{l:Loc Archive.View.Maintenance}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceView}"
AutomationProperties.Name="{l:Loc Archive.View.Maintenance}" />
<v:SegmentedItem Content="{l:Loc Archive.View.Health}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceView}" AutomationProperties.Name="{l:Loc Archive.View.Health}" />
</v:SegmentedControl>
<TextBlock Text="{Binding LastScanText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="14,0,0,0"
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Archive.LastScan}" />
@@ -236,6 +320,7 @@
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="MinHeight" Value="32" />
<Setter Property="Padding" Value="6,0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="ToolTip" Value="{Binding RowToolTip}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Detail}" />
@@ -281,13 +366,28 @@
</Border>
<Grid Grid.Column="2">
<!--
Chart labels in TextMuted as in Archive.html: the kit's charts draw them in TextFaint, too faint for 11 px data
labels (reported to the shared controls; remove this alias once they draw in TextMuted).
-->
<Grid.Resources>
<SolidColorBrush x:Key="Brush.TextFaint" Color="{DynamicResource Color.TextMuted}" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="14" />
<RowDefinition Height="*" />
<RowDefinition Height="14" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- One column split for both chart rows, so the gutter lines up; 14 px gaps throughout (Archive.html). -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" />
<ColumnDefinition Width="14" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Figure tiles (Archive.html). -->
<ItemsControl ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-10,0">
<ItemsControl Grid.ColumnSpan="3" ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-14,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
@@ -295,7 +395,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:ArchiveTile}">
<Border Style="{StaticResource Border.Panel}" Padding="14,8" Margin="0,0,10,0" ToolTip="{Binding Caption}">
<Border Style="{StaticResource Border.Panel}" Padding="14,8" Margin="0,0,14,0" ToolTip="{Binding Caption}">
<StackPanel>
<!-- A narrow tile (the window at its minimum width) shrinks the figure rather than cutting it. -->
<Viewbox StretchDirection="DownOnly" HorizontalAlignment="Left">
@@ -308,49 +408,59 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid Grid.Row="1" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Months}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:HeatmapStrip Rows="{Binding MonthRows}" ColumnLabels="{Binding MonthLabels}" ValueFormatter="{Binding CountFormatter}" MaxCellSize="18"
ToolTip="{l:Loc Tooltips.Archive.Months}" AutomationProperties.Name="{l:Loc Archive.Chart.Months}" />
<Border Grid.Row="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<!-- The colour scale sits in the header, at the end of the title (Archive.html). -->
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" FlowDirection="LeftToRight" VerticalAlignment="Center"
Visibility="{Binding HasMonthScale, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding MonthScaleLow}" Style="{StaticResource Text.Chip}" Typography.NumeralAlignment="Tabular" />
<Grid Width="60" Height="8" Margin="6,0">
<Border CornerRadius="2" Background="{DynamicResource Brush.Accent}" Opacity="0.08" />
<Border CornerRadius="2" Background="{DynamicResource Brush.Accent}">
<Border.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="Transparent" Offset="0" />
<GradientStop Color="Black" Offset="1" />
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
</Grid>
<TextBlock Text="{Binding MonthScaleHigh}" Style="{StaticResource Text.Chip}" Typography.NumeralAlignment="Tabular" />
</StackPanel>
<TextBlock Text="{l:Loc Archive.Chart.Months}" Style="{StaticResource Text.PanelHeading}" />
</DockPanel>
</Border>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Storage}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding StorageBars}" MinimumOpacity="0.55" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Storage}"
AutomationProperties.Name="{l:Loc Archive.Chart.Storage}" />
</DockPanel>
</Border>
</Grid>
<Grid Grid.Row="2" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Cameras}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding CameraBars}" BrushKey="Brush.Sun" MinimumOpacity="0.45" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Cameras}"
AutomationProperties.Name="{l:Loc Archive.Chart.Cameras}" />
</DockPanel>
</Border>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Formats}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding FormatBars}" MinimumOpacity="0.35" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Formats}"
AutomationProperties.Name="{l:Loc Archive.Chart.Formats}" />
</DockPanel>
</Border>
</Grid>
<v:HeatmapStrip Rows="{Binding MonthRows}" ColumnLabels="{Binding MonthLabels}" ValueFormatter="{Binding CountFormatter}" MaxCellSize="32" ShowScale="False"
ToolTip="{l:Loc Tooltips.Archive.Months}" AutomationProperties.Name="{l:Loc Archive.Chart.Months}"
AutomationProperties.HelpText="{Binding MonthsDescription}">
<!-- Months still to come in the Stroke tone: the kit fills them with Card, the panel's own colour in the light theme. -->
<v:HeatmapStrip.Resources>
<SolidColorBrush x:Key="Brush.Card" Color="{DynamicResource Color.Stroke}" />
</v:HeatmapStrip.Resources>
</v:HeatmapStrip>
</DockPanel>
</Border>
<Border Grid.Row="2" Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Storage}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding StorageBars}" MinimumOpacity="0.55" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Storage}"
AutomationProperties.Name="{l:Loc Archive.Chart.Storage}" AutomationProperties.HelpText="{Binding StorageDescription}" />
</DockPanel>
</Border>
<Border Grid.Row="4" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Cameras}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding CameraBars}" BrushKey="Brush.Sun" MinimumOpacity="0.45" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Cameras}"
AutomationProperties.Name="{l:Loc Archive.Chart.Cameras}" AutomationProperties.HelpText="{Binding CamerasDescription}" />
</DockPanel>
</Border>
<Border Grid.Row="4" Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Formats}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding FormatBars}" MinimumOpacity="0.35" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Formats}"
AutomationProperties.Name="{l:Loc Archive.Chart.Formats}" AutomationProperties.HelpText="{Binding FormatsDescription}" />
</DockPanel>
</Border>
</Grid>
</Grid>
@@ -371,12 +481,21 @@
<TextBlock Text="{l:Loc Archive.Health.Title}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<ItemsControl ItemsSource="{Binding Health}" Focusable="False">
<ItemsControl.ItemTemplate>
<!-- Archive.html: a 14 px glyph in the state's colour (● ok, ▲ needs attention), the text in the normal colour. -->
<DataTemplate DataType="{x:Type ar:HealthLineViewModel}">
<DockPanel Height="32">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{Binding FixText}" Command="{Binding FixCommand}"
ToolTip="{Binding FixToolTip}" Visibility="{Binding HasFix, Converter={StaticResource BoolToVisibility}}" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="13" VerticalAlignment="Center" ToolTip="{Binding KindToolTip}" />
<ui:Icon x:Name="Glyph" DockPanel.Dock="Left" Glyph="{StaticResource Icon.Warning}" Size="14" Margin="0,0,10,0" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.Warning}" />
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding KindToolTip}" />
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsOk}" Value="True">
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.SuccessCircle}" />
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.Success}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -402,7 +521,9 @@
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding DateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="1" Text="{Binding Text}" Margin="12,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text}" />
<TextBlock Grid.Column="2" Text="{Binding StateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<!-- The outcome in its state's colour and glyph (Archive.html: accent while running, green when done). -->
<ui:StatusGlyph Grid.Column="2" Kind="{Binding StateKind}" Text="{Binding StateText}" FontSize="12" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{Binding StateToolTip}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -421,12 +542,13 @@
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{l:Loc Archive.Duplicates.Mark}"
Command="{Binding MarkDuplicatesCommand}" ToolTip="{Binding MarkDuplicatesToolTip}" />
<!-- Cancel only in the card whose search runs; the other card's Find waits, its tooltip says why. -->
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Run}" Command="{Binding FindDuplicatesCommand}"
ToolTip="{Binding DuplicatesToolTip}" Visibility="{Binding IsSearching, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
ToolTip="{Binding DuplicatesToolTip}" Visibility="{Binding IsFindingDuplicates, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Cancel}" Command="{Binding CancelSearchCommand}"
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsSearching, Converter={StaticResource BoolToVisibility}}" />
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsFindingDuplicates, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Duplicates.Title}" Style="{StaticResource Text.PanelHeading}" />
<TextBlock Text="{Binding DuplicatesText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding DuplicatesText}" infra:LiveRegion.Text="{Binding DuplicatesText}" Margin="10,0,0,0" />
</DockPanel>
<ListBox ItemsSource="{Binding Duplicates}" ItemContainerStyle="{StaticResource ListBoxItem.Duplicate}" AutomationProperties.Name="{l:Loc Archive.Duplicates.Title}"
KeyboardNavigation.TabNavigation="Continue">
@@ -454,11 +576,11 @@
<DockPanel>
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Run}" Command="{Binding FindOrphansCommand}"
ToolTip="{Binding OrphansToolTip}" Visibility="{Binding IsSearching, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
ToolTip="{Binding OrphansToolTip}" Visibility="{Binding IsFindingOrphans, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Cancel}" Command="{Binding CancelSearchCommand}"
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsSearching, Converter={StaticResource BoolToVisibility}}" />
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsFindingOrphans, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Orphans.Title}" Style="{StaticResource Text.PanelHeading}" />
<TextBlock Text="{Binding OrphansText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding OrphansText}" infra:LiveRegion.Text="{Binding OrphansText}" Margin="10,0,0,0" />
</DockPanel>
<ListBox ItemsSource="{Binding Orphans}" ItemContainerStyle="{StaticResource ListBoxItem.Duplicate}" AutomationProperties.Name="{l:Loc Archive.Orphans.Title}"
KeyboardNavigation.TabNavigation="Continue">
@@ -468,7 +590,7 @@
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Content="{Binding FixText}" Command="{Binding FixCommand}" ToolTip="{Binding FixToolTip}" />
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Row.Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" ToolTip="{Binding Row.Title}" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
<ui:StatusGlyph Kind="Warning" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
</StackPanel>
</DockPanel>
</DataTemplate>
@@ -485,10 +607,10 @@
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="{l:Loc Archive.Set.Label}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="0,0,10,8" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" BorderBrush="{DynamicResource Brush.Accent}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Set}"
AutomationProperties.Name="{l:Loc Archive.Set.Filter}">
AutomationProperties.Name="{Binding SetFilterName}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SetText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" MaxWidth="260" TextTrimming="CharacterEllipsis" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
+36 -12
View File
@@ -3,6 +3,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Archiving;
@@ -12,6 +13,7 @@ public partial class ArchiveView : UserControl
{
private bool _restoring;
private string? _focusKey;
private IInputElement? _beforeDialog;
public ArchiveView()
{
@@ -79,26 +81,48 @@ public partial class ArchiveView : UserControl
});
}
/// <summary>On a year: Right opens it, Left closes it, Enter toggles it.</summary>
private void OnTreeKeyDown(object sender, KeyEventArgs e)
{
if (Model is not { } model || Keyboard.FocusedElement is not ListBoxItem { DataContext: ArchiveTreeRowViewModel row } || !row.HasChildren || row.IsArchive) return;
var toggle = e.Key switch
{
Key.Right => !row.IsExpanded,
Key.Left => row.IsExpanded,
Key.Enter => true,
_ => false,
};
if (!toggle) return;
if (!Toggles(e.Key, Tree.FlowDirection, row.IsExpanded)) return;
model.Toggle(row);
e.Handled = true;
}
/// <summary>A dialog that opens takes the keyboard: its first field or button.</summary>
/// <summary>
/// Whether <paramref name="key"/> opens or closes a year: the arrow towards the indented side opens it (Right, or
/// Left in a right-to-left layout, as a tree view does), the other arrow closes it, Enter toggles it.
/// </summary>
internal static bool Toggles(Key key, FlowDirection direction, bool isExpanded)
{
var (open, close) = direction == FlowDirection.RightToLeft ? (Key.Left, Key.Right) : (Key.Right, Key.Left);
return key == open ? !isExpanded
: key == close ? isExpanded
: key == Key.Enter;
}
/// <summary>
/// A dialog that opens takes the keyboard (its first field or button); when it closes, the keyboard goes back to the
/// control that opened it, or to the tree when that control can no longer take it.
/// </summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(ArchiveViewModel.Dialog) || Model?.Dialog is null || !IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
if (e.PropertyName != nameof(ArchiveViewModel.Dialog) || Model is not { } model) return;
if (model.Dialog is not null)
{
if (!IsVisible) return;
// Raised before the screen behind the dialog is disabled: the control that opened it still has the keyboard.
_beforeDialog ??= Keyboard.FocusedElement is Visual focused && IsAncestorOf(focused) ? Keyboard.FocusedElement : null;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
return;
}
var back = _beforeDialog;
_beforeDialog = null;
if (!IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () =>
{
if (back is UIElement { IsVisible: true, IsEnabled: true, Focusable: true } element && element.Focus()) return;
Tree.Focus();
});
}
}
+59 -18
View File
@@ -46,6 +46,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private Core.Model.Archive? _archive;
private ArchiveAvailability _availability = ArchiveAvailability.Offline;
private ArchiveStats? _stats;
private int _withoutProxies;
private ArchiveTree? _tree;
private int _viewIndex;
private bool _loaded;
@@ -126,7 +127,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public bool HasArchive => _archive is not null;
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", _archive.RootPath);
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", Formatting.LeftToRight(_archive.RootPath));
/// <summary>0 = overview (tree and figures), 1 = maintenance.</summary>
public int ViewIndex
@@ -167,7 +168,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public ICommand VerifyCommand { get; }
public ICommand AdoptCommand { get; }
/// <summary>"Adopt folder ▾ › Copy into the layout": the Import screen copies the folder into the archive with its templates.</summary>
/// <summary>"Adopt folder ▾ › Copy into archive": the Import screen copies the folder into the archive with its templates.</summary>
public ICommand CopyFolderCommand { get; }
public ICommand BackupCommand { get; }
@@ -188,6 +189,20 @@ public sealed class ArchiveViewModel : SectionViewModel
public IReadOnlyList<ChartItem> CameraBars { get => _cameras; private set => Set(ref _cameras, value); }
public IReadOnlyList<ChartItem> FormatBars { get => _formats; private set => Set(ref _formats, value); }
/// <summary>The heatmap's scale in the card header (Archive.html: "0 ▭ 21,000"); hidden without photos.</summary>
public bool HasMonthScale => MonthScaleMax > 0;
public string MonthScaleLow => Formatting.Count(0);
public string MonthScaleHigh => Formatting.Count((long)MonthScaleMax);
private double MonthScaleMax => _months.SelectMany(r => r.Values).Where(double.IsFinite).DefaultIfEmpty(0).Max();
/// <summary>What each chart shows, value by value, for screen readers (the charts themselves are images).</summary>
public string MonthsDescription => Describe(_months.SelectMany(r => r.Values.Select((photos, month) => photos > 0 ? r.ToolTips?[month] : null)));
public string StorageDescription => Describe(_storage.Select(b => b.ToolTip));
public string CamerasDescription => Describe(_cameras.Select(b => b.ToolTip));
public string FormatsDescription => Describe(_formats.Select(b => b.ToolTip));
/// <summary>Photos per month in the culture's digits.</summary>
public Func<double, string> CountFormatter { get; } = v => Formatting.Count((long)v);
@@ -205,6 +220,9 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>The set button's accessible name: what it is and the set it shows.</summary>
public string SetFilterName => Loc.L("Archive.Set.Filter") + " · " + SetText;
/// <summary>Camera, status and tag on top of the tree selection.</summary>
public ArchiveSetFilter Filter
{
@@ -276,7 +294,9 @@ public sealed class ArchiveViewModel : SectionViewModel
get => _duplicates;
private set
{
if (Set(ref _duplicates, value)) OnPropertyChanged(nameof(DuplicatesText));
if (!Set(ref _duplicates, value)) return;
OnPropertyChanged(nameof(DuplicatesText));
ShowHealth();
}
}
@@ -289,8 +309,11 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>A duplicates or orphans search runs; it can be cancelled.</summary>
public bool IsSearching => _search is not null;
/// <summary>The duplicates search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingDuplicates => _findingDuplicates;
/// <summary>The orphans search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingOrphans => _findingOrphans;
/// <summary>"3 groups", "None found", or empty before the first search.</summary>
public string DuplicatesText => _findingDuplicates ? Loc.L("Archive.Find.Searching")
@@ -418,19 +441,28 @@ public sealed class ArchiveViewModel : SectionViewModel
private void ShowFigures(ArchiveStats stats, int withoutProxies)
{
_withoutProxies = withoutProxies;
Tiles = ArchiveFigures.Tiles(stats);
MonthRows = [.. ArchiveFigures.PhotosPerMonth(stats, DateTime.Today).Select(r => new ChartRow(r.Label, r.Values, r.ToolTips))];
StorageBars = Bars(ArchiveFigures.StorageByYear(stats));
CameraBars = Bars(ArchiveFigures.ByCamera(stats));
FormatBars = Bars(ArchiveFigures.ByFormat(stats));
ShowHealth();
}
/// <summary>The health lines of the last figures; the duplicates line follows the last duplicates search.</summary>
private void ShowHealth()
{
if (_stats is not { } stats) return;
Health =
[
.. ArchiveFigures.Health(stats, withoutProxies).Select(line => new HealthLineViewModel(line, line.Action switch
.. ArchiveFigures.Health(stats, _withoutProxies, _duplicates?.Count).Select(line => new HealthLineViewModel(line, line.Action switch
{
HealthAction.Verify => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.Verified, ids => ArchiveJobs.Verify(_archive!, ids))),
HealthAction.Proxies => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.ProxiesBuilt, ids => ArchiveJobs.Proxies(ids, CountLabel(ids)))),
HealthAction.Analyse => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.AnalyzedLight, ids => ProcessingJobs.LightAnalysis(ids, CountLabel(ids)))),
HealthAction.Duplicates => FindDuplicatesCommand,
HealthAction.MarkDuplicates => MarkDuplicatesCommand,
HealthAction.Orphans => FindOrphansCommand,
_ => null,
})),
@@ -440,6 +472,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private static IReadOnlyList<ChartItem> Bars(IReadOnlyList<BarValue> values) =>
[.. values.Select(v => new ChartItem(v.Label, v.Value, v.ValueText, v.ToolTip))];
private static string Describe(IEnumerable<string?> values) => string.Join(Environment.NewLine, values.Where(v => !string.IsNullOrEmpty(v)));
/// <summary>A reloaded tree keeps the open years and the selection (nodes that still exist).</summary>
private void ShowTree(ArchiveTree tree)
{
@@ -488,6 +522,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSetChanged()
{
OnPropertyChanged(nameof(SetText));
OnPropertyChanged(nameof(SetFilterName));
OnPropertyChanged(nameof(CameraChoices));
OnPropertyChanged(nameof(StatusChoices));
OnPropertyChanged(nameof(TagChoices));
@@ -679,13 +714,13 @@ public sealed class ArchiveViewModel : SectionViewModel
try
{
var path = await db.BackupAsync(Services.Environment.BackupDirectory);
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"),
() => ShellActions.Reveal(path));
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Formatting.LeftToRight(Path.GetFileName(path)), Loc.L("Library.Export.Show"),
Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or NotSupportedException)
{
Log.Warning("archive", "Database backup failed", ex);
Shell.Notify(Loc.L("Archive.Backup.Failed"), ex.Message);
NotifyFailure("Archive.Backup.Failed", ex, BackupCommand);
}
}
@@ -702,13 +737,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Services.SaveSettings();
_archive = archive;
await Services.QueueScanAsync(archive, full: false);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), archive.RootPath);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), Formatting.LeftToRight(archive.RootPath));
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", $"Relinking {folder} failed", ex);
Shell.Notify(Loc.L("Archive.Relink.Failed"), ex.Message);
// Retry asks for the folder again: the same one once its drive is back, or the right one.
NotifyFailure("Archive.Relink.Failed", ex, RelinkCommand);
}
}
@@ -742,7 +778,8 @@ public sealed class ArchiveViewModel : SectionViewModel
}
catch (DatabaseException ex)
{
Shell.ReportError(ex);
Log.Warning("archive", "Duplicates search failed", ex);
NotifyFailure("Archive.Duplicates.Failed", ex, FindDuplicatesCommand);
}
finally
{
@@ -768,10 +805,10 @@ public sealed class ArchiveViewModel : SectionViewModel
catch (OperationCanceledException) when (search.IsCancellationRequested)
{
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", "Orphan search failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.Failed"), ex.Message);
NotifyFailure("Archive.Orphans.Failed", ex, FindOrphansCommand);
}
finally
{
@@ -796,7 +833,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSearchChanged()
{
OnPropertyChanged(nameof(IsSearching));
OnPropertyChanged(nameof(IsFindingDuplicates));
OnPropertyChanged(nameof(IsFindingOrphans));
OnPropertyChanged(nameof(DuplicatesText));
OnPropertyChanged(nameof(OrphansText));
OnPropertyChanged(nameof(DuplicatesToolTip));
@@ -853,11 +891,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Orphans = Orphans?.Where(o => o.Row != row).ToList();
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException
or ArgumentException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException or ArgumentException)
{
Log.Warning("archive", $"Fixing {row.Title} failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.FixFailed"), ex.Message);
NotifyFailure("Archive.Orphans.FixFailed", ex, new AsyncRelayCommand(() => FixAsync(row)));
}
}
/// <summary>An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).</summary>
private void NotifyFailure(string titleKey, Exception ex, ICommand retry) =>
Shell.Notify(Loc.L(titleKey), ArchiveFailures.Cause(ex), Loc.L("Archive.Failed.Retry"), Loc.L("Tooltips.Archive.Retry"), () => retry.Execute(null));
}
@@ -1,13 +1,17 @@
using System.Globalization;
using System.IO;
using Titano.App.Archiving;
using Titano.App.Infrastructure;
using Titano.App.Library;
using Titano.Core.Archiving;
using Titano.Core.Imaging;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data;
using Titano.Data.Archiving;
using Titano.Data.Repositories;
using Titano.Testing;
using Titano.Ui.Controls;
namespace Titano.App.Tests.Archiving;
@@ -163,11 +167,31 @@ public sealed class ArchiveLogicTests
Assert.True(double.IsNaN(rows[2].Values[10]));
Assert.Null(rows[2].ToolTips[11]);
Assert.Equal("July 2026 · 5,000 photos · 5 sequences", rows[2].ToolTips[6]);
Assert.Equal(12, ArchiveFigures.MonthLabels().Count);
Assert.Equal("J", ArchiveFigures.MonthLabels()[0]);
Assert.Empty(ArchiveFigures.PhotosPerMonth(Stats() with { ByMonth = [] }, DateTime.Today));
}
[Test]
public void MonthColumnsAreInitialsOnlyWhereTheyAreLetters()
{
var numbers = Enumerable.Range(1, 12).Select(m => m.ToString(CultureInfo.InvariantCulture)).ToArray();
try
{
Assert.Equal("J F M A M J J A S O N D", string.Join(' ', ArchiveFigures.MonthLabels()));
Loc.SetCulture(CultureInfo.GetCultureInfo("it"));
Assert.Equal("G F M A M G L A S O N D", string.Join(' ', ArchiveFigures.MonthLabels()));
// Numbered abbreviations ("10月", "Tháng 10") would read "1" for October to December, or "T" for every month.
foreach (var culture in new[] { "ja", "ko", "zh-Hans", "zh-Hant", "vi", "th", "ar", "he" })
{
Loc.SetCulture(CultureInfo.GetCultureInfo(culture));
Assert.SequenceEqual(numbers, ArchiveFigures.MonthLabels(), culture);
}
}
finally
{
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
}
}
[Test]
public void TilesAndHealthSummariseTheIndex()
{
@@ -177,7 +201,7 @@ public sealed class ArchiveLogicTests
Assert.Equal("9.4 TB", tiles[2].Value);
Assert.Equal("6", tiles[3].Value);
Assert.Equal("cameras · 8 formats", tiles[3].Caption);
Assert.Equal("2024 – 2026", tiles[4].Value);
Assert.Equal(Formatting.LeftToRight("2024 – 2026"), tiles[4].Value, "a year range keeps its order in right-to-left text");
var health = ArchiveFigures.Health(Stats(), withoutProxies: 0);
Assert.Equal(HealthAction.Verify, health[0].Action);
@@ -187,6 +211,59 @@ public sealed class ArchiveLogicTests
Assert.True(health[2].IsOk);
Assert.Equal(HealthAction.Analyse, health[3].Action);
Assert.Equal(HealthAction.Duplicates, health[4].Action);
Assert.Equal("5 duplicate frames", health[4].Text);
}
[Test]
public void HealthDuplicatesFollowTheLastDuplicatesSearch()
{
var unflagged = Stats() with { Health = Stats().Health with { DuplicateFrames = 0 } };
var before = ArchiveFigures.Health(unflagged, withoutProxies: 0)[4];
Assert.True(before.IsOk);
Assert.Equal("No copies flagged", before.Text, "before a search the line says what it measures");
var found = ArchiveFigures.Health(unflagged, withoutProxies: 0, duplicateGroups: 1)[4];
Assert.False(found.IsOk, "never a tick while the Duplicates card lists groups");
Assert.Equal("1 duplicate group", found.Text);
Assert.Equal(HealthAction.MarkDuplicates, found.Action);
var none = ArchiveFigures.Health(Stats(), withoutProxies: 0, duplicateGroups: 0)[4];
Assert.True(none.IsOk);
Assert.Equal(HealthAction.None, none.Action);
}
[Test]
public void FailuresAreOneLocalizedSentenceByCause()
{
Assert.Equal("The archive " + Formatting.LeftToRight("/archive") + " is offline.",
ArchiveFailures.Cause(new ArchiveOfflineException("/archive", ArchiveAvailability.Offline)));
Assert.Equal("The archive " + Formatting.LeftToRight("/archive") + " is read-only.",
ArchiveFailures.Cause(new ArchiveOfflineException("/archive", ArchiveAvailability.ReadOnly)));
Assert.Equal("Titano was denied access to the archive.", ArchiveFailures.Cause(new UnauthorizedAccessException("Access to '/x' is denied.")));
Assert.Equal("The index could not be read or written.", ArchiveFailures.Cause(new DatabaseConnectionException("socket closed")));
Assert.Equal("The sequence is no longer in the index.", ArchiveFailures.Cause(new ArgumentException("Unknown sequence 42.")));
Assert.Equal("A file of the archive could not be read or written.", ArchiveFailures.Cause(new IOException("The device is not ready.")));
Assert.Equal(Loc.L("Archive.Error.StalePlan"), ArchiveFailures.Cause(new StaleRenamePlanException(Guid.NewGuid())));
}
[Test]
public void TreeRowsShowTheirWholeTitleAndTheKeysOfTheReadingDirection()
{
var harbour = Seq("Construction cam · weekly", new DateTime(2026, 9, 28), 3_600, 72_000_000_000);
var tree = ArchiveTree.Build(Main, ArchiveAvailability.Online, [harbour]);
var year = new ArchiveTreeRowViewModel(tree.Root.Children[0], ArchiveAvailability.Online, _ => { });
var sequence = new ArchiveTreeRowViewModel(tree.Root.Children[0].Children[0], ArchiveAvailability.Online, _ => { });
Assert.Equal("Construction cam · weekly · 3,600 photos · 72 GB", sequence.RowToolTip);
Assert.Equal("2026 · 1 sequence · 72 GB · Right arrow opens the year, Left arrow closes it", year.RowToolTip);
try
{
Loc.SetCulture(CultureInfo.GetCultureInfo("he"));
Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", "2026 · " + year.Detail), year.RowToolTip, "the arrow keys of a mirrored tree");
}
finally
{
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
}
}
[Test]
@@ -257,6 +334,11 @@ public sealed class ArchiveLogicTests
Assert.Equal("2 photos not in sidecar", orphans[0].Detail);
Assert.Equal(a.Id, orphans[0].SequenceId);
Assert.Null(orphans[2].SequenceId);
// Folders stay left to right inside right-to-left text.
Assert.Equal("No sidecar in " + Formatting.LeftToRight("2024/Gone"), orphans[1].Detail);
Assert.Equal(Formatting.LeftToRight("2026/New shoot"), orphans[2].Title);
Assert.True(duplicates.Single().Places[1].EndsWith(Formatting.LeftToRight(b.Folder + "/originals/IMG_9.CR2"), StringComparison.Ordinal),
"a duplicate's path stays left to right");
var now = DateTimeOffset.UtcNow;
var jobs = new[]
@@ -267,7 +349,9 @@ public sealed class ArchiveLogicTests
var recent = MaintenanceReports.Recent(jobs, 5);
Assert.Equal("Verify · TitanoArchive", recent[0].Text);
Assert.Equal("71 %", recent[0].StateText);
Assert.Equal(StatusKind.Running, recent[0].StateKind);
Assert.Equal(JobState.Done, recent[1].State);
Assert.Equal(StatusKind.Done, recent[1].StateKind, "a finished run is a green dot, a failed one a red cross");
}
[Test]
@@ -1,8 +1,17 @@
using System.IO;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using Titano.App.Archiving;
using Titano.App.Infrastructure;
using Titano.App.Sections;
using Titano.App.Shell;
using Titano.App.Tests.Windows;
using Titano.Core.Archiving;
using Titano.Core.Localization;
using Titano.Testing;
using Titano.Ui.Controls;
@@ -10,7 +19,9 @@ namespace Titano.App.Tests.Archiving;
/// <summary>
/// Every Archive view of <c>--capture</c> (<see cref="ArchiveScenes"/>) on the sample archive, rendered in both themes
/// in the real main window, with what each view must show — and the buttons really enabled, not only their commands.
/// in the real main window, with what each view must show — the buttons really enabled and named for screen readers,
/// keyboard focus visible, no error or busy state left over — and paths and templates readable in a right-to-left
/// language.
/// </summary>
[WindowsOnly]
[Serial]
@@ -35,14 +46,21 @@ public sealed class ArchiveScreenSmokeTests
Assert.NotEmpty(archive.StorageBars);
Assert.NotEmpty(archive.CameraBars);
Assert.NotEmpty(archive.FormatBars);
Assert.True(archive.HasMonthScale, "the heatmap's scale sits in its header");
Assert.Contains(archive.CameraBars[0].ToolTip!, archive.CamerasDescription);
Assert.True(archive.ScanCommand.CanExecute(null), "an online archive can be scanned");
await app.ExpectAsync<ArchiveView>("archive-overview");
Assert.True(ButtonFor(app, archive.ScanCommand).IsEnabled, "the Scan button is enabled once the archive is read");
Assert.True(ButtonFor(app, archive.AnalyseSetCommand).IsEnabled, "mass operations are enabled on the whole archive");
AssertEveryButtonIsNamed(app);
Assert.Contains(archive.SetText, AutomationProperties.GetName(SetButton(app)));
foreach (var row in TreeItems(app)) Assert.NotNull(row.FocusVisualStyle, "a tree row shows keyboard focus");
var sequence = archive.TreeRows.First(r => r.Node.Kind == TreeNodeKind.Sequence);
Assert.Contains(sequence.Title, sequence.RowToolTip);
// Expanding another year keeps the selection: the set stays what the user chose.
var year = archive.TreeRows[1];
var tree = app.FindAll<ListBox>().Single(l => l.Name == "Tree");
var tree = Tree(app);
tree.SelectedItems.Add(year);
var chosen = archive.SetText;
archive.Toggle(archive.TreeRows.Last(r => r.IsYear));
@@ -55,19 +73,34 @@ public sealed class ArchiveScreenSmokeTests
Assert.Equal(5, archive.Health.Count);
Assert.Equal(1, archive.Duplicates!.Count);
Assert.Equal(3, archive.Orphans!.Count, "unlisted photos, a row without sidecar, a folder not indexed");
var duplicatesLine = archive.Health[4].Line;
Assert.False(duplicatesLine.IsOk, "index health agrees with the duplicate groups listed beside it");
Assert.Equal(HealthAction.MarkDuplicates, duplicatesLine.Action);
await app.ExpectAsync<ArchiveView>("archive-maintenance");
Assert.False(app.FindAll<Button>().Any(b => b.IsVisible && ReferenceEquals(b.Command, archive.CancelSearchCommand)), "no Cancel without a search");
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(TextFor(app, archive.DuplicatesText)), "search results are announced");
AssertEveryButtonIsNamed(app);
await ArchiveScenes.ShowAsync(app.Shell, "rebuild");
var rebuild = Assert.NotNull(archive.Dialog as RebuildDialogViewModel);
Assert.True(rebuild.RebuildCommand.CanExecute(null));
Assert.False(archive.IsContentEnabled, "the screen behind a dialog takes no input");
Assert.False(rebuild.FactRows.Any(f => f.Value == Loc.L("Archive.Rebuild.Counting")), "counted, the facts no longer say Counting…");
await app.ExpectAsync<ArchiveView>("archive-rebuild");
Assert.False(tree.IsEnabled);
var frame = Assert.NotNull(VisualTreeHelper.GetChild(tree, 0) as Border);
Assert.Equal(0, ((SolidColorBrush)frame.Background).Color.A, "the disabled tree keeps its panel's fill instead of the system's white");
AssertNoErrorShown(app);
await ArchiveScenes.ShowAsync(app.Shell, "move");
var move = Assert.NotNull(archive.Dialog as RenameDialogViewModel);
Assert.NotEmpty(move.Rows, "the dry run lists the folders that change");
Assert.Null(move.ErrorText);
await app.ExpectAsync<ArchiveView>("archive-move");
Assert.True(ButtonFor(app, move.ApplyCommand).IsEnabled, "Apply follows the dry run");
Assert.True(ButtonFor(app, move.CloseCommand).IsDefault, "Enter takes the safe way out");
AssertNoErrorShown(app);
AssertEveryButtonIsNamed(app);
move.CloseCommand.Execute(null);
archive.RetagSetCommand.Execute(null);
@@ -75,9 +108,113 @@ public sealed class ArchiveScreenSmokeTests
retag.Add.Text = "sunset";
await app.ExpectAsync<ArchiveView>("archive-retag");
Assert.True(ButtonFor(app, retag.ApplyCommand).IsEnabled, "Apply follows the typed tags");
AssertNoErrorShown(app);
retag.CloseCommand.Execute(null);
});
[Test]
public Task PathsTemplatesAndMonthsStayReadableRightToLeft() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
UiLanguage.Apply("ar");
try
{
var archive = app.Shell.Archive;
await ArchiveScenes.ShowAsync(app.Shell, "overview");
Assert.Equal(12.ToString("N0", Loc.Culture), archive.MonthLabels[^1], "Arabic month names have no initials: the columns are numbered");
var year = archive.TreeRows[1];
Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", year.Title + " · " + year.Detail), year.RowToolTip, "the tooltip names the mirrored arrow keys");
await app.ExpectAsync<ArchiveView>("archive-overview-ar");
await ArchiveScenes.ShowAsync(app.Shell, "rebuild");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, archive.SelectedArchive!.RootPath).FlowDirection, "the archive folder reads left to right");
await app.ExpectAsync<ArchiveView>("archive-rebuild-ar");
await ArchiveScenes.ShowAsync(app.Shell, "move");
var move = Assert.NotNull(archive.Dialog as RenameDialogViewModel);
var template = Assert.NotNull(app.FindAll<TextBox>().FirstOrDefault(t => t.IsVisible && EditBehavior.GetField(t) == move.Template));
Assert.Equal(FlowDirection.LeftToRight, template.FlowDirection, "the naming template reads left to right");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, move.Rows[0].From).FlowDirection, "a folder before the move reads left to right");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, move.Rows[0].To).FlowDirection, "a folder after the move reads left to right");
await app.ExpectAsync<ArchiveView>("archive-move-ar");
move.CloseCommand.Execute(null);
}
finally
{
UiLanguage.Apply("en");
}
});
[Test]
public async Task RebuildCountsSayWhyInsteadOfCountingForever()
{
var offline = new RebuildDialogViewModel(Archive("/nowhere"), ArchiveAvailability.Offline, 3, () => Task.CompletedTask, _ => { });
await offline.CountAsync();
var sidecars = Fact(offline, "Archive.Rebuild.Sidecars");
Assert.Equal("—", sidecars.Value);
Assert.Equal(Loc.L("Archive.Error.Offline", Formatting.LeftToRight("/nowhere")), sidecars.ToolTip);
Assert.True(Fact(offline, "Archive.Rebuild.Root").IsPath, "the archive folder is shown left to right");
var missing = Path.Combine(Path.GetTempPath(), "titano-missing-" + Guid.NewGuid().ToString("N"));
var unreadable = new RebuildDialogViewModel(Archive(missing), ArchiveAvailability.Online, 3, () => Task.CompletedTask, _ => { });
await unreadable.CountAsync();
Assert.Equal("—", Fact(unreadable, "Archive.Rebuild.Metadata").Value);
Assert.Equal(Loc.L("Archive.Failed.Files"), Fact(unreadable, "Archive.Rebuild.Metadata").ToolTip);
Assert.Null(unreadable.BusyText, "nothing is counting any more");
static Core.Model.Archive Archive(string root) => new() { Id = Guid.CreateVersion7(), Name = "TitanoArchive", RootPath = root };
static DialogFact Fact(RebuildDialogViewModel dialog, string label) => dialog.FactRows.Single(f => f.Label == Loc.L(label));
}
[Test]
public void TheArrowTowardsTheIndentOpensAYearInEitherDirection()
{
Assert.True(ArchiveView.Toggles(Key.Right, FlowDirection.LeftToRight, isExpanded: false));
Assert.False(ArchiveView.Toggles(Key.Right, FlowDirection.LeftToRight, isExpanded: true));
Assert.True(ArchiveView.Toggles(Key.Left, FlowDirection.LeftToRight, isExpanded: true));
Assert.True(ArchiveView.Toggles(Key.Left, FlowDirection.RightToLeft, isExpanded: false), "a mirrored tree opens with Left");
Assert.True(ArchiveView.Toggles(Key.Right, FlowDirection.RightToLeft, isExpanded: true), "and closes with Right");
Assert.False(ArchiveView.Toggles(Key.Right, FlowDirection.RightToLeft, isExpanded: false));
Assert.True(ArchiveView.Toggles(Key.Enter, FlowDirection.RightToLeft, isExpanded: true));
Assert.False(ArchiveView.Toggles(Key.Down, FlowDirection.LeftToRight, isExpanded: false));
}
/// <summary>Every button of the screen has a name screen readers can announce, menu buttons with drawn chevrons included.</summary>
private static void AssertEveryButtonIsNamed(ScreenSmokeTests.SampleApp app)
{
foreach (var button in app.FindAll<ButtonBase>().Where(b => b.IsVisible && b.Focusable && IsInArchive(b)))
{
var name = AutomationProperties.GetName(button);
if (string.IsNullOrEmpty(name)) name = button.Content as string;
Assert.False(string.IsNullOrWhiteSpace(name), $"{button.GetType().Name} '{button.Name}' bound to {button.Command} has no accessible name");
}
}
/// <summary>A dialog that has not failed shows no error line.</summary>
private static void AssertNoErrorShown(ScreenSmokeTests.SampleApp app) =>
Assert.False(app.FindAll<StatusGlyph>().Any(g => g.IsVisible && g.Kind == StatusKind.Error && IsInArchive(g)), "no error state before anything failed");
private static ListBox Tree(ScreenSmokeTests.SampleApp app) => app.FindAll<ListBox>().Single(l => l.Name == "Tree");
private static IEnumerable<ListBoxItem> TreeItems(ScreenSmokeTests.SampleApp app) =>
app.FindAll<ListBoxItem>().Where(i => i.IsVisible && i.DataContext is ArchiveTreeRowViewModel);
private static Button SetButton(ScreenSmokeTests.SampleApp app) =>
Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => b.IsVisible && b.ToolTip as string == Loc.L("Tooltips.Archive.Set")), "the set filter button");
private static bool IsInArchive(DependencyObject element)
{
for (var node = VisualTreeHelper.GetParent(element); node is not null; node = VisualTreeHelper.GetParent(node))
{
if (node is ArchiveView) return true;
}
return false;
}
private static TextBlock TextFor(ScreenSmokeTests.SampleApp app, string text) =>
Assert.NotNull(app.FindAll<TextBlock>().FirstOrDefault(t => t.IsVisible && t.Text == text && IsInArchive(t)), $"a visible text '{text}'");
private static Button ButtonFor(ScreenSmokeTests.SampleApp app, ICommand command) =>
Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => ReferenceEquals(b.Command, command) && b.IsVisible), "a visible button bound to the command");
}