merge: accessible, right-to-left safe Import screen after the visual review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-05 22:00:45 +00:00
commit 8a72daa553
19 files changed
+892 -136

No files matched your search

+11
View File
@@ -65,6 +65,7 @@
<data name="Import.Details.Files.other" xml:space="preserve"><value>{0:N0} files</value></data> <data name="Import.Details.Files.other" xml:space="preserve"><value>{0:N0} files</value></data>
<data name="Import.Details.Session" xml:space="preserve"><value>Session {0} · {1}</value><comment>long</comment></data> <data name="Import.Details.Session" xml:space="preserve"><value>Session {0} · {1}</value><comment>long</comment></data>
<data name="Import.Details.Split" xml:space="preserve"><value>Split here</value></data> <data name="Import.Details.Split" xml:space="preserve"><value>Split here</value></data>
<data name="Import.Details.SplitName" xml:space="preserve"><value>Split at {0}</value></data>
<data name="Import.Details.Title" xml:space="preserve"><value>Plan</value></data> <data name="Import.Details.Title" xml:space="preserve"><value>Plan</value></data>
<data name="Import.Details.Unreadable" xml:space="preserve"><value>Cannot read {0}: {1}</value><comment>long</comment></data> <data name="Import.Details.Unreadable" xml:space="preserve"><value>Cannot read {0}: {1}</value><comment>long</comment></data>
<data name="Import.Device.Away" xml:space="preserve"><value>{0} · not inserted</value><comment>long</comment></data> <data name="Import.Device.Away" xml:space="preserve"><value>{0} · not inserted</value><comment>long</comment></data>
@@ -103,7 +104,12 @@
<data name="Import.Erase.Verdict.SourceMissing" xml:space="preserve"><value>no longer on the card</value></data> <data name="Import.Erase.Verdict.SourceMissing" xml:space="preserve"><value>no longer on the card</value></data>
<data name="Import.Erase.Verified.one" xml:space="preserve"><value>{0:N0} verified on the card</value></data> <data name="Import.Erase.Verified.one" xml:space="preserve"><value>{0:N0} verified on the card</value></data>
<data name="Import.Erase.Verified.other" xml:space="preserve"><value>{0:N0} verified on the card</value></data> <data name="Import.Erase.Verified.other" xml:space="preserve"><value>{0:N0} verified on the card</value></data>
<data name="Import.Failed.Access" xml:space="preserve"><value>Titano may not write to the destination.</value><comment>long</comment></data>
<data name="Import.Failed.Full" xml:space="preserve"><value>The destination is full.</value><comment>long</comment></data>
<data name="Import.Failed.Other" xml:space="preserve"><value>The import stopped before the end.</value><comment>long</comment></data>
<data name="Import.Failed.Retry" xml:space="preserve"><value>Retry</value></data> <data name="Import.Failed.Retry" xml:space="preserve"><value>Retry</value></data>
<data name="Import.Failed.Server" xml:space="preserve"><value>The server did not accept the photos.</value><comment>long</comment></data>
<data name="Import.Failed.SourceGone" xml:space="preserve"><value>{0} is no longer available.</value><comment>long</comment></data>
<data name="Import.Folder.PickDestination" xml:space="preserve"><value>Import into folder</value></data> <data name="Import.Folder.PickDestination" xml:space="preserve"><value>Import into folder</value></data>
<data name="Import.Folder.PickSource" xml:space="preserve"><value>Import from folder</value></data> <data name="Import.Folder.PickSource" xml:space="preserve"><value>Import from folder</value></data>
<data name="Import.Label.After" xml:space="preserve"><value>After import</value></data> <data name="Import.Label.After" xml:space="preserve"><value>After import</value></data>
@@ -171,20 +177,25 @@
<data name="Import.Session.Column.Size" xml:space="preserve"><value>Size</value></data> <data name="Import.Session.Column.Size" xml:space="preserve"><value>Size</value></data>
<data name="Import.Session.Frames" xml:space="preserve"><value>{0} · {1}</value><comment>invariant</comment></data> <data name="Import.Session.Frames" xml:space="preserve"><value>{0} · {1}</value><comment>invariant</comment></data>
<data name="Import.Session.Merge" xml:space="preserve"><value>Merge</value></data> <data name="Import.Session.Merge" xml:space="preserve"><value>Merge</value></data>
<data name="Import.Session.MergeName" xml:space="preserve"><value>Merge session {0}</value></data>
<data name="Import.Session.New" xml:space="preserve"><value>New · {0}</value><comment>long</comment></data> <data name="Import.Session.New" xml:space="preserve"><value>New · {0}</value><comment>long</comment></data>
<data name="Import.Session.NewShort" xml:space="preserve"><value>new</value></data> <data name="Import.Session.NewShort" xml:space="preserve"><value>new</value></data>
<data name="Import.Session.Server" xml:space="preserve"><value>Server</value></data> <data name="Import.Session.Server" xml:space="preserve"><value>Server</value></data>
<data name="Import.Session.Time" xml:space="preserve"><value>{0} · {1} → {2}</value><comment>invariant</comment></data> <data name="Import.Session.Time" xml:space="preserve"><value>{0} · {1} → {2}</value><comment>invariant</comment></data>
<data name="Import.Session.TimeRtl" xml:space="preserve"><value>{0} · {1} ← {2}</value><comment>invariant</comment></data>
<data name="Import.Session.TitleName" xml:space="preserve"><value>Sequence of session {0}</value></data>
<data name="Import.Start.one" xml:space="preserve"><value>Import {0:N0} photo</value></data> <data name="Import.Start.one" xml:space="preserve"><value>Import {0:N0} photo</value></data>
<data name="Import.Start.other" xml:space="preserve"><value>Import {0:N0} photos</value></data> <data name="Import.Start.other" xml:space="preserve"><value>Import {0:N0} photos</value></data>
<data name="Import.StartPlain" xml:space="preserve"><value>Import</value></data> <data name="Import.StartPlain" xml:space="preserve"><value>Import</value></data>
<data name="Import.Status.Cancelled" xml:space="preserve"><value>Import cancelled</value></data> <data name="Import.Status.Cancelled" xml:space="preserve"><value>Import cancelled</value></data>
<data name="Import.Status.Choose" xml:space="preserve"><value>Choose a card or a folder.</value><comment>long</comment></data> <data name="Import.Status.Choose" xml:space="preserve"><value>Choose a card or a folder.</value><comment>long</comment></data>
<data name="Import.Status.NotInserted" xml:space="preserve"><value>Insert this card to plan its import.</value><comment>long</comment></data> <data name="Import.Status.NotInserted" xml:space="preserve"><value>Insert this card to plan its import.</value><comment>long</comment></data>
<data name="Import.Status.PlanError" xml:space="preserve"><value>The import could not be planned.</value><comment>long</comment></data>
<data name="Import.Status.PlanFailed" xml:space="preserve"><value>The card could not be read: {0}</value><comment>long</comment></data> <data name="Import.Status.PlanFailed" xml:space="preserve"><value>The card could not be read: {0}</value><comment>long</comment></data>
<data name="Import.Status.Reading" xml:space="preserve"><value>Reading the card…</value></data> <data name="Import.Status.Reading" xml:space="preserve"><value>Reading the card…</value></data>
<data name="Import.Status.ReadingCount.one" xml:space="preserve"><value>{0:N0} photo read</value></data> <data name="Import.Status.ReadingCount.one" xml:space="preserve"><value>{0:N0} photo read</value></data>
<data name="Import.Status.ReadingCount.other" xml:space="preserve"><value>{0:N0} photos read</value></data> <data name="Import.Status.ReadingCount.other" xml:space="preserve"><value>{0:N0} photos read</value></data>
<data name="Import.Status.Unreadable" xml:space="preserve"><value>{0} could not be read.</value><comment>long</comment></data>
<data name="Import.Toast.AutoMessage" xml:space="preserve"><value>Importing with its saved settings</value><comment>long</comment></data> <data name="Import.Toast.AutoMessage" xml:space="preserve"><value>Importing with its saved settings</value><comment>long</comment></data>
<data name="Import.Toast.Cancel" xml:space="preserve"><value>Cancel</value></data> <data name="Import.Toast.Cancel" xml:space="preserve"><value>Cancel</value></data>
<data name="Import.Toast.CardChanged" xml:space="preserve"><value>{0} changed since it was checked</value><comment>long</comment></data> <data name="Import.Toast.CardChanged" xml:space="preserve"><value>{0} changed since it was checked</value><comment>long</comment></data>
+10
View File
@@ -65,6 +65,7 @@
<data name="Import.Details.Files.other" xml:space="preserve"><value>{0:N0} file</value></data> <data name="Import.Details.Files.other" xml:space="preserve"><value>{0:N0} file</value></data>
<data name="Import.Details.Session" xml:space="preserve"><value>Sessione {0} · {1}</value></data> <data name="Import.Details.Session" xml:space="preserve"><value>Sessione {0} · {1}</value></data>
<data name="Import.Details.Split" xml:space="preserve"><value>Dividi qui</value></data> <data name="Import.Details.Split" xml:space="preserve"><value>Dividi qui</value></data>
<data name="Import.Details.SplitName" xml:space="preserve"><value>Dividi a partire da {0}</value></data>
<data name="Import.Details.Title" xml:space="preserve"><value>Piano</value></data> <data name="Import.Details.Title" xml:space="preserve"><value>Piano</value></data>
<data name="Import.Details.Unreadable" xml:space="preserve"><value>Impossibile leggere {0}: {1}</value></data> <data name="Import.Details.Unreadable" xml:space="preserve"><value>Impossibile leggere {0}: {1}</value></data>
<data name="Import.Device.Away" xml:space="preserve"><value>{0} · non inserita</value></data> <data name="Import.Device.Away" xml:space="preserve"><value>{0} · non inserita</value></data>
@@ -101,7 +102,12 @@
<data name="Import.Erase.Verdict.SourceMissing" xml:space="preserve"><value>non più sulla scheda</value></data> <data name="Import.Erase.Verdict.SourceMissing" xml:space="preserve"><value>non più sulla scheda</value></data>
<data name="Import.Erase.Verified.one" xml:space="preserve"><value>{0:N0} verificata sulla scheda</value></data> <data name="Import.Erase.Verified.one" xml:space="preserve"><value>{0:N0} verificata sulla scheda</value></data>
<data name="Import.Erase.Verified.other" xml:space="preserve"><value>{0:N0} verificate sulla scheda</value></data> <data name="Import.Erase.Verified.other" xml:space="preserve"><value>{0:N0} verificate sulla scheda</value></data>
<data name="Import.Failed.Access" xml:space="preserve"><value>Titano non può scrivere nella destinazione.</value></data>
<data name="Import.Failed.Full" xml:space="preserve"><value>La destinazione è piena.</value></data>
<data name="Import.Failed.Other" xml:space="preserve"><value>L'importazione si è interrotta prima della fine.</value></data>
<data name="Import.Failed.Retry" xml:space="preserve"><value>Riprova</value></data> <data name="Import.Failed.Retry" xml:space="preserve"><value>Riprova</value></data>
<data name="Import.Failed.Server" xml:space="preserve"><value>Il server non ha accettato le foto.</value></data>
<data name="Import.Failed.SourceGone" xml:space="preserve"><value>{0} non è più disponibile.</value></data>
<data name="Import.Folder.PickDestination" xml:space="preserve"><value>Importa nella cartella</value></data> <data name="Import.Folder.PickDestination" xml:space="preserve"><value>Importa nella cartella</value></data>
<data name="Import.Folder.PickSource" xml:space="preserve"><value>Importa dalla cartella</value></data> <data name="Import.Folder.PickSource" xml:space="preserve"><value>Importa dalla cartella</value></data>
<data name="Import.Label.After" xml:space="preserve"><value>Dopo l'importazione</value></data> <data name="Import.Label.After" xml:space="preserve"><value>Dopo l'importazione</value></data>
@@ -166,19 +172,23 @@
<data name="Import.Session.Column.Session" xml:space="preserve"><value>Sessione</value></data> <data name="Import.Session.Column.Session" xml:space="preserve"><value>Sessione</value></data>
<data name="Import.Session.Column.Size" xml:space="preserve"><value>Dimensione</value></data> <data name="Import.Session.Column.Size" xml:space="preserve"><value>Dimensione</value></data>
<data name="Import.Session.Merge" xml:space="preserve"><value>Unisci</value></data> <data name="Import.Session.Merge" xml:space="preserve"><value>Unisci</value></data>
<data name="Import.Session.MergeName" xml:space="preserve"><value>Unisci la sessione {0}</value></data>
<data name="Import.Session.New" xml:space="preserve"><value>Nuova · {0}</value></data> <data name="Import.Session.New" xml:space="preserve"><value>Nuova · {0}</value></data>
<data name="Import.Session.NewShort" xml:space="preserve"><value>nuova</value></data> <data name="Import.Session.NewShort" xml:space="preserve"><value>nuova</value></data>
<data name="Import.Session.Server" xml:space="preserve"><value>Server</value></data> <data name="Import.Session.Server" xml:space="preserve"><value>Server</value></data>
<data name="Import.Session.TitleName" xml:space="preserve"><value>Sequenza della sessione {0}</value></data>
<data name="Import.Start.one" xml:space="preserve"><value>Importa {0:N0} foto</value></data> <data name="Import.Start.one" xml:space="preserve"><value>Importa {0:N0} foto</value></data>
<data name="Import.Start.other" xml:space="preserve"><value>Importa {0:N0} foto</value></data> <data name="Import.Start.other" xml:space="preserve"><value>Importa {0:N0} foto</value></data>
<data name="Import.StartPlain" xml:space="preserve"><value>Importa</value></data> <data name="Import.StartPlain" xml:space="preserve"><value>Importa</value></data>
<data name="Import.Status.Cancelled" xml:space="preserve"><value>Importazione annullata</value></data> <data name="Import.Status.Cancelled" xml:space="preserve"><value>Importazione annullata</value></data>
<data name="Import.Status.Choose" xml:space="preserve"><value>Scegli una scheda o una cartella.</value></data> <data name="Import.Status.Choose" xml:space="preserve"><value>Scegli una scheda o una cartella.</value></data>
<data name="Import.Status.NotInserted" xml:space="preserve"><value>Inserisci questa scheda per pianificarne l'importazione.</value></data> <data name="Import.Status.NotInserted" xml:space="preserve"><value>Inserisci questa scheda per pianificarne l'importazione.</value></data>
<data name="Import.Status.PlanError" xml:space="preserve"><value>Impossibile preparare il piano di importazione.</value></data>
<data name="Import.Status.PlanFailed" xml:space="preserve"><value>Impossibile leggere la scheda: {0}</value></data> <data name="Import.Status.PlanFailed" xml:space="preserve"><value>Impossibile leggere la scheda: {0}</value></data>
<data name="Import.Status.Reading" xml:space="preserve"><value>Lettura della scheda…</value></data> <data name="Import.Status.Reading" xml:space="preserve"><value>Lettura della scheda…</value></data>
<data name="Import.Status.ReadingCount.one" xml:space="preserve"><value>{0:N0} foto letta</value></data> <data name="Import.Status.ReadingCount.one" xml:space="preserve"><value>{0:N0} foto letta</value></data>
<data name="Import.Status.ReadingCount.other" xml:space="preserve"><value>{0:N0} foto lette</value></data> <data name="Import.Status.ReadingCount.other" xml:space="preserve"><value>{0:N0} foto lette</value></data>
<data name="Import.Status.Unreadable" xml:space="preserve"><value>Impossibile leggere {0}.</value></data>
<data name="Import.Toast.AutoMessage" xml:space="preserve"><value>Importazione con le impostazioni salvate</value></data> <data name="Import.Toast.AutoMessage" xml:space="preserve"><value>Importazione con le impostazioni salvate</value></data>
<data name="Import.Toast.Cancel" xml:space="preserve"><value>Annulla</value></data> <data name="Import.Toast.Cancel" xml:space="preserve"><value>Annulla</value></data>
<data name="Import.Toast.CardChanged" xml:space="preserve"><value>{0} è cambiata dopo il controllo</value></data> <data name="Import.Toast.CardChanged" xml:space="preserve"><value>{0} è cambiata dopo il controllo</value></data>
+17
View File
@@ -0,0 +1,17 @@
using Titano.Core.Localization;
namespace Titano.App.Import;
/// <summary>
/// Paths, volume serials and other left-to-right fragments inside a sentence of a right-to-left language (BRIEF §16):
/// without an embedding, a path that starts with a digit or ends in a separator is reordered and reads garbled.
/// </summary>
public static class BidiText
{
private const char LeftToRightEmbedding = '‪';
private const char PopDirectionalFormatting = '‬';
/// <summary><paramref name="text"/> kept left to right in a right-to-left UI language; unchanged otherwise.</summary>
public static string Ltr(string text) =>
Loc.IsRightToLeft && text.Length > 0 ? LeftToRightEmbedding + text + PopDirectionalFormatting : text;
}
+1 -1
View File
@@ -70,7 +70,7 @@ public sealed record CardActions(ImportDestinationKind Destination, bool IsKnown
/// <summary>Why each kept photo stays on the card ("IMG_0042.CR2 · the archive copy no longer matches").</summary> /// <summary>Why each kept photo stays on the card ("IMG_0042.CR2 · the archive copy no longer matches").</summary>
public IReadOnlyList<string> KeptReasons => public IReadOnlyList<string> KeptReasons =>
Erase is null ? [] : [.. Erase.Items.Where(i => i.Verdict != EraseVerdict.Delete).Select(i => Loc.L("Import.Erase.Reason", i.Candidate.SourcePath, Verdict(i.Verdict)))]; Erase is null ? [] : [.. Erase.Items.Where(i => i.Verdict != EraseVerdict.Delete).Select(i => Loc.L("Import.Erase.Reason", BidiText.Ltr(i.Candidate.SourcePath), Verdict(i.Verdict)))];
public static string Verdict(EraseVerdict verdict) => Loc.L("Import.Erase.Verdict." + verdict); public static string Verdict(EraseVerdict verdict) => Loc.L("Import.Erase.Verdict." + verdict);
} }
+15 -4
View File
@@ -55,7 +55,11 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic
{ {
public bool IsInserted => Device is not null || FolderPath is not null; public bool IsInserted => Device is not null || FolderPath is not null;
public bool IsKnown => Card is not null; /// <summary>
/// The card has a nickname (BRIEF §12.4: known cards show their nickname, unknown ones ask for it). A card is
/// remembered as soon as its first plan reads it, but stays new until it is named.
/// </summary>
public bool IsKnown => Card is { Nickname.Length: > 0 };
/// <summary>Where the photos are read from; null for a remembered card that is not inserted.</summary> /// <summary>Where the photos are read from; null for a remembered card that is not inserted.</summary>
public string? Root => Device?.Root ?? FolderPath; public string? Root => Device?.Root ?? FolderPath;
@@ -63,12 +67,13 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic
/// <summary>"EOS R5 · card A", the volume label, or the drive.</summary> /// <summary>"EOS R5 · card A", the volume label, or the drive.</summary>
public string Title => Card?.Nickname is { Length: > 0 } nickname ? nickname public string Title => Card?.Nickname is { Length: > 0 } nickname ? nickname
: Device is { Label.Length: > 0 } labelled ? labelled.Label : Device is { Label.Length: > 0 } labelled ? labelled.Label
: Device?.Root ?? FolderPath ?? Card?.Label ?? string.Empty; : (Device?.Root ?? FolderPath) is { } path ? BidiText.Ltr(path)
: Card?.Label ?? string.Empty;
/// <summary>"128 GB · 96.2 GB used · 4,812 photos", "no DCIM · 1.8 TB free", "Canon EOS R5 · not inserted".</summary> /// <summary>"128 GB · 96.2 GB used · 4,812 photos", "no DCIM · 1.8 TB free", "Canon EOS R5 · not inserted".</summary>
public string Subtitle => Kind switch public string Subtitle => Kind switch
{ {
SourceKind.Folder => FolderPath ?? string.Empty, SourceKind.Folder => BidiText.Ltr(FolderPath ?? string.Empty),
SourceKind.Drive => Loc.L("Import.Device.NoDcim", Formatting.Bytes(Device!.FreeBytes)), SourceKind.Drive => Loc.L("Import.Device.NoDcim", Formatting.Bytes(Device!.FreeBytes)),
_ when Device is not null && Contents is { } contents => Loc.L("Import.Device.CardPhotos", Formatting.Bytes(Device.TotalBytes), _ when Device is not null && Contents is { } contents => Loc.L("Import.Device.CardPhotos", Formatting.Bytes(Device.TotalBytes),
Formatting.Bytes(Device.UsedBytes), Loc.Plural("Shell.Status.Photos", contents.Photos)), Formatting.Bytes(Device.UsedBytes), Loc.Plural("Shell.Status.Photos", contents.Photos)),
@@ -86,6 +91,12 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic
_ => "Import.Device.State.New", _ => "Import.Device.State.New",
}); });
/// <summary>
/// "Known card · 128 GB · 96.2 GB used · 4,812 photos": the entry's tooltip, with what its subtitle may have to cut
/// (a drive's subtitle already says it has no DCIM).
/// </summary>
public string ToolTip => Kind == SourceKind.Drive ? Subtitle : string.Join(" · ", new[] { StateText, Subtitle }.Where(t => t.Length > 0));
/// <summary>"Canon EOS R5 · 4,812 photos": the insertion toast's line; "not yet known to Titano" for a new card.</summary> /// <summary>"Canon EOS R5 · 4,812 photos": the insertion toast's line; "not yet known to Titano" for a new card.</summary>
public string ToastText public string ToastText
{ {
@@ -108,7 +119,7 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic
var capacity = Device?.TotalBytes ?? Card?.Capacity ?? 0; var capacity = Device?.TotalBytes ?? Card?.Capacity ?? 0;
if (capacity > 0) parts.Add(Formatting.Bytes(capacity)); if (capacity > 0) parts.Add(Formatting.Bytes(capacity));
var serial = Device?.SerialNumber ?? Card?.VolumeSerial; var serial = Device?.SerialNumber ?? Card?.VolumeSerial;
if (serial is { } s && Kind != SourceKind.Folder) parts.Add(Loc.L("Import.Device.Serial", SerialText(s))); if (serial is { } s && Kind != SourceKind.Folder) parts.Add(Loc.L("Import.Device.Serial", BidiText.Ltr(SerialText(s))));
if (CameraText(Card) is { Length: > 0 } camera) parts.Add(Card?.CameraSerial is { Length: > 0 } body ? Loc.L("Import.Device.Body", camera, body) : camera); if (CameraText(Card) is { Length: > 0 } camera) parts.Add(Card?.CameraSerial is { Length: > 0 } body ? Loc.L("Import.Device.Body", camera, body) : camera);
return string.Join(" · ", parts); return string.Join(" · ", parts);
} }
+1 -1
View File
@@ -86,7 +86,7 @@ public sealed record ImportChoices
/// <summary>True when a choice changes which photos form which session or where they go, so the card must be planned again.</summary> /// <summary>True when a choice changes which photos form which session or where they go, so the card must be planned again.</summary>
public bool NeedsNewPlan(ImportChoices previous) => public bool NeedsNewPlan(ImportChoices previous) =>
previous.Destination != Destination previous.Destination != Destination
|| !string.Equals(previous.FolderPath, FolderPath, StringComparison.OrdinalIgnoreCase) || (Destination == ImportDestinationKind.Folder && !string.Equals(previous.FolderPath, FolderPath, StringComparison.OrdinalIgnoreCase))
|| previous.IncludeSubfolders != IncludeSubfolders || previous.IncludeSubfolders != IncludeSubfolders
|| previous.SplitSessions != SplitSessions || previous.SplitSessions != SplitSessions
|| (SplitSessions && previous.GapMinutes != GapMinutes) || (SplitSessions && previous.GapMinutes != GapMinutes)
+36
View File
@@ -0,0 +1,36 @@
using System.IO;
using System.Net.Http;
using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Protocol.Client;
namespace Titano.App.Import;
/// <summary>
/// What the Import screen says when an import or its plan stops (BRIEF §0.2 rule 6: one sentence saying what
/// happened): a localized sentence chosen by cause. The exception's own text, which may hold full paths or several
/// sentences, goes to the tooltip and the log only.
/// </summary>
public static class ImportFailures
{
private const int DiskFull = unchecked((int)0x80070070);
private const int HandleDiskFull = unchecked((int)0x80070027);
/// <param name="source">The card or folder as the Devices list names it.</param>
public static string Import(Exception ex, string source) => ex switch
{
ImportSourceUnavailableException => Loc.L("Import.Failed.SourceGone", source),
IOException { HResult: DiskFull or HandleDiskFull } => Loc.L("Import.Failed.Full"),
UnauthorizedAccessException => Loc.L("Import.Failed.Access"),
TitanoApiException or HttpRequestException or UntrustedCertificateException => Loc.L("Import.Failed.Server"),
_ => Loc.L("Import.Failed.Other"),
};
/// <summary>Why the card or folder could not be planned.</summary>
public static string Plan(Exception ex, string source) => ex switch
{
DirectoryNotFoundException or DriveNotFoundException or ImportSourceUnavailableException => Loc.L("Import.Failed.SourceGone", source),
IOException or UnauthorizedAccessException => Loc.L("Import.Status.Unreadable", source),
_ => Loc.L("Import.Status.PlanError"),
};
}
+26 -8
View File
@@ -13,11 +13,13 @@ public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long Co
public bool HasEnoughSpace => FreeAfter is not < 0; public bool HasEnoughSpace => FreeAfter is not < 0;
/// <summary>"3 sessions · 4,812 photos · 96.2 GB · about 12 min".</summary> /// <summary>"3 sessions · 4,812 photos · 96.2 GB · about 12 min".</summary>
public string Text => string.Join(" · ", public string Text => SummaryText + " · " + Loc.L("Import.Plan.About", Formatting.Duration(Estimate));
/// <summary>"3 sessions · 4,812 photos · 96.2 GB": the plan without its time estimate.</summary>
public string SummaryText => string.Join(" · ",
Loc.Plural("Import.Plan.Sessions", Sessions), Loc.Plural("Import.Plan.Sessions", Sessions),
Loc.Plural("Shell.Status.Photos", Photos), Loc.Plural("Shell.Status.Photos", Photos),
Formatting.Bytes(CopyBytes), Formatting.Bytes(CopyBytes));
Loc.L("Import.Plan.About", Formatting.Duration(Estimate)));
/// <summary>"0 duplicates" (already in the archive by hash).</summary> /// <summary>"0 duplicates" (already in the archive by hash).</summary>
public string DuplicatesText => Loc.Plural("Import.Plan.Duplicates", Duplicates); public string DuplicatesText => Loc.Plural("Import.Plan.Duplicates", Duplicates);
@@ -51,9 +53,21 @@ public enum PlanRowKind
File, File,
} }
/// <summary>A line of "Show plan": a session heading or one file and its destination.</summary> /// <summary>A line of "Show plan": a session heading and its folder, or one file (card path) and its destination path.</summary>
/// <param name="CanSplit">A file that is not the first of its session: a new session can start there.</param> /// <param name="CanSplit">A file that is not the first of its session: a new session can start there.</param>
public sealed record PlanDetailRow(PlanRowKind Kind, string Source, string Destination, string ActionText, string SizeText, bool IsSkipped, bool CanSplit); public sealed record PlanDetailRow(PlanRowKind Kind, string Source, string Destination, string ActionText, string SizeText, bool IsSkipped, bool CanSplit)
{
/// <summary>A file's name on the card (its session heading shows the rest); the heading itself for a session.</summary>
public string SourceText => Kind == PlanRowKind.File ? NameOf(Source) : Source;
/// <summary>The file's new name (its session shows the folder); the folder for a session.</summary>
public string DestinationText => Kind == PlanRowKind.File ? NameOf(Destination) : Destination;
/// <summary>"Split at IMG_0042.JPG": the row's split button as screen readers announce it.</summary>
public string SplitName => Loc.L("Import.Details.SplitName", SourceText);
private static string NameOf(string path) => path[(path.LastIndexOf('/') + 1)..];
}
/// <summary>Everything "Show plan" lists: every file to its destination, the totals and the conflicts.</summary> /// <summary>Everything "Show plan" lists: every file to its destination, the totals and the conflicts.</summary>
public sealed record PlanDetails(IReadOnlyList<PlanDetailRow> Rows, string TotalsText, IReadOnlyList<string> Conflicts); public sealed record PlanDetails(IReadOnlyList<PlanDetailRow> Rows, string TotalsText, IReadOnlyList<string> Conflicts);
@@ -154,7 +168,7 @@ public static class ImportPlans
} }
var totals = Totals(plan, verify); var totals = Totals(plan, verify);
var conflicts = new List<string>(); var conflicts = new List<string>();
foreach (var problem in plan.Problems) conflicts.Add(Loc.L("Import.Details.Unreadable", problem.RelativePath, problem.Message)); foreach (var problem in plan.Problems) conflicts.Add(Loc.L("Import.Details.Unreadable", BidiText.Ltr(problem.RelativePath), problem.Message));
if (totals.Duplicates > 0) conflicts.Add(totals.DuplicatesText); if (totals.Duplicates > 0) conflicts.Add(totals.DuplicatesText);
if (!totals.HasEnoughSpace) conflicts.Add(totals.SpaceText); if (!totals.HasEnoughSpace) conflicts.Add(totals.SpaceText);
var text = string.Join(" · ", new[] var text = string.Join(" · ", new[]
@@ -209,9 +223,13 @@ public static class ImportPlans
_ => Loc.L("Import.Action.Copy"), _ => Loc.L("Import.Action.Copy"),
}; };
/// <summary>"28/09/2026 · 18:02 → 20:04".</summary> /// <summary>
/// "28/09/2026 · 18:02 → 20:04". Bidi never mirrors an arrow, so a right-to-left language reads it from its own
/// resource with the arrow pointing from the start to the end in its reading order.
/// </summary>
private static string TimeText(PlannedSession s) => private static string TimeText(PlannedSession s) =>
Loc.L("Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture), s.End.ToString("t", Loc.Culture)); Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
s.End.ToString("t", Loc.Culture));
/// <summary>"3,600 · 2 s": photos and the median interval between them.</summary> /// <summary>"3,600 · 2 s": photos and the median interval between them.</summary>
private static string FramesText(PlannedSession s) private static string FramesText(PlannedSession s)
@@ -46,7 +46,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
_device = device; _device = device;
Outcome = outcome; Outcome = outcome;
_actions = new CardActions(choices.Destination, card is not null, device is not null, device?.IsRemovable == true, outcome, null, null); _actions = new CardActions(choices.Destination, card is not null, device is not null, device?.IsRemovable == true, outcome, null, null);
Failures = [.. outcome.Failures.Take(ListedFailures).Select(f => Loc.L("Import.Result.Failure", f.SourcePath, f.Message))]; Failures = [.. outcome.Failures.Take(ListedFailures).Select(f => Loc.L("Import.Result.Failure", BidiText.Ltr(f.SourcePath), f.Message))];
CheckCommand = new AsyncRelayCommand(CheckAsync, () => _actions.CanCheck && !_isBusy); CheckCommand = new AsyncRelayCommand(CheckAsync, () => _actions.CanCheck && !_isBusy);
DeleteCommand = new AsyncRelayCommand(DeleteAsync, () => _actions.CanDelete && !_isBusy); DeleteCommand = new AsyncRelayCommand(DeleteAsync, () => _actions.CanDelete && !_isBusy);
FormatCommand = new AsyncRelayCommand(FormatAsync, () => _actions.CanFormat && !_isBusy); FormatCommand = new AsyncRelayCommand(FormatAsync, () => _actions.CanFormat && !_isBusy);
+4 -3
View File
@@ -1,7 +1,6 @@
using Titano.App.Sections; using Titano.App.Sections;
using Titano.App.Shell; using Titano.App.Shell;
using Titano.Core.Import; using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Data; using Titano.Data;
namespace Titano.App.Import; namespace Titano.App.Import;
@@ -28,6 +27,8 @@ public static class ImportScenes
switch (state) switch (state)
{ {
case "inserted": case "inserted":
// Each theme pass starts as the first: the new card of "newcard" is not remembered yet.
await ForgetAsync(shell, SampleCards.NewCard(data).Identity);
await ShowPlanAsync(import, SampleCards.Card(data)); await ShowPlanAsync(import, SampleCards.Card(data));
await import.CardInsertedAsync(SampleCards.Card(data)); await import.CardInsertedAsync(SampleCards.Card(data));
break; break;
@@ -43,7 +44,7 @@ public static class ImportScenes
import.ShowRunning(new ImportProgress(31, plan.FileCount, plan.CopyBytes * 31 / plan.FileCount, plan.CopyBytes, 31, 0, 0, null)); import.ShowRunning(new ImportProgress(31, plan.FileCount, plan.CopyBytes * 31 / plan.FileCount, plan.CopyBytes, 31, 0, 0, null));
break; break;
case "failed": case "failed":
import.ShowFailed(Loc.L("Archive.Error.SourceGone", SampleCards.Card(data).Root)); import.ShowFailed(new ImportSourceUnavailableException(SampleCards.Card(data).Root));
break; break;
case "done": case "done":
await ShowPlanAsync(import, SampleCards.Card(data)); await ShowPlanAsync(import, SampleCards.Card(data));
@@ -83,7 +84,7 @@ public static class ImportScenes
private static ImportPlan Plan(ImportViewModel import) => import.Plan ?? throw new InvalidOperationException("The sample card has no plan."); private static ImportPlan Plan(ImportViewModel import) => import.Plan ?? throw new InvalidOperationException("The sample card has no plan.");
/// <summary>The new card stays new in every theme: an earlier state registered it on its first plan.</summary> /// <summary>The new card stays new in every theme: its first plan in an earlier pass registered it.</summary>
private static async Task ForgetAsync(ShellViewModel shell, string identity) private static async Task ForgetAsync(ShellViewModel shell, string identity)
{ {
if (shell.Services.Database is not { } db || await db.MediaCards.FindByIdentityAsync(identity) is not { } known) return; if (shell.Services.Database is not { } db || await db.MediaCards.FindByIdentityAsync(identity) is not { } known) return;
@@ -51,4 +51,10 @@ public sealed class ImportSessionRowViewModel : ObservableObject
public string MergeToolTip => !IsEditable ? Loc.L("Import.Blocked.Copying") public string MergeToolTip => !IsEditable ? Loc.L("Import.Blocked.Copying")
: Row.MergesInto is { } target ? Loc.L("Tooltips.Import.Merge", target) : Row.MergesInto is { } target ? Loc.L("Tooltips.Import.Merge", target)
: string.Empty; : string.Empty;
/// <summary>"Sequence of session 2": the title field as screen readers announce it, one per row.</summary>
public string TitleName => Loc.L("Import.Session.TitleName", Row.Number);
/// <summary>"Merge session 2".</summary>
public string MergeName => Loc.L("Import.Session.MergeName", Row.Number);
} }
+223 -87
View File
@@ -9,14 +9,28 @@
<KeyBinding Key="Enter" Modifiers="Control" Command="{Binding StartCommand}" /> <KeyBinding Key="Enter" Modifiers="Control" Command="{Binding StartCommand}" />
</UserControl.InputBindings> </UserControl.InputBindings>
<UserControl.Resources> <UserControl.Resources>
<!-- Devices list entry (Import.html): 54 px, Surface fill, Stroke border; selected = accent border. --> <!-- Keyboard focus drawn inside the element: an outer ring would be clipped by the scroll viewer around lists. -->
<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>
<!-- Devices list entry (Import.html): 54 px, Surface fill, Stroke border; selected = accent border; disabled while copying. -->
<Style x:Key="ListBoxItem.Device" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}"> <Style x:Key="ListBoxItem.Device" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Height" Value="54" /> <Setter Property="Height" Value="54" />
<Setter Property="Margin" Value="0,0,0,8" /> <Setter Property="Margin" Value="0,0,0,8" />
<Setter Property="Padding" Value="12,0" /> <Setter Property="Padding" Value="12,0" />
<Setter Property="Background" Value="{DynamicResource Brush.Surface}" /> <Setter Property="Background" Value="{DynamicResource Brush.Surface}" />
<Setter Property="ToolTip" Value="{Binding StateText}" /> <Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" /> <Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding ToolTip}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="ListBoxItem"> <ControlTemplate TargetType="ListBoxItem">
@@ -32,10 +46,18 @@
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" /> <Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" /> <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="ToolTip" Value="{l:Loc Import.Blocked.Copying}" />
</Trigger>
</Style.Triggers>
</Style> </Style>
<!-- One form line: a label column at least 116 px wide, as wide as the longest label of the form, then the controls (Import.html grid). --> <!-- One form line: a label column at least 116 px wide, as wide as the longest label of the form, then the controls (Import.html grid). -->
@@ -68,15 +90,82 @@
<Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}"> <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
<Setter Property="Margin" Value="0,4,18,4" /> <Setter Property="Margin" Value="0,4,18,4" />
</Style> </Style>
<!-- Unit words beside a field ("gap … min"): dimmed with the field they belong to. -->
<Style x:Key="Text.Unit" TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" />
</Trigger>
</Style.Triggers>
</Style>
<!--
Up to four digits (gap ≤ 1440). The kit's text box applies its padding twice (reported to the shared controls),
so the side padding is halved here: four digits fit before and after that fix.
-->
<Style x:Key="TextBox.Small" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}"> <Style x:Key="TextBox.Small" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}">
<Setter Property="Width" Value="56" /> <Setter Property="Width" Value="56" />
<Setter Property="Height" Value="30" /> <Setter Property="Height" Value="30" />
<Setter Property="Padding" Value="4,0" />
<Setter Property="Margin" Value="6,0" /> <Setter Property="Margin" Value="6,0" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style> </Style>
<!-- Session table columns, shared by header and rows. --> <!-- File paths and name templates stay left to right in every language (BRIEF §16). -->
<Style x:Key="TextBox.NameTemplate" TargetType="TextBox" BasedOn="{StaticResource TextBox.Mono}">
<Setter Property="Height" Value="30" />
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<!-- The folder path is in use only with the Folder destination (Import.html: faint text otherwise). -->
<Style x:Key="TextBox.FolderPath" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Width" Value="190" />
<Setter Property="Height" Value="30" />
<Setter Property="FlowDirection" Value="LeftToRight" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsFolderDestination}" Value="False">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
</DataTrigger>
</Style.Triggers>
</Style>
<!-- A path or file name in a cell: left to right, at the start of the cell in either direction. -->
<Style x:Key="Text.CellPath" TargetType="TextBlock" BasedOn="{StaticResource Text.Cell}">
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<!-- Numbers stay right-aligned in tables in both directions. -->
<Style x:Key="Text.CellNumberLtr" TargetType="TextBlock" BasedOn="{StaticResource Text.CellNumber}">
<Setter Property="FlowDirection" Value="LeftToRight" />
</Style>
<Style x:Key="Text.HeaderNumber" TargetType="TextBlock" BasedOn="{StaticResource Text.Header}">
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="TextAlignment" Value="Right" />
</Style>
<!-- Row actions (DESIGN §4 tables): revealed on the row it acts on, still in the tab order. -->
<Style x:Key="Button.RowAction" TargetType="Button" BasedOn="{StaticResource Button.Row}">
<Setter Property="Opacity" Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
<DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
<Setter Property="Opacity" Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>
<!-- Session table rows (36 px). -->
<Style x:Key="Session.Grid" TargetType="Grid"> <Style x:Key="Session.Grid" TargetType="Grid">
<Setter Property="Height" Value="34" /> <Setter Property="Height" Value="36" />
</Style> </Style>
<Style x:Key="ListBoxItem.Session" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}"> <Style x:Key="ListBoxItem.Session" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.TimeText}" /> <Setter Property="AutomationProperties.Name" Value="{Binding Row.TimeText}" />
@@ -84,15 +173,19 @@
<!-- Show plan and failure rows: focusable, so the arrow keys move through a long list. --> <!-- Show plan and failure rows: focusable, so the arrow keys move through a long list. -->
<Style x:Key="ListBoxItem.PlanRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}"> <Style x:Key="ListBoxItem.PlanRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" /> <Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Source}" /> <Setter Property="AutomationProperties.Name" Value="{Binding Source}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Destination}" />
</Style> </Style>
<Style x:Key="ListBoxItem.Failure" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}"> <Style x:Key="ListBoxItem.Failure" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" /> <Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding}" /> <Setter Property="AutomationProperties.Name" Value="{Binding}" />
</Style> </Style>
<!-- "Folder…" (Import.html): transparent, 1 px dashed Stroke border. --> <!-- "Folder…" (Import.html): transparent, 1 px dashed Stroke border. -->
<Style x:Key="Button.Dashed" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> <Style x:Key="Button.Dashed" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
@@ -104,9 +197,6 @@
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Edge" Property="Fill" Value="{DynamicResource Brush.Card}" /> <Setter TargetName="Edge" Property="Fill" Value="{DynamicResource Brush.Card}" />
</Trigger> </Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter TargetName="Edge" Property="Stroke" Value="{DynamicResource Brush.Accent}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False"> <Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4" /> <Setter Property="Opacity" Value="0.4" />
</Trigger> </Trigger>
@@ -124,18 +214,19 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- ===================== Devices ===================== --> <!-- ===================== Devices (declared top to bottom: the tab order follows) ===================== -->
<DockPanel> <Grid>
<DockPanel DockPanel.Dock="Top" Height="32" Margin="0,0,0,8"> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<DockPanel Height="32" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Icon}" ui:ButtonIcon.Glyph="{StaticResource Icon.Refresh}" Command="{Binding RefreshCommand}" <Button DockPanel.Dock="Right" Style="{StaticResource Button.Icon}" ui:ButtonIcon.Glyph="{StaticResource Icon.Refresh}" Command="{Binding RefreshCommand}"
ToolTip="{l:Loc Tooltips.Import.Refresh}" AutomationProperties.Name="{l:Loc Import.Devices.Refresh}" /> ToolTip="{l:Loc Tooltips.Import.Refresh}" AutomationProperties.Name="{l:Loc Import.Devices.Refresh}" />
<TextBlock Text="{l:Loc Import.Devices.Title}" Style="{StaticResource Text.Section}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Devices.Title}" Style="{StaticResource Text.Section}" VerticalAlignment="Center" />
</DockPanel> </DockPanel>
<CheckBox DockPanel.Dock="Bottom" Margin="0,8,0,0" IsChecked="{Binding AutoImport}" IsEnabled="{Binding CanAutoImport}" ToolTip="{Binding AutoImportToolTip}" <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" Focusable="False" IsEnabled="{Binding CanChangeSource}">
VerticalContentAlignment="Top">
<TextBlock Text="{l:Loc Import.Devices.Auto}" TextWrapping="Wrap" Foreground="{DynamicResource Brush.TextMuted}" />
</CheckBox>
<ScrollViewer VerticalScrollBarVisibility="Auto" Focusable="False" IsEnabled="{Binding CanChangeSource}">
<StackPanel> <StackPanel>
<ListBox ItemsSource="{Binding Sources}" SelectedItem="{Binding SelectedSource}" ItemContainerStyle="{StaticResource ListBoxItem.Device}" <ListBox ItemsSource="{Binding Sources}" SelectedItem="{Binding SelectedSource}" ItemContainerStyle="{StaticResource ListBoxItem.Device}"
AutomationProperties.Name="{l:Loc Import.Devices.Title}"> AutomationProperties.Name="{l:Loc Import.Devices.Title}">
@@ -158,7 +249,7 @@
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" /> <TextBlock Text="{Binding Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{Binding Subtitle}" Style="{StaticResource Text.Secondary}" TextTrimming="CharacterEllipsis" Margin="0,2,0,0" /> <TextBlock Text="{Binding Subtitle}" Style="{StaticResource Text.Secondary}" TextTrimming="CharacterEllipsis" Margin="0,2,0,0" />
</StackPanel> </StackPanel>
<ui:StatusGlyph x:Name="State" Grid.Column="2" Kind="Online" Margin="8,0,0,0" VerticalAlignment="Center" ToolTip="{Binding StateText}" /> <ui:StatusGlyph x:Name="State" Grid.Column="2" Kind="Online" Margin="8,0,0,0" VerticalAlignment="Center" />
</Grid> </Grid>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding Kind}" Value="Drive"> <DataTrigger Binding="{Binding Kind}" Value="Drive">
@@ -181,7 +272,8 @@
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<Button Style="{StaticResource Button.Dashed}" Height="44" HorizontalContentAlignment="Left" Command="{Binding PickFolderCommand}" ToolTip="{l:Loc Tooltips.Import.Folder}"> <Button x:Name="FolderSourceButton" Style="{StaticResource Button.Dashed}" Height="44" HorizontalContentAlignment="Left" Command="{Binding PickFolderCommand}"
ToolTip="{Binding FolderSourceToolTip}" AutomationProperties.Name="{l:Loc Import.Devices.Folder}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<ui:Icon Glyph="{StaticResource Icon.Folder}" Margin="0,0,10,0" Foreground="{DynamicResource Brush.TextMuted}" /> <ui:Icon Glyph="{StaticResource Icon.Folder}" Margin="0,0,10,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Text="{l:Loc Import.Devices.Folder}" Foreground="{DynamicResource Brush.TextMuted}" /> <TextBlock Text="{l:Loc Import.Devices.Folder}" Foreground="{DynamicResource Brush.TextMuted}" />
@@ -189,7 +281,11 @@
</Button> </Button>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
</DockPanel> <CheckBox Grid.Row="2" Margin="0,8,0,0" IsChecked="{Binding AutoImport}" IsEnabled="{Binding CanAutoImport}" ToolTip="{Binding AutoImportToolTip}"
VerticalContentAlignment="Top" AutomationProperties.Name="{l:Loc Import.Devices.Auto}">
<TextBlock Text="{l:Loc Import.Devices.Auto}" TextWrapping="Wrap" Foreground="{DynamicResource Brush.TextMuted}" />
</CheckBox>
</Grid>
<!-- ===================== Profile, form and plan ===================== --> <!-- ===================== Profile, form and plan ===================== -->
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="20,16"> <Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="20,16">
@@ -200,9 +296,22 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Profile header: nickname (or its field for a new card), identity, Edit ▾. --> <!-- Profile header: nickname (or its field for a new card), identity, Edit ▾ (declared in reading order for Tab). -->
<DockPanel Margin="0,0,0,14" MinHeight="32"> <Grid Margin="0,0,0,14" MinHeight="32">
<Button x:Name="EditButton" DockPanel.Dock="Right" Click="OnOpenMenu" IsEnabled="{Binding CanEditProfile}" ToolTip="{Binding EditToolTip}"> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding SourceTitle}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" MaxWidth="320" TextTrimming="CharacterEllipsis"
Visibility="{Binding IsNicknameOpen, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<TextBox x:Name="NicknameBox" Width="240" Text="{Binding Nickname.Text, UpdateSourceTrigger=PropertyChanged}" shell:EditBehavior.Field="{Binding Nickname}"
ui:Field.Placeholder="{l:Loc Import.Profile.Nickname}" ToolTip="{Binding Nickname.ToolTip}" AutomationProperties.Name="{l:Loc Import.Profile.Nickname}"
Visibility="{Binding IsNicknameOpen, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Grid.Column="1" Text="{Binding IdentityText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="12,0,12,0"
TextTrimming="CharacterEllipsis" ToolTip="{Binding IdentityText}" />
<Button x:Name="EditButton" Grid.Column="2" Click="OnOpenMenu" IsEnabled="{Binding CanEditProfile}" ToolTip="{Binding EditToolTip}"
AutomationProperties.Name="{l:Loc Import.Profile.Edit}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Import.Profile.Edit}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Profile.Edit}" VerticalAlignment="Center" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" /> <ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
@@ -226,16 +335,7 @@
</ContextMenu> </ContextMenu>
</Button.ContextMenu> </Button.ContextMenu>
</Button> </Button>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> </Grid>
<TextBlock Text="{Binding SourceTitle}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" MaxWidth="320" TextTrimming="CharacterEllipsis"
Visibility="{Binding IsNicknameOpen, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<TextBox x:Name="NicknameBox" Width="240" Text="{Binding Nickname.Text, UpdateSourceTrigger=PropertyChanged}" shell:EditBehavior.Field="{Binding Nickname}"
ui:Field.Placeholder="{l:Loc Import.Profile.Nickname}" ToolTip="{Binding Nickname.ToolTip}" AutomationProperties.Name="{l:Loc Import.Profile.Nickname}"
Visibility="{Binding IsNicknameOpen, Converter={StaticResource BoolToVisibility}}" />
</StackPanel>
<TextBlock Text="{Binding IdentityText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="12,0,12,0"
TextTrimming="CharacterEllipsis" ToolTip="{Binding IdentityText}" />
</DockPanel>
<!-- The form (Import.html grid). --> <!-- The form (Import.html grid). -->
<StackPanel Grid.Row="1" IsEnabled="{Binding IsFormEnabled}" Grid.IsSharedSizeScope="True"> <StackPanel Grid.Row="1" IsEnabled="{Binding IsFormEnabled}" Grid.IsSharedSizeScope="True">
@@ -245,12 +345,14 @@
IsEnabled="{Binding CanUseArchive}" ToolTip="{Binding ArchiveToolTip}" /> IsEnabled="{Binding CanUseArchive}" ToolTip="{Binding ArchiveToolTip}" />
<RadioButton GroupName="Destination" Content="{l:Loc Import.Destination.Folder}" IsChecked="{Binding IsFolderDestination}" <RadioButton GroupName="Destination" Content="{l:Loc Import.Destination.Folder}" IsChecked="{Binding IsFolderDestination}"
ToolTip="{l:Loc Tooltips.Import.FolderDestination}" Margin="0,4,8,4" /> ToolTip="{l:Loc Tooltips.Import.FolderDestination}" Margin="0,4,8,4" />
<TextBox Width="190" Height="30" Text="{Binding FolderPath.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" <TextBox x:Name="FolderPathBox" Style="{StaticResource TextBox.FolderPath}"
shell:EditBehavior.Field="{Binding FolderPath}" ToolTip="{Binding FolderPath.ToolTip}" AutomationProperties.Name="{l:Loc Import.Destination.Folder}" Text="{Binding FolderPath.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding FolderPath}"
ToolTip="{Binding FolderPath.ToolTip}" AutomationProperties.Name="{l:Loc Import.Destination.FolderPlaceholder}"
ui:Field.Placeholder="{l:Loc Import.Destination.FolderPlaceholder}" /> ui:Field.Placeholder="{l:Loc Import.Destination.FolderPlaceholder}" />
<Button Style="{StaticResource Button.Icon}" Width="30" MinWidth="30" Height="30" Margin="6,0,18,0" Content="…" Command="{Binding ChooseDestinationCommand}" <Button Style="{StaticResource Button.Icon}" Width="30" MinWidth="30" Height="30" Margin="6,0,18,0" Content="…" Command="{Binding ChooseDestinationCommand}"
ToolTip="{l:Loc Tooltips.Import.ChooseFolder}" AutomationProperties.Name="{l:Loc Import.Destination.Choose}" /> ToolTip="{l:Loc Tooltips.Import.ChooseFolder}" AutomationProperties.Name="{l:Loc Import.Destination.Choose}" />
<RadioButton GroupName="Destination" IsChecked="{Binding IsServerDestination}" IsEnabled="{Binding CanUseServer}" ToolTip="{Binding ServerToolTip}"> <RadioButton GroupName="Destination" IsChecked="{Binding IsServerDestination}" IsEnabled="{Binding CanUseServer}" ToolTip="{Binding ServerToolTip}"
AutomationProperties.Name="{Binding ServerChoiceName}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Import.Destination.Server}" /> <TextBlock Text="{l:Loc Import.Destination.Server}" />
<ui:Icon Glyph="{StaticResource Icon.Server}" Margin="10,0,6,0" Foreground="{DynamicResource Brush.Accent}" /> <ui:Icon Glyph="{StaticResource Icon.Server}" Margin="10,0,6,0" Foreground="{DynamicResource Brush.Accent}" />
@@ -265,16 +367,16 @@
<CheckBox Content="{l:Loc Import.Scan.Subfolders}" IsChecked="{Binding IncludeSubfolders}" ToolTip="{l:Loc Tooltips.Import.Subfolders}" /> <CheckBox Content="{l:Loc Import.Scan.Subfolders}" IsChecked="{Binding IncludeSubfolders}" ToolTip="{l:Loc Tooltips.Import.Subfolders}" />
<CheckBox Content="{l:Loc Import.Scan.Sessions}" IsChecked="{Binding SplitSessions}" ToolTip="{l:Loc Tooltips.Import.Sessions}" /> <CheckBox Content="{l:Loc Import.Scan.Sessions}" IsChecked="{Binding SplitSessions}" ToolTip="{l:Loc Tooltips.Import.Sessions}" />
<StackPanel Orientation="Horizontal" Style="{StaticResource Import.Choice}" IsEnabled="{Binding SplitSessions}"> <StackPanel Orientation="Horizontal" Style="{StaticResource Import.Choice}" IsEnabled="{Binding SplitSessions}">
<TextBlock Text="{l:Loc Import.Scan.Gap}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Scan.Gap}" Style="{StaticResource Text.Unit}" />
<TextBox Style="{StaticResource TextBox.Small}" Text="{Binding GapMinutes.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" <TextBox x:Name="GapBox" Style="{StaticResource TextBox.Small}" Text="{Binding GapMinutes.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding GapMinutes}" ToolTip="{Binding GapMinutes.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.GapName}" /> shell:EditBehavior.Field="{Binding GapMinutes}" ToolTip="{Binding GapMinutes.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.GapName}" />
<TextBlock Text="{l:Loc Import.Scan.Minutes}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Scan.Minutes}" Style="{StaticResource Text.Unit}" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Style="{StaticResource Import.Choice}"> <StackPanel Orientation="Horizontal" Style="{StaticResource Import.Choice}">
<TextBlock Text="{l:Loc Import.Scan.Minimum}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Scan.Minimum}" Style="{StaticResource Text.Unit}" />
<TextBox Style="{StaticResource TextBox.Small}" Text="{Binding MinimumFrames.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" <TextBox Style="{StaticResource TextBox.Small}" Text="{Binding MinimumFrames.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding MinimumFrames}" ToolTip="{Binding MinimumFrames.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.MinimumName}" /> shell:EditBehavior.Field="{Binding MinimumFrames}" ToolTip="{Binding MinimumFrames.ToolTip}" AutomationProperties.Name="{l:Loc Import.Scan.MinimumName}" />
<TextBlock Text="{l:Loc Import.Scan.Frames}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Scan.Frames}" Style="{StaticResource Text.Unit}" />
</StackPanel> </StackPanel>
<CheckBox Content="{l:Loc Import.Scan.Verify}" IsChecked="{Binding VerifyCopies}" ToolTip="{l:Loc Tooltips.Import.Verify}" /> <CheckBox Content="{l:Loc Import.Scan.Verify}" IsChecked="{Binding VerifyCopies}" ToolTip="{l:Loc Tooltips.Import.Verify}" />
</WrapPanel> </WrapPanel>
@@ -289,11 +391,11 @@
<ColumnDefinition Width="*" MinWidth="140" /> <ColumnDefinition Width="*" MinWidth="140" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox Style="{StaticResource TextBox.Mono}" Height="30" Text="{Binding FolderTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" <TextBox Style="{StaticResource TextBox.NameTemplate}" Text="{Binding FolderTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding FolderTemplate}" ToolTip="{Binding FolderTemplate.ToolTip}" GotKeyboardFocus="OnFolderTemplateFocus" shell:EditBehavior.Field="{Binding FolderTemplate}" ToolTip="{Binding FolderTemplate.ToolTip}" GotKeyboardFocus="OnFolderTemplateFocus"
AutomationProperties.Name="{l:Loc Import.Names.Folder}" /> AutomationProperties.Name="{l:Loc Import.Names.Folder}" />
<TextBlock Grid.Column="1" Text="/" Foreground="{DynamicResource Brush.TextFaint}" Margin="10,0" VerticalAlignment="Center" /> <TextBlock Grid.Column="1" Text="/" Style="{StaticResource Text.Unit}" Foreground="{DynamicResource Brush.TextFaint}" Margin="10,0" />
<TextBox Grid.Column="2" Style="{StaticResource TextBox.Mono}" Height="30" <TextBox Grid.Column="2" Style="{StaticResource TextBox.NameTemplate}"
Text="{Binding FileTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding FileTemplate}" Text="{Binding FileTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding FileTemplate}"
ToolTip="{Binding FileTemplate.ToolTip}" GotKeyboardFocus="OnFileTemplateFocus" AutomationProperties.Name="{l:Loc Import.Names.File}" /> ToolTip="{Binding FileTemplate.ToolTip}" GotKeyboardFocus="OnFileTemplateFocus" AutomationProperties.Name="{l:Loc Import.Names.File}" />
<Button x:Name="TokensButton" Grid.Column="3" Style="{StaticResource Button.Icon}" Width="30" MinWidth="30" Height="30" Margin="10,0,0,0" Content="{}{ }" <Button x:Name="TokensButton" Grid.Column="3" Style="{StaticResource Button.Icon}" Width="30" MinWidth="30" Height="30" Margin="10,0,0,0" Content="{}{ }"
@@ -313,7 +415,7 @@
</Button> </Button>
</Grid> </Grid>
<TextBlock Text="{Binding NamePreview}" Style="{StaticResource Text.Secondary}" Foreground="{DynamicResource Brush.TextFaint}" Margin="0,6,0,0" <TextBlock Text="{Binding NamePreview}" Style="{StaticResource Text.Secondary}" Foreground="{DynamicResource Brush.TextFaint}" Margin="0,6,0,0"
TextTrimming="CharacterEllipsis" ToolTip="{Binding NamePreview}" /> TextTrimming="CharacterEllipsis" ToolTip="{Binding NamePreview}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
</StackPanel> </StackPanel>
</HeaderedContentControl> </HeaderedContentControl>
@@ -361,11 +463,15 @@
Typography.NumeralAlignment="Tabular" TextTrimming="CharacterEllipsis" ToolTip="{Binding TotalsText}" /> Typography.NumeralAlignment="Tabular" TextTrimming="CharacterEllipsis" ToolTip="{Binding TotalsText}" />
</DockPanel> </DockPanel>
<!-- No source, reading the card, or the reason no plan can be made. --> <!-- No source, reading the card, or the reason no plan can be made: one sentence and one action. -->
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding ShowsStatus, Converter={StaticResource BoolToVisibility}}"> <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="420"
<TextBlock Text="{Binding StatusText}" Foreground="{DynamicResource Brush.TextMuted}" TextAlignment="Center" TextWrapping="Wrap" MaxWidth="420" /> Visibility="{Binding ShowsStatus, Converter={StaticResource BoolToVisibility}}">
<ProgressBar IsIndeterminate="{Binding IsBusyPlanning}" Width="240" Margin="0,12,0,0" <TextBlock x:Name="StatusLine" Text="{Binding StatusText, NotifyOnTargetUpdated=True}" ToolTip="{Binding StatusDetail}" Foreground="{DynamicResource Brush.TextMuted}"
TextAlignment="Center" TextWrapping="Wrap" AutomationProperties.LiveSetting="Polite" />
<ProgressBar IsIndeterminate="{Binding IsBusyPlanning}" Width="240" Margin="0,12,0,0" AutomationProperties.LabeledBy="{Binding ElementName=StatusLine}"
Visibility="{Binding IsBusyPlanning, Converter={StaticResource BoolToVisibility}}" /> Visibility="{Binding IsBusyPlanning, Converter={StaticResource BoolToVisibility}}" />
<Button x:Name="StatusActionButton" Content="{Binding StatusActionText}" Command="{Binding StatusActionCommand}" ToolTip="{Binding StatusActionToolTip}"
HorizontalAlignment="Center" Margin="0,12,0,0" Visibility="{Binding HasStatusAction, Converter={StaticResource BoolToVisibility}}" />
</StackPanel> </StackPanel>
<!-- Sessions of the plan with editable titles. --> <!-- Sessions of the plan with editable titles. -->
@@ -374,53 +480,59 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid TextElement.FontSize="12" Margin="0,0,0,4"> <!-- The right margin is the list's scroll bar (always shown, 10 px), so header and cells line up. -->
<Grid TextElement.FontSize="12" Margin="0,0,10,4">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.35*" MinWidth="110" /> <ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="SessionTime" />
<ColumnDefinition Width="0.85*" MinWidth="70" /> <ColumnDefinition Width="0.85*" MinWidth="70" />
<ColumnDefinition Width="0.6*" MinWidth="56" /> <ColumnDefinition Width="0.6*" MinWidth="56" />
<ColumnDefinition Width="0.8*" MinWidth="64" /> <ColumnDefinition Width="0.9*" MinWidth="64" />
<ColumnDefinition Width="1.9*" MinWidth="150" /> <ColumnDefinition Width="1.6*" MinWidth="150" />
<ColumnDefinition Width="Auto" SharedSizeGroup="SessionAction" /> <ColumnDefinition Width="Auto" SharedSizeGroup="SessionAction" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Session}" /> <TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Session}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Frames}" Margin="10,0,0,0" /> <TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Frames}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Size}" Margin="10,0,0,0" TextAlignment="Right" /> <TextBlock Grid.Column="2" Style="{StaticResource Text.HeaderNumber}" Text="{l:Loc Import.Session.Column.Size}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Camera}" Margin="10,0,0,0" /> <TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Camera}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Sequence}" Margin="10,0,0,0" /> <TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Sequence}" Margin="10,0,0,0" />
</Grid> </Grid>
<ListBox Grid.Row="1" ItemsSource="{Binding Sessions}" ItemContainerStyle="{StaticResource ListBoxItem.Session}" AutomationProperties.Name="{l:Loc Import.Plan.Title}" <ListBox x:Name="SessionRows" Grid.Row="1" ItemsSource="{Binding Sessions}" ItemContainerStyle="{StaticResource ListBoxItem.Session}"
KeyboardNavigation.TabNavigation="Continue"> AutomationProperties.Name="{l:Loc Import.Plan.Title}" KeyboardNavigation.TabNavigation="Continue" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type imp:ImportSessionRowViewModel}"> <DataTemplate DataType="{x:Type imp:ImportSessionRowViewModel}">
<Grid Style="{StaticResource Session.Grid}" TextElement.FontSize="12"> <Grid Style="{StaticResource Session.Grid}" TextElement.FontSize="12">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.35*" MinWidth="110" /> <ColumnDefinition Width="Auto" MinWidth="110" SharedSizeGroup="SessionTime" />
<ColumnDefinition Width="0.85*" MinWidth="70" /> <ColumnDefinition Width="0.85*" MinWidth="70" />
<ColumnDefinition Width="0.6*" MinWidth="56" /> <ColumnDefinition Width="0.6*" MinWidth="56" />
<ColumnDefinition Width="0.8*" MinWidth="64" /> <ColumnDefinition Width="0.9*" MinWidth="64" />
<ColumnDefinition Width="1.9*" MinWidth="150" /> <ColumnDefinition Width="1.6*" MinWidth="150" />
<ColumnDefinition Width="Auto" SharedSizeGroup="SessionAction" /> <ColumnDefinition Width="Auto" SharedSizeGroup="SessionAction" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Row.TimeText}" ToolTip="{Binding Row.TimeText}" /> <TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Row.TimeText}" ToolTip="{Binding Row.TimeText}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Row.FramesText}" Margin="10,0,0,0" /> <TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Row.FramesText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.CellNumber}" Text="{Binding Row.SizeText}" Margin="10,0,0,0" /> <TextBlock Grid.Column="2" Style="{StaticResource Text.CellNumberLtr}" Text="{Binding Row.SizeText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding Row.CameraText}" Margin="10,0,0,0" ToolTip="{Binding Row.CameraText}" /> <TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding Row.CameraText}" Margin="10,0,0,0" ToolTip="{Binding Row.CameraText}" />
<DockPanel Grid.Column="4" Margin="10,0,0,0"> <DockPanel Grid.Column="4" Margin="10,0,0,0">
<TextBlock x:Name="Target" DockPanel.Dock="Right" Text="{l:Loc Import.Session.NewShort}" Foreground="{DynamicResource Brush.Accent}" <TextBlock x:Name="Target" DockPanel.Dock="Right" Text="{l:Loc Import.Session.NewShort}" Foreground="{DynamicResource Brush.Accent}"
VerticalAlignment="Center" Margin="8,0,0,0" ToolTip="{Binding Row.TargetText}" /> VerticalAlignment="Center" Margin="8,0,0,0" ToolTip="{Binding Row.TargetText}" />
<TextBox Height="26" Padding="8,0" Text="{Binding Title.Text, UpdateSourceTrigger=PropertyChanged}" shell:EditBehavior.Field="{Binding Title}" <TextBox Height="26" Padding="8,0" Text="{Binding Title.Text, UpdateSourceTrigger=PropertyChanged}" shell:EditBehavior.Field="{Binding Title}"
IsEnabled="{Binding IsEditable}" ui:Field.Placeholder="{Binding Placeholder}" ToolTip="{Binding TitleToolTip}" ToolTipService.ShowOnDisabled="True" IsEnabled="{Binding IsEditable}" ui:Field.Placeholder="{Binding Placeholder}" ToolTip="{Binding TitleToolTip}" ToolTipService.ShowOnDisabled="True"
AutomationProperties.Name="{l:Loc Import.Session.Column.Sequence}" /> AutomationProperties.Name="{Binding TitleName}" />
</DockPanel> </DockPanel>
<Button Grid.Column="5" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{l:Loc Import.Session.Merge}" Command="{Binding MergeCommand}" <Button x:Name="Merge" Grid.Column="5" Style="{StaticResource Button.RowAction}" Margin="8,0,0,0" Content="{l:Loc Import.Session.Merge}"
ToolTip="{Binding MergeToolTip}" Visibility="{Binding HasMerge, Converter={StaticResource BoolToVisibility}}" /> Command="{Binding MergeCommand}" ToolTip="{Binding MergeToolTip}" AutomationProperties.Name="{Binding MergeName}"
AutomationProperties.HelpText="{Binding MergeToolTip}" Visibility="{Binding HasMerge, Converter={StaticResource BoolToVisibility}}" />
</Grid> </Grid>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding Row.IsNew}" Value="False"> <DataTrigger Binding="{Binding Row.IsNew}" Value="False">
<Setter TargetName="Target" Property="Text" Value="{l:Loc Import.Session.AddsShort}" /> <Setter TargetName="Target" Property="Text" Value="{l:Loc Import.Session.AddsShort}" />
<Setter TargetName="Target" Property="Foreground" Value="{DynamicResource Brush.TextMuted}" /> <Setter TargetName="Target" Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger> </DataTrigger>
<!-- While copying the plan is fixed: no row action to reveal. -->
<DataTrigger Binding="{Binding IsEditable}" Value="False">
<Setter TargetName="Merge" Property="Visibility" Value="Hidden" />
</DataTrigger>
</DataTemplate.Triggers> </DataTemplate.Triggers>
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
@@ -436,7 +548,10 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<ui:StatusGlyph Kind="{Binding ResultKind}" Text="{Binding ResultText}" FontSize="16" FontWeight="SemiBold" ToolTip="{l:Loc Tooltips.Import.Result}" /> <!-- The glyph colours the result; the text beside it is what screen readers announce. -->
<ui:StatusGlyph x:Name="ResultGlyph" Kind="{Binding ResultKind}" VerticalAlignment="Center" />
<TextBlock Text="{Binding ResultText, NotifyOnTargetUpdated=True}" Foreground="{Binding Foreground, ElementName=ResultGlyph}" FontSize="16" FontWeight="SemiBold"
VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Import.Result}" AutomationProperties.LiveSetting="Polite" />
<TextBlock Text="{Binding DetailText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,0,0,0" VerticalAlignment="Center" /> <TextBlock Text="{Binding DetailText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,0,0,0" VerticalAlignment="Center" />
</StackPanel> </StackPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding Failures}" Margin="0,8,0,0" ItemContainerStyle="{StaticResource ListBoxItem.Failure}" <ListBox Grid.Row="1" ItemsSource="{Binding Failures}" Margin="0,8,0,0" ItemContainerStyle="{StaticResource ListBoxItem.Failure}"
@@ -449,8 +564,8 @@
</ListBox> </ListBox>
<StackPanel Grid.Row="2" Margin="0,10,0,0" Visibility="{Binding OffersCheck, Converter={StaticResource BoolToVisibility}}"> <StackPanel Grid.Row="2" Margin="0,10,0,0" Visibility="{Binding OffersCheck, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding EraseText}" Typography.NumeralAlignment="Tabular" /> <TextBlock Text="{Binding EraseText}" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,4,0,0" <TextBlock Text="{Binding BusyText, NotifyOnTargetUpdated=True}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,4,0,0"
Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" /> AutomationProperties.LiveSetting="Polite" Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<ItemsControl ItemsSource="{Binding KeptReasons}" Focusable="False" MaxHeight="80" Margin="0,4,0,0"> <ItemsControl ItemsSource="{Binding KeptReasons}" Focusable="False" MaxHeight="80" Margin="0,4,0,0">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
@@ -466,25 +581,28 @@
Margin="0,0,8,0" Visibility="{Binding OffersDelete, Converter={StaticResource BoolToVisibility}}" /> Margin="0,0,8,0" Visibility="{Binding OffersDelete, Converter={StaticResource BoolToVisibility}}" />
<Button Style="{StaticResource Button.Destructive}" Content="{l:Loc Import.Result.Format}" Command="{Binding FormatCommand}" ToolTip="{Binding FormatToolTip}" <Button Style="{StaticResource Button.Destructive}" Content="{l:Loc Import.Result.Format}" Command="{Binding FormatCommand}" ToolTip="{Binding FormatToolTip}"
Margin="0,0,8,0" Visibility="{Binding OffersFormat, Converter={StaticResource BoolToVisibility}}" /> Margin="0,0,8,0" Visibility="{Binding OffersFormat, Converter={StaticResource BoolToVisibility}}" />
<Button Command="{Binding EjectCommand}" ToolTip="{Binding EjectToolTip}" Margin="0,0,8,0"> <Button Command="{Binding EjectCommand}" ToolTip="{Binding EjectToolTip}" Margin="0,0,8,0" AutomationProperties.Name="{l:Loc Import.Result.Eject}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<ui:Icon Glyph="{StaticResource Icon.Eject}" Margin="0,0,6,0" /> <ui:Icon Glyph="{StaticResource Icon.Eject}" Margin="0,0,6,0" />
<TextBlock Text="{l:Loc Import.Result.Eject}" /> <TextBlock Text="{l:Loc Import.Result.Eject}" />
</StackPanel> </StackPanel>
</Button> </Button>
<Button Content="{l:Loc Import.Result.Library}" Command="{Binding OpenLibraryCommand}" ToolTip="{l:Loc Tooltips.Import.Library}" Margin="0,0,8,0" /> <Button Content="{l:Loc Import.Result.Library}" Command="{Binding OpenLibraryCommand}" ToolTip="{l:Loc Tooltips.Import.Library}" Margin="0,0,8,0" />
<Button Content="{l:Loc Import.Result.New}" Command="{Binding DataContext.NewImportCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" <Button x:Name="NewImportButton" Content="{l:Loc Import.Result.New}" Command="{Binding DataContext.NewImportCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{l:Loc Tooltips.Import.New}" /> ToolTip="{l:Loc Tooltips.Import.New}" />
</WrapPanel> </WrapPanel>
</Grid> </Grid>
<!-- The import failed or was cancelled. --> <!-- The import failed or was cancelled: what happened in one sentence (its full text in the tooltip), and Retry. -->
<StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="{Binding IsFailed, Converter={StaticResource BoolToVisibility}}"> <StackPanel Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="520" Visibility="{Binding IsFailed, Converter={StaticResource BoolToVisibility}}">
<ui:StatusGlyph Kind="Failed" Text="{Binding ErrorText}" FontSize="13" HorizontalAlignment="Center" ToolTip="{l:Loc Tooltips.Import.Failed}" /> <DockPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,12,0,0"> <ui:Icon DockPanel.Dock="Left" Glyph="{StaticResource Icon.Cross}" Size="12" Foreground="{DynamicResource Brush.Error}" VerticalAlignment="Top" Margin="0,3,6,0" />
<Button Content="{l:Loc Import.Failed.Retry}" Command="{Binding RetryCommand}" ToolTip="{l:Loc Tooltips.Import.Retry}" Margin="0,0,8,0" /> <TextBlock x:Name="FailureLine" Text="{Binding ErrorText, NotifyOnTargetUpdated=True}" Foreground="{DynamicResource Brush.Error}" TextWrapping="Wrap"
<Button Content="{l:Loc Shell.Nav.Jobs}" Command="{Binding Shell.NavigateCommand}" CommandParameter="Jobs" ToolTip="{l:Loc Tooltips.Nav.Jobs}" /> TextTrimming="CharacterEllipsis" LineHeight="18" LineStackingStrategy="BlockLineHeight" MaxHeight="54" ToolTip="{Binding FailureToolTip}"
</StackPanel> AutomationProperties.LiveSetting="Assertive" />
</DockPanel>
<Button x:Name="RetryButton" Content="{l:Loc Import.Failed.Retry}" Command="{Binding RetryCommand}" ToolTip="{l:Loc Tooltips.Import.Retry}"
HorizontalAlignment="Center" Margin="0,12,0,0" />
</StackPanel> </StackPanel>
<!-- Footer: Show plan and Import, or the progress while copying. --> <!-- Footer: Show plan and Import, or the progress while copying. -->
@@ -493,15 +611,16 @@
Visibility="{Binding IsRunning, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" /> Visibility="{Binding IsRunning, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Height="36" Padding="22,0" Content="{Binding StartText}" Command="{Binding StartCommand}" <Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Height="36" Padding="22,0" Content="{Binding StartText}" Command="{Binding StartCommand}"
ToolTip="{Binding StartToolTip}" Visibility="{Binding IsRunning, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" /> ToolTip="{Binding StartToolTip}" Visibility="{Binding IsRunning, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Content="{l:Loc Import.Progress.Cancel}" Command="{Binding CancelCommand}" ToolTip="{l:Loc Tooltips.Import.Cancel}" Margin="12,0,0,0" <Button x:Name="CancelButton" DockPanel.Dock="Right" Content="{l:Loc Import.Progress.Cancel}" Command="{Binding CancelCommand}" ToolTip="{l:Loc Tooltips.Import.Cancel}" Margin="12,0,0,0"
Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibility}}" /> Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibility}}" />
<Grid Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibility}}" VerticalAlignment="Center"> <Grid Visibility="{Binding IsRunning, Converter={StaticResource BoolToVisibility}}" VerticalAlignment="Center">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ProgressBar Maximum="1" Value="{Binding Progress, Mode=OneWay}" VerticalAlignment="Center" /> <ProgressBar Maximum="1" Value="{Binding Progress, Mode=OneWay}" VerticalAlignment="Center" AutomationProperties.LabeledBy="{Binding ElementName=ProgressLine}" />
<TextBlock Grid.Column="1" Text="{Binding ProgressText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="12,0,0,0" Typography.NumeralAlignment="Tabular" /> <TextBlock x:Name="ProgressLine" Grid.Column="1" Text="{Binding ProgressText, NotifyOnTargetUpdated=True}" Foreground="{DynamicResource Brush.TextMuted}" Margin="12,0,0,0"
Typography.NumeralAlignment="Tabular" AutomationProperties.LiveSetting="Polite" />
</Grid> </Grid>
</DockPanel> </DockPanel>
</Grid> </Grid>
@@ -527,7 +646,7 @@
AutomationProperties.Name="{l:Loc Import.Details.Close}" /> AutomationProperties.Name="{l:Loc Import.Details.Close}" />
<TextBlock Text="{l:Loc Import.Details.Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" /> <TextBlock Text="{l:Loc Import.Details.Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" />
<TextBlock Text="{Binding TotalsText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,0,0,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" <TextBlock Text="{Binding TotalsText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="14,0,0,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
Typography.NumeralAlignment="Tabular" /> Typography.NumeralAlignment="Tabular" ToolTip="{Binding TotalsText}" />
</DockPanel> </DockPanel>
<ItemsControl Grid.Row="1" ItemsSource="{Binding Conflicts}" Focusable="False" Margin="0,8,0,0" MaxHeight="96"> <ItemsControl Grid.Row="1" ItemsSource="{Binding Conflicts}" Focusable="False" Margin="0,8,0,0" MaxHeight="96">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
@@ -536,7 +655,8 @@
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
<Grid Grid.Row="2" Margin="0,10,0,4" TextElement.FontSize="12"> <!-- The right margin is the list's scroll bar (always shown, 10 px), so header and cells line up. -->
<Grid Grid.Row="2" Margin="0,10,10,4" TextElement.FontSize="12">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" MinWidth="140" /> <ColumnDefinition Width="1.2*" MinWidth="140" />
<ColumnDefinition Width="1.8*" MinWidth="180" /> <ColumnDefinition Width="1.8*" MinWidth="180" />
@@ -547,13 +667,18 @@
<TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Source}" /> <TextBlock Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Source}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Destination}" Margin="10,0,0,0" /> <TextBlock Grid.Column="1" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Destination}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Action}" Margin="10,0,0,0" /> <TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Details.Column.Action}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.Header}" Text="{l:Loc Import.Session.Column.Size}" Margin="10,0,0,0" TextAlignment="Right" /> <TextBlock Grid.Column="3" Style="{StaticResource Text.HeaderNumber}" Text="{l:Loc Import.Session.Column.Size}" Margin="10,0,0,0" />
</Grid> </Grid>
<ListBox x:Name="PlanRows" Grid.Row="3" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.PlanRow}" AutomationProperties.Name="{l:Loc Import.Details.Title}" <ListBox x:Name="PlanRows" Grid.Row="3" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.PlanRow}" AutomationProperties.Name="{l:Loc Import.Details.Title}"
KeyboardNavigation.TabNavigation="Continue"> KeyboardNavigation.TabNavigation="Continue" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<!-- A file: its name on the card, its new name, what happens, its size. A session: its heading over two columns, its folder below. -->
<DataTemplate DataType="{x:Type imp:PlanDetailRow}"> <DataTemplate DataType="{x:Type imp:PlanDetailRow}">
<Grid x:Name="Row" Height="30" TextElement.FontSize="12"> <Grid x:Name="Row" Height="36" TextElement.FontSize="12">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" MinWidth="140" /> <ColumnDefinition Width="1.2*" MinWidth="140" />
<ColumnDefinition Width="1.8*" MinWidth="180" /> <ColumnDefinition Width="1.8*" MinWidth="180" />
@@ -561,21 +686,32 @@
<ColumnDefinition Width="0.5*" MinWidth="64" /> <ColumnDefinition Width="0.5*" MinWidth="64" />
<ColumnDefinition Width="Auto" SharedSizeGroup="PlanAction" /> <ColumnDefinition Width="Auto" SharedSizeGroup="PlanAction" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBlock x:Name="Source" Style="{StaticResource Text.Cell}" Text="{Binding Source}" ToolTip="{Binding Source}" /> <TextBlock x:Name="Source" Style="{StaticResource Text.Cell}" Text="{Binding SourceText}" ToolTip="{Binding Source}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Destination}" Margin="10,0,0,0" ToolTip="{Binding Destination}" /> <TextBlock x:Name="Destination" Grid.Column="1" Style="{StaticResource Text.CellPath}" Text="{Binding DestinationText}" Margin="10,0,0,0"
ToolTip="{Binding Destination}" />
<TextBlock x:Name="Action" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ActionText}" Margin="10,0,0,0" /> <TextBlock x:Name="Action" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding ActionText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.CellNumber}" Text="{Binding SizeText}" Margin="10,0,0,0" /> <TextBlock Grid.Column="3" Style="{StaticResource Text.CellNumberLtr}" Text="{Binding SizeText}" Margin="10,0,0,0" />
<Button x:Name="Split" Grid.Column="4" Style="{StaticResource Button.Row}" Margin="10,0,4,0" Content="{l:Loc Import.Details.Split}" <Button x:Name="Split" Grid.Column="4" Style="{StaticResource Button.RowAction}" Margin="10,0,4,0" Content="{l:Loc Import.Details.Split}"
Command="{Binding DataContext.SplitCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}" Command="{Binding DataContext.SplitCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Import.Split}" Visibility="Hidden" /> ToolTip="{l:Loc Tooltips.Import.Split}" AutomationProperties.Name="{Binding SplitName}" Visibility="Hidden" />
</Grid> </Grid>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding CanSplit}" Value="True"> <DataTrigger Binding="{Binding CanSplit}" Value="True">
<Setter TargetName="Split" Property="Visibility" Value="Visible" /> <Setter TargetName="Split" Property="Visibility" Value="Visible" />
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding Kind}" Value="File">
<Setter TargetName="Source" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="Source" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
<DataTrigger Binding="{Binding Kind}" Value="Session"> <DataTrigger Binding="{Binding Kind}" Value="Session">
<Setter TargetName="Row" Property="Height" Value="50" />
<Setter TargetName="Source" Property="FontWeight" Value="SemiBold" /> <Setter TargetName="Source" Property="FontWeight" Value="SemiBold" />
<Setter TargetName="Row" Property="Height" Value="34" /> <Setter TargetName="Source" Property="Grid.ColumnSpan" Value="2" />
<Setter TargetName="Destination" Property="Grid.Row" Value="1" />
<Setter TargetName="Destination" Property="Grid.Column" Value="0" />
<Setter TargetName="Destination" Property="Grid.ColumnSpan" Value="4" />
<Setter TargetName="Destination" Property="Margin" Value="0,2,0,8" />
<Setter TargetName="Destination" Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding IsSkipped}" Value="True"> <DataTrigger Binding="{Binding IsSkipped}" Value="True">
<Setter TargetName="Row" Property="Opacity" Value="0.6" /> <Setter TargetName="Row" Property="Opacity" Value="0.6" />
+67 -2
View File
@@ -1,7 +1,10 @@
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Threading; using System.Windows.Threading;
@@ -9,12 +12,19 @@ namespace Titano.App.Sections;
public partial class ImportView : UserControl public partial class ImportView : UserControl
{ {
/// <summary>A polite text that keeps changing (copy progress) is announced at most this often.</summary>
private static readonly TimeSpan PoliteInterval = TimeSpan.FromSeconds(3);
private readonly Dictionary<UIElement, DateTime> _announced = [];
private readonly HashSet<UIElement> _pending = [];
private bool _nicknameOpen; private bool _nicknameOpen;
private bool _restoreFocus;
public ImportView() public ImportView()
{ {
InitializeComponent(); InitializeComponent();
DataContextChanged += OnDataContextChanged; DataContextChanged += OnDataContextChanged;
AddHandler(Binding.TargetUpdatedEvent, new EventHandler<DataTransferEventArgs>(OnTargetUpdated));
} }
private ImportViewModel? Model => DataContext as ImportViewModel; private ImportViewModel? Model => DataContext as ImportViewModel;
@@ -42,7 +52,9 @@ public partial class ImportView : UserControl
/// <summary> /// <summary>
/// Keyboard focus follows what opens: the nickname field when it appears (a new card, Rename), and "Show plan" /// Keyboard focus follows what opens: the nickname field when it appears (a new card, Rename), and "Show plan"
/// (focus returns to its button when it closes). /// (focus returns to its button when it closes). A change of phase that hides the focused button (Import, Retry,
/// New import, the status action, "Split here" closing the plan) moves focus to what replaced it, once the card
/// is planned again.
/// </summary> /// </summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e) private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{ {
@@ -54,9 +66,62 @@ public partial class ImportView : UserControl
if (opened && IsVisible) FocusLater(NicknameBox); if (opened && IsVisible) FocusLater(NicknameBox);
} }
if (e.PropertyName is nameof(ImportViewModel.IsDetailsOpen) && IsVisible) if (e.PropertyName is nameof(ImportViewModel.IsDetailsOpen) && IsVisible)
FocusLater(model.IsDetailsOpen ? ClosePlanButton : ShowPlanButton); {
if (model.IsDetailsOpen) FocusLater(ClosePlanButton);
else _restoreFocus = true;
}
if (e.PropertyName is nameof(ImportViewModel.IsDetailsOpen) or "" && IsVisible) Dispatcher.BeginInvoke(DispatcherPriority.Input, RestoreFocus);
}
private void RestoreFocus()
{
if (Model is not { } model || model.IsBusyPlanning) return;
var lost = Keyboard.FocusedElement is UIElement { IsVisible: false } focused && IsAncestorOf(focused);
if (!_restoreFocus && !lost) return;
_restoreFocus = false;
UIElement? target = model.IsRunning ? CancelButton
: model.IsDone ? NewImportButton
: model.IsFailed ? RetryButton
: model.HasPlan ? ShowPlanButton
: model.HasStatusAction ? StatusActionButton
: null;
target?.Focus();
} }
/// <summary>After layout: an element that just became visible cannot take focus yet.</summary> /// <summary>After layout: an element that just became visible cannot take focus yet.</summary>
private void FocusLater(UIElement element) => Dispatcher.BeginInvoke(DispatcherPriority.Input, () => element.Focus()); private void FocusLater(UIElement element) => Dispatcher.BeginInvoke(DispatcherPriority.Input, () => element.Focus());
/// <summary>
/// Live texts (AutomationProperties.LiveSetting in XAML, their binding with NotifyOnTargetUpdated) tell screen
/// readers that they changed: planning status, copy progress, the result and the failure. WPF raises nothing by itself.
/// </summary>
private void OnTargetUpdated(object? sender, DataTransferEventArgs e)
{
if (e.TargetObject is not UIElement element || AutomationProperties.GetLiveSetting(element) is var setting && setting == AutomationLiveSetting.Off) return;
if (AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) Announce(element, setting);
}
/// <summary>Polite texts at most every <see cref="PoliteInterval"/>, ending with their latest value; assertive ones at once.</summary>
private void Announce(UIElement element, AutomationLiveSetting setting)
{
var wait = setting == AutomationLiveSetting.Polite && _announced.TryGetValue(element, out var last) ? last + PoliteInterval - DateTime.UtcNow : TimeSpan.Zero;
if (wait > TimeSpan.Zero)
{
if (_pending.Add(element)) _ = AnnounceLaterAsync(element, setting, wait);
return;
}
_announced[element] = DateTime.UtcNow;
// After the bindings of the same change: a text that is being hidden is not announced.
Dispatcher.BeginInvoke(DispatcherPriority.Background, () =>
{
if (element.IsVisible) UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
});
}
private async Task AnnounceLaterAsync(UIElement element, AutomationLiveSetting setting, TimeSpan wait)
{
await Task.Delay(wait);
_pending.Remove(element);
Announce(element, setting);
}
} }
+150 -27
View File
@@ -35,6 +35,18 @@ public enum ImportPhase
Failed, Failed,
} }
/// <summary>The one action offered with the Plan panel's status sentence (BRIEF §0.2 rule 6).</summary>
public enum StatusAction
{
None,
PickSource,
Refresh,
OpenLibrary,
ChooseDestination,
OpenServer,
Replan,
}
/// <summary>A template token offered by the "{ }" menu.</summary> /// <summary>A template token offered by the "{ }" menu.</summary>
public sealed record TokenItem(string Text, string ToolTip); public sealed record TokenItem(string Text, string ToolTip);
@@ -65,6 +77,8 @@ public sealed class ImportViewModel : SectionViewModel
private ImportChoices _choices = new(); private ImportChoices _choices = new();
private ImportPhase _phase; private ImportPhase _phase;
private string? _statusText; private string? _statusText;
private string? _statusDetail;
private StatusAction _statusAction;
private ImportPlan? _rawPlan; private ImportPlan? _rawPlan;
private ImportPlan? _plan; private ImportPlan? _plan;
private PlanTotals? _totals; private PlanTotals? _totals;
@@ -78,6 +92,7 @@ public sealed class ImportViewModel : SectionViewModel
private string? _progressText; private string? _progressText;
private ImportResultViewModel? _result; private ImportResultViewModel? _result;
private string? _errorText; private string? _errorText;
private string? _errorDetail;
private Guid? _jobId; private Guid? _jobId;
private string? _jobSourceKey; private string? _jobSourceKey;
private Guid? _jobCardId; private Guid? _jobCardId;
@@ -98,11 +113,13 @@ public sealed class ImportViewModel : SectionViewModel
_planDelay.Tick += (_, _) => _planDelay.Tick += (_, _) =>
{ {
_planDelay.Stop(); _planDelay.Stop();
Replan(); // A finished import keeps its result; "New import" plans again.
if (_phase != ImportPhase.Done) Replan();
}; };
Nickname = new EditableField(string.Empty, _ => null, text => _ = SaveCardAsync(text, null), () => Loc.L("Tooltips.Import.Nickname")); Nickname = new EditableField(string.Empty, _ => null, text => _ = SaveCardAsync(text, null), () => Loc.L("Tooltips.Import.Nickname"));
FolderPath = new EditableField(string.Empty, ArchiveLocations.Validate, text => Choices = _choices with { FolderPath = text }, // The path is checked only while Folder is the destination; typing one chooses Folder, as "…" does.
() => Loc.L("Tooltips.Import.FolderPath")); FolderPath = new EditableField(string.Empty, text => IsFolderDestination ? ArchiveLocations.Validate(text) : null,
text => Choices = _choices with { FolderPath = text, Destination = ImportDestinationKind.Folder }, () => Loc.L("Tooltips.Import.FolderPath"));
GapMinutes = NumberField(1, 24 * 60, () => _choices.GapMinutes, n => Choices = _choices with { GapMinutes = n }, "Tooltips.Import.Gap"); GapMinutes = NumberField(1, 24 * 60, () => _choices.GapMinutes, n => Choices = _choices with { GapMinutes = n }, "Tooltips.Import.Gap");
MinimumFrames = NumberField(1, 1000, () => _choices.MinimumFrames, n => Choices = _choices with { MinimumFrames = n }, "Tooltips.Import.MinimumFrames"); MinimumFrames = NumberField(1, 1000, () => _choices.MinimumFrames, n => Choices = _choices with { MinimumFrames = n }, "Tooltips.Import.MinimumFrames");
FolderTemplate = new EditableField(_choices.FolderTemplate, t => NamingPreview.Validate(t, isFolder: true), FolderTemplate = new EditableField(_choices.FolderTemplate, t => NamingPreview.Validate(t, isFolder: true),
@@ -136,6 +153,7 @@ public sealed class ImportViewModel : SectionViewModel
Replan(); Replan();
}); });
RetryCommand = new AsyncRelayCommand(RetryAsync, () => _phase == ImportPhase.Failed); RetryCommand = new AsyncRelayCommand(RetryAsync, () => _phase == ImportPhase.Failed);
StatusActionCommand = new RelayCommand(RunStatusAction, () => HasStatusAction);
shell.Services.Devices.Arrived += device => Dispatch(() => _ = CardInsertedAsync(device)); shell.Services.Devices.Arrived += device => Dispatch(() => _ = CardInsertedAsync(device));
shell.Services.Devices.Removed += removed => Dispatch(() => _ = OnRemovedAsync()); shell.Services.Devices.Removed += removed => Dispatch(() => _ = OnRemovedAsync());
@@ -168,6 +186,8 @@ public sealed class ImportViewModel : SectionViewModel
/// <summary>The source of a running import stays selected.</summary> /// <summary>The source of a running import stays selected.</summary>
public bool CanChangeSource => _phase != ImportPhase.Running; public bool CanChangeSource => _phase != ImportPhase.Running;
public string FolderSourceToolTip => CanChangeSource ? Loc.L("Tooltips.Import.Folder") : Loc.L("Import.Blocked.Copying");
/// <summary>Start the import with the card's profile as soon as this card is inserted (per card, BRIEF §12.4).</summary> /// <summary>Start the import with the card's profile as soon as this card is inserted (per card, BRIEF §12.4).</summary>
public bool AutoImport public bool AutoImport
{ {
@@ -243,6 +263,7 @@ public sealed class ImportViewModel : SectionViewModel
var previous = _choices; var previous = _choices;
if (previous == value) return; if (previous == value) return;
_choices = value; _choices = value;
if (value.Destination != previous.Destination) FolderPath.Refresh();
OnPropertyChanged(string.Empty); OnPropertyChanged(string.Empty);
if (value.NeedsNewPlan(previous) || (value.TitlesChangeNames != previous.TitlesChangeNames && _titles.Count > 0)) SchedulePlan(); if (value.NeedsNewPlan(previous) || (value.TitlesChangeNames != previous.TitlesChangeNames && _titles.Count > 0)) SchedulePlan();
else ApplyPlan(); else ApplyPlan();
@@ -278,12 +299,15 @@ public sealed class ImportViewModel : SectionViewModel
public bool CanUseArchive => _archive is not null && Services.Archives is not null; public bool CanUseArchive => _archive is not null && Services.Archives is not null;
public string ArchiveToolTip => CanUseArchive ? Loc.L("Tooltips.Import.Archive", _archive!.RootPath) : Loc.L("Import.Blocked.NoArchive"); public string ArchiveToolTip => CanUseArchive ? Loc.L("Tooltips.Import.Archive", BidiText.Ltr(_archive!.RootPath)) : Loc.L("Import.Blocked.NoArchive");
public bool CanUseServer => Services.Server.IsConnected; public bool CanUseServer => Services.Server.IsConnected;
public string ServerName => Services.Server.ServerName ?? Loc.L("Import.Destination.NotConnected"); public string ServerName => Services.Server.ServerName ?? Loc.L("Import.Destination.NotConnected");
/// <summary>"Server · Studio NAS": the Server choice as screen readers announce it.</summary>
public string ServerChoiceName => Loc.L("Import.Destination.Server") + " · " + ServerName;
public string ServerToolTip => CanUseServer ? Loc.L("Tooltips.Import.Server") : Loc.L("Import.Blocked.NoServer"); public string ServerToolTip => CanUseServer ? Loc.L("Tooltips.Import.Server") : Loc.L("Import.Blocked.NoServer");
public EditableField FolderPath { get; } public EditableField FolderPath { get; }
@@ -409,8 +433,11 @@ public sealed class ImportViewModel : SectionViewModel
public bool IsBusyPlanning => _phase == ImportPhase.Planning; public bool IsBusyPlanning => _phase == ImportPhase.Planning;
/// <summary>The form is fixed while copying, and behind "Show plan" while it is open.</summary> /// <summary>
public bool IsFormEnabled => _phase != ImportPhase.Running && _details is null; /// The form is fixed while copying and once the import finished ("New import" plans again, so the verification
/// result is never replaced by a silent new plan), and behind "Show plan" while it is open.
/// </summary>
public bool IsFormEnabled => _phase is not (ImportPhase.Running or ImportPhase.Done) && _details is null;
public bool IsPlanPanelEnabled => _details is null; public bool IsPlanPanelEnabled => _details is null;
public bool HasPlan => _plan is not null && _phase is ImportPhase.Ready or ImportPhase.Running; public bool HasPlan => _plan is not null && _phase is ImportPhase.Ready or ImportPhase.Running;
@@ -422,13 +449,48 @@ public sealed class ImportViewModel : SectionViewModel
/// <summary>"Reading 1,240 photos", "Choose a card or a folder", or why nothing can be planned.</summary> /// <summary>"Reading 1,240 photos", "Choose a card or a folder", or why nothing can be planned.</summary>
public string? StatusText => _statusText; public string? StatusText => _statusText;
public string TotalsText => _totals?.Text ?? string.Empty; /// <summary>The cause behind a status sentence (an exception's own text), for its tooltip; null when there is none.</summary>
public string? StatusDetail => _statusDetail;
/// <summary>The status sentence comes with one action: Folder…, Refresh, Library, Choose folder, Server or Retry.</summary>
public bool HasStatusAction => _statusAction != StatusAction.None && _phase == ImportPhase.NoSource;
public string StatusActionText => _statusAction switch
{
StatusAction.PickSource => Loc.L("Import.Devices.Folder"),
StatusAction.Refresh => Loc.L("Import.Devices.Refresh"),
StatusAction.OpenLibrary => Loc.L("Shell.Nav.Library"),
StatusAction.ChooseDestination => Loc.L("Import.Destination.Choose"),
StatusAction.OpenServer => Loc.L("Shell.Nav.Server"),
StatusAction.Replan => Loc.L("Import.Failed.Retry"),
_ => string.Empty,
};
public string StatusActionToolTip => _statusAction switch
{
StatusAction.PickSource => Loc.L("Tooltips.Import.Folder"),
StatusAction.Refresh => Loc.L("Tooltips.Import.Refresh"),
StatusAction.OpenLibrary => Loc.L("Tooltips.Nav.Library"),
StatusAction.ChooseDestination => Loc.L("Tooltips.Import.ChooseFolder"),
StatusAction.OpenServer => Loc.L("Tooltips.Nav.Server"),
StatusAction.Replan => Loc.L("Tooltips.Import.New"),
_ => string.Empty,
};
public ICommand StatusActionCommand { get; }
/// <summary>"3 sessions · 4,812 photos · 96.2 GB · about 12 min"; without the estimate once the import finished.</summary>
public string TotalsText => (IsDone ? _totals?.SummaryText : _totals?.Text) ?? string.Empty;
public string DuplicatesText => _totals?.DuplicatesText ?? string.Empty; public string DuplicatesText => _totals?.DuplicatesText ?? string.Empty;
public bool HasDuplicates => _totals?.Duplicates > 0; public bool HasDuplicates => _totals?.Duplicates > 0;
public StatusKind DuplicatesKind => HasDuplicates ? StatusKind.Warning : StatusKind.Done; public StatusKind DuplicatesKind => HasDuplicates ? StatusKind.Warning : StatusKind.Done;
public string ImportedBeforeText => _totals?.ImportedBeforeText ?? string.Empty;
public string SpaceText => _totals?.SpaceText ?? string.Empty; /// <summary>Plan figures that no longer hold once the import finished are not shown then.</summary>
public bool IsSpaceShort => _totals is { HasEnoughSpace: false }; public string ImportedBeforeText => IsDone ? string.Empty : _totals?.ImportedBeforeText ?? string.Empty;
public string SpaceText => IsDone ? string.Empty : _totals?.SpaceText ?? string.Empty;
public bool IsSpaceShort => !IsDone && _totals is { HasEnoughSpace: false };
public ObservableCollection<ImportSessionRowViewModel> Sessions { get; } = []; public ObservableCollection<ImportSessionRowViewModel> Sessions { get; } = [];
@@ -490,8 +552,12 @@ public sealed class ImportViewModel : SectionViewModel
} }
} }
/// <summary>Why the import stopped, in one sentence.</summary>
public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); } public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); }
/// <summary>The failure's own text when it says more than <see cref="ErrorText"/>, else what was kept.</summary>
public string FailureToolTip => _errorDetail is { Length: > 0 } detail && detail != _errorText ? detail : Loc.L("Tooltips.Import.Failed");
// ---------------- Lifecycle ---------------- // ---------------- Lifecycle ----------------
protected override void OnActivated() protected override void OnActivated()
@@ -595,8 +661,8 @@ public sealed class ImportViewModel : SectionViewModel
ShowProgress(progress); ShowProgress(progress);
} }
/// <summary>Shows an import that stopped with <paramref name="message"/>, without running it (capture).</summary> /// <summary>Shows an import that stopped with <paramref name="error"/>, without running it (capture).</summary>
public void ShowFailed(string message) => Fail(message); public void ShowFailed(Exception error) => Fail(ImportFailures.Import(error, SourceTitle), error.Message);
public override void Dispose() public override void Dispose()
{ {
@@ -844,6 +910,14 @@ public sealed class ImportViewModel : SectionViewModel
_ => null, _ => null,
}; };
/// <summary>Where the user removes the destination's blocker: the Library (create or adopt an archive), the folder picker, the Server screen.</summary>
private StatusAction DestinationAction() => _choices.Destination switch
{
ImportDestinationKind.Archive => StatusAction.OpenLibrary,
ImportDestinationKind.Folder => StatusAction.ChooseDestination,
_ => StatusAction.OpenServer,
};
private IImportDestination? Destination() => DestinationBlocker() is not null ? null : _choices.Destination switch private IImportDestination? Destination() => DestinationBlocker() is not null ? null : _choices.Destination switch
{ {
ImportDestinationKind.Archive => new ArchiveDestination(Services.Archives!, _archive!), ImportDestinationKind.Archive => new ArchiveDestination(Services.Archives!, _archive!),
@@ -867,12 +941,13 @@ public sealed class ImportViewModel : SectionViewModel
Sessions.Clear(); Sessions.Clear();
if (_selected?.Root is not { } root) if (_selected?.Root is not { } root)
{ {
SetStatus(ImportPhase.NoSource, Loc.L(_selected is null ? "Import.Status.Choose" : "Import.Status.NotInserted")); if (_selected is null) SetStatus(ImportPhase.NoSource, Loc.L("Import.Status.Choose"), StatusAction.PickSource);
else SetStatus(ImportPhase.NoSource, Loc.L("Import.Status.NotInserted"), StatusAction.Refresh);
return; return;
} }
if (Destination() is not { } destination) if (Destination() is not { } destination)
{ {
SetStatus(ImportPhase.NoSource, DestinationBlocker()); SetStatus(ImportPhase.NoSource, DestinationBlocker(), DestinationAction());
return; return;
} }
SetStatus(ImportPhase.Planning, Loc.L("Import.Status.Reading")); SetStatus(ImportPhase.Planning, Loc.L("Import.Status.Reading"));
@@ -908,7 +983,7 @@ public sealed class ImportViewModel : SectionViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or ArgumentException or InvalidOperationException) catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or ArgumentException or InvalidOperationException)
{ {
Log.Warning("import", $"Planning the import of {root} failed", ex); Log.Warning("import", $"Planning the import of {root} failed", ex);
SetStatus(ImportPhase.NoSource, Loc.L("Import.Status.PlanFailed", ex.Message)); SetStatus(ImportPhase.NoSource, ImportFailures.Plan(ex, SourceTitle), StatusAction.Replan, ex.Message);
} }
} }
@@ -1014,11 +1089,43 @@ public sealed class ImportViewModel : SectionViewModel
Replan(); Replan();
} }
private void SetStatus(ImportPhase phase, string? text) private void SetStatus(ImportPhase phase, string? text, StatusAction action = StatusAction.None, string? detail = null)
{ {
_statusText = text; _statusText = text;
_statusAction = action;
_statusDetail = detail;
Phase = phase; Phase = phase;
OnPropertyChanged(nameof(StatusText)); OnPropertyChanged(nameof(StatusText));
OnPropertyChanged(nameof(StatusDetail));
OnPropertyChanged(nameof(HasStatusAction));
OnPropertyChanged(nameof(StatusActionText));
OnPropertyChanged(nameof(StatusActionToolTip));
CommandManager.InvalidateRequerySuggested();
}
private void RunStatusAction()
{
switch (_statusAction)
{
case StatusAction.PickSource:
PickSourceFolder();
break;
case StatusAction.Refresh:
_ = RefreshSourcesAsync();
break;
case StatusAction.OpenLibrary:
Shell.Navigate(SectionKey.Library);
break;
case StatusAction.ChooseDestination:
ChooseDestinationFolder();
break;
case StatusAction.OpenServer:
Shell.Navigate(SectionKey.Server);
break;
case StatusAction.Replan:
Replan();
break;
}
} }
// ---------------- Running ---------------- // ---------------- Running ----------------
@@ -1033,7 +1140,7 @@ public sealed class ImportViewModel : SectionViewModel
_jobSourceKey = source.Key; _jobSourceKey = source.Key;
if (source.Card is { } card) await SaveProfileAsync(card, choices); if (source.Card is { } card) await SaveProfileAsync(card, choices);
Details = null; Details = null;
ErrorText = null; ClearFailure();
Progress = 0; Progress = 0;
ProgressText = Loc.L("Import.Progress.Starting"); ProgressText = Loc.L("Import.Progress.Starting");
Phase = ImportPhase.Running; Phase = ImportPhase.Running;
@@ -1046,9 +1153,16 @@ public sealed class ImportViewModel : SectionViewModel
return; return;
} }
var progress = new Progress<ImportProgress>(ShowProgress); var progress = new Progress<ImportProgress>(ShowProgress);
var outcome = choices.Destination == ImportDestinationKind.Folder ImportOutcome outcome;
? await Task.Run(() => LocalImport.RunAsync(plan, new FolderImportSink(choices.FolderPath!), choices.VerifyCopies, progress, cts.Token), cts.Token) if (choices.Destination == ImportDestinationKind.Folder)
: await RunServerAsync(plan, choices, progress, cts.Token); outcome = await Task.Run(() => LocalImport.RunAsync(plan, new FolderImportSink(choices.FolderPath!), choices.VerifyCopies, progress, cts.Token), cts.Token);
else if (Services.Server.Flow is { Address: { } address, Token: { } token })
outcome = await RunServerAsync(plan, choices, address, token, progress, cts.Token);
else
{
Fail(Loc.L("Import.Blocked.NoServer"));
return;
}
Finish(plan, outcome); Finish(plan, outcome);
} }
catch (OperationCanceledException) when (cts.IsCancellationRequested) catch (OperationCanceledException) when (cts.IsCancellationRequested)
@@ -1059,14 +1173,13 @@ public sealed class ImportViewModel : SectionViewModel
{ {
// Whatever stopped it, the screen leaves Running: the form, the sources and Retry come back. // Whatever stopped it, the screen leaves Running: the form, the sources and Retry come back.
Log.Warning("import", $"Import of {root} failed", ex); Log.Warning("import", $"Import of {root} failed", ex);
Fail(ex.Message); Fail(ImportFailures.Import(ex, source.Title), ex.Message);
} }
} }
private async Task<ImportOutcome> RunServerAsync(ImportPlan plan, ImportChoices choices, IProgress<ImportProgress> progress, CancellationToken ct) private async Task<ImportOutcome> RunServerAsync(ImportPlan plan, ImportChoices choices, Uri address, string token, IProgress<ImportProgress> progress,
CancellationToken ct)
{ {
var flow = Services.Server.Flow;
if (flow.Address is not { } address || flow.Token is not { } token) throw new InvalidOperationException(Loc.L("Import.Blocked.NoServer"));
var staging = Path.Combine(ServerStagingRoot, plan.Id.ToString("N")); var staging = Path.Combine(ServerStagingRoot, plan.Id.ToString("N"));
using var client = new TitanoClient(address, new CertificatePinning(Services.Server.Fingerprints), $"Titano ({Environment.MachineName})") { Token = token }; using var client = new TitanoClient(address, new CertificatePinning(Services.Server.Fingerprints), $"Titano ({Environment.MachineName})") { Token = token };
try try
@@ -1147,7 +1260,8 @@ public sealed class ImportViewModel : SectionViewModel
await QueueDeepAnalysisAsync(plan); await QueueDeepAnalysisAsync(plan);
break; break;
case JobState.Failed: case JobState.Failed:
Fail(job.Error ?? Loc.L("Jobs.State.Failed")); // The engine wrote the job's error (a localized sentence for the archive's own failures); the full text stays in the tooltip.
Fail(job.Error ?? Loc.L("Import.Failed.Other"), job.Error);
break; break;
case JobState.Cancelled: case JobState.Cancelled:
_jobId = null; _jobId = null;
@@ -1227,13 +1341,22 @@ public sealed class ImportViewModel : SectionViewModel
_ = Result.AutoEjectAsync(); _ = Result.AutoEjectAsync();
} }
private void Fail(string message) private void Fail(string message, string? detail = null)
{ {
_runCts = null; _runCts = null;
_errorDetail = detail;
ErrorText = message; ErrorText = message;
OnPropertyChanged(nameof(FailureToolTip));
Phase = ImportPhase.Failed; Phase = ImportPhase.Failed;
} }
private void ClearFailure()
{
_errorDetail = null;
ErrorText = null;
OnPropertyChanged(nameof(FailureToolTip));
}
private async Task CancelAsync() private async Task CancelAsync()
{ {
if (_jobId is { } id && Services.Jobs is { } jobs) await jobs.CancelAsync(id); if (_jobId is { } id && Services.Jobs is { } jobs) await jobs.CancelAsync(id);
@@ -1245,7 +1368,7 @@ public sealed class ImportViewModel : SectionViewModel
{ {
if (_jobId is { } id && Services.Jobs is { } jobs) if (_jobId is { } id && Services.Jobs is { } jobs)
{ {
ErrorText = null; ClearFailure();
Phase = ImportPhase.Running; Phase = ImportPhase.Running;
await jobs.ResumeAsync(id); await jobs.ResumeAsync(id);
return; return;
@@ -53,6 +53,49 @@ public sealed class CardPoolTests
Assert.Equal(@"D:\Shoots\2026", pool[4].Root); Assert.Equal(@"D:\Shoots\2026", pool[4].Root);
} }
[Test]
public void ARememberedCardStaysNewUntilItHasANickname()
{
var unnamed = Known(GoPro, "GoPro 12", DateTimeOffset.UtcNow) with { Nickname = null };
var source = CardPool.Build([GoPro], [unnamed], null).Single();
Assert.NotNull(source.Card, "the first plan remembered it");
Assert.False(source.IsKnown);
Assert.Equal("New card", source.StateText);
Assert.Equal("GOPRO", source.Title);
var named = CardPool.Build([GoPro], [unnamed with { Nickname = "GoPro 12" }], null).Single();
Assert.True(named.IsKnown);
Assert.Equal("Known card", named.StateText);
}
[Test]
public void TheEntryTooltipCarriesTheStateAndTheWholeSubtitle()
{
var pool = CardPool.Build([CardA, Usb], [Known(CardA, "EOS R5 · card A", DateTimeOffset.UtcNow)], @"D:\Shoots\2026");
Assert.Equal("Known card · 128 GB · 96.2 GB used", pool[0].ToolTip);
Assert.Equal("no DCIM · 1.8 TB free", pool[1].ToolTip);
Assert.Equal(@"Folder · D:\Shoots\2026", pool[2].ToolTip);
}
[Test]
public void PathsAndSerialsStayLeftToRightInARightToLeftLanguage()
{
try
{
Loc.SetCulture(CultureInfo.GetCultureInfo("he"));
var pool = CardPool.Build([Usb with { Label = string.Empty }, CardA], [], @"D:\Shoots\");
Assert.Equal("\u202AG:\\\u202C", pool[1].Title, "a drive root keeps its separator at its end");
Assert.Equal("\u202AD:\\Shoots\\\u202C", pool[2].Title);
Assert.Equal("\u202AD:\\Shoots\\\u202C", pool[2].Subtitle);
Assert.Contains("\u202A3F2A-9C11\u202C", pool[0].IdentityText);
Assert.Equal("EOS_DIGITAL", pool[0].Title, "a label is left to bidi");
}
finally
{
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
}
}
[Test] [Test]
public void AKnownCardWithoutDcimIsStillACard() public void AKnownCardWithoutDcimIsStillACard()
{ {
@@ -66,6 +66,10 @@ public sealed class ImportChoicesTests
Assert.True((a with { FileTemplate = "{name}" }).NeedsNewPlan(a)); Assert.True((a with { FileTemplate = "{name}" }).NeedsNewPlan(a));
Assert.True((a with { Destination = ImportDestinationKind.Folder }).NeedsNewPlan(a)); Assert.True((a with { Destination = ImportDestinationKind.Folder }).NeedsNewPlan(a));
Assert.True((a with { IncludeSubfolders = false }).NeedsNewPlan(a)); Assert.True((a with { IncludeSubfolders = false }).NeedsNewPlan(a));
Assert.False((a with { FolderPath = @"D:\Shoots" }).NeedsNewPlan(a), "the folder path is not used for the archive");
var folder = a with { Destination = ImportDestinationKind.Folder, FolderPath = @"D:\Shoots" };
Assert.True((folder with { FolderPath = @"E:\Backup" }).NeedsNewPlan(folder));
Assert.False((folder with { FolderPath = @"d:\shoots" }).NeedsNewPlan(folder), "paths compare without case");
Assert.False(a.TitlesChangeNames); Assert.False(a.TitlesChangeNames);
Assert.True((a with { FolderTemplate = "{year}/{Title:upper}" }).TitlesChangeNames); Assert.True((a with { FolderTemplate = "{year}/{Title:upper}" }).TitlesChangeNames);
} }
@@ -0,0 +1,41 @@
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Http;
using Titano.App.Import;
using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Protocol;
using Titano.Protocol.Client;
using Titano.Testing;
namespace Titano.App.Tests.Import;
/// <summary>A stopped import or plan says what happened in one localized sentence, never the exception's raw text.</summary>
public sealed class ImportFailuresTests
{
public ImportFailuresTests() => Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
[Test]
public void AnImportFailureIsOneSentenceByCause()
{
const string Card = "EOS R5 · card A";
Assert.Equal("EOS R5 · card A is no longer available.", ImportFailures.Import(new ImportSourceUnavailableException(@"C:\Users\me\AppData\Local\Temp\card\"), Card));
Assert.Equal("The destination is full.", ImportFailures.Import(new IOException("There is not enough space on the disk.", unchecked((int)0x80070070)), Card));
Assert.Equal("Titano may not write to the destination.", ImportFailures.Import(new UnauthorizedAccessException(@"Access to D:\Shoots is denied."), Card));
Assert.Equal("The server did not accept the photos.", ImportFailures.Import(new HttpRequestException("No such host is known."), Card));
Assert.Equal("The server did not accept the photos.",
ImportFailures.Import(new TitanoApiException(HttpStatusCode.InsufficientStorage, new ApiError("quota", "Quota exceeded", null)), Card));
Assert.Equal("The import stopped before the end.", ImportFailures.Import(new InvalidDataException("Bad sidecar. Second sentence."), Card));
}
[Test]
public void APlanningFailureNamesTheSource()
{
const string Folder = @"D:\Shoots";
Assert.Equal(@"D:\Shoots is no longer available.", ImportFailures.Plan(new DirectoryNotFoundException(@"Could not find a part of the path 'D:\Shoots\DCIM'."), Folder));
Assert.Equal(@"D:\Shoots could not be read.", ImportFailures.Plan(new UnauthorizedAccessException("Access denied."), Folder));
Assert.Equal(@"D:\Shoots could not be read.", ImportFailures.Plan(new IOException("The device is not ready."), Folder));
Assert.Equal("The import could not be planned.", ImportFailures.Plan(new InvalidOperationException("Sequence contains no elements"), Folder));
}
}
@@ -35,6 +35,7 @@ public sealed class ImportPlansTests
Assert.True(totals.HasEnoughSpace); Assert.True(totals.HasEnoughSpace);
Assert.Equal(TimeSpan.FromSeconds(3), totals.Estimate); Assert.Equal(TimeSpan.FromSeconds(3), totals.Estimate);
Assert.Equal("3 sessions · 7 photos · 120 MB · about 3 s", totals.Text); Assert.Equal("3 sessions · 7 photos · 120 MB · about 3 s", totals.Text);
Assert.Equal("3 sessions · 7 photos · 120 MB", totals.SummaryText);
Assert.Equal("1 duplicate", totals.DuplicatesText); Assert.Equal("1 duplicate", totals.DuplicatesText);
Assert.Equal("Import 5 photos", totals.ImportText); Assert.Equal("Import 5 photos", totals.ImportText);
Assert.Equal("80 MB free after import", totals.SpaceText); Assert.Equal("80 MB free after import", totals.SpaceText);
@@ -124,6 +125,39 @@ public sealed class ImportPlansTests
Assert.Equal("2026/2026-09-28 Canon EOS R5/" + plan.Sessions[0].Items[0].FileName, folder.Rows[1].Destination); Assert.Equal("2026/2026-09-28 Canon EOS R5/" + plan.Sessions[0].Items[0].FileName, folder.Rows[1].Destination);
} }
[Test]
public void ShowPlanShowsNamesUnderTheirSessionFolder()
{
var plan = ThreeSessions();
var details = ImportPlans.Details(plan, ImportDestinationKind.Archive, verify: true);
var session = details.Rows[0];
Assert.True(session.SourceText.StartsWith("Session 1 · ", StringComparison.Ordinal), session.SourceText);
Assert.Equal("2026/2026-09-28 Canon EOS R5/originals", session.DestinationText);
var file = details.Rows[2];
Assert.Equal("IMG_0002.CR2", file.SourceText);
Assert.Equal(plan.Sessions[0].Items[1].FileName, file.DestinationText);
Assert.Equal("DCIM/100CANON/IMG_0002.CR2", file.Source, "the full path stays for the tooltip");
Assert.Equal("Split at IMG_0002.CR2", file.SplitName);
}
[Test]
public void ARightToLeftLanguageReadsTheSessionTimesWithItsOwnArrow()
{
var plan = ThreeSessions();
Assert.Contains("→", ImportPlans.Sessions(plan, ImportDestinationKind.Archive, new HashSet<string>())[0].TimeText);
try
{
Loc.SetCulture(CultureInfo.GetCultureInfo("he"));
var time = ImportPlans.Sessions(plan, ImportDestinationKind.Archive, new HashSet<string>())[0].TimeText;
Assert.Contains("←", time);
Assert.False(time.Contains('→'), "a right-to-left reader would see the arrow point back to the start");
}
finally
{
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
}
}
[Test] [Test]
public void TheNamePreviewShowsTheFirstThreeCopiedFiles() public void TheNamePreviewShowsTheFirstThreeCopiedFiles()
{ {
@@ -1,8 +1,16 @@
using System.Globalization;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media;
using Titano.App.Import; using Titano.App.Import;
using Titano.App.Infrastructure;
using Titano.App.Sections; using Titano.App.Sections;
using Titano.App.Shell;
using Titano.App.Tests.Windows; using Titano.App.Tests.Windows;
using Titano.Core.Localization;
using Titano.Testing; using Titano.Testing;
using Titano.Ui.Controls; using Titano.Ui.Controls;
@@ -10,8 +18,9 @@ namespace Titano.App.Tests.Import;
/// <summary> /// <summary>
/// Every Import state of <c>--capture</c> (<see cref="ImportScenes"/>) on the simulated cards, rendered in both themes /// Every Import state of <c>--capture</c> (<see cref="ImportScenes"/>) on the simulated cards, rendered in both themes
/// in the real main window, with the figures and gates each state must show — and the buttons really enabled, not /// in the real main window at the 1200 × 788 capture size, with the figures and gates each state must show — and the
/// only their commands. /// buttons really enabled, named for screen readers, nothing that matters cut off, and paths, numbers and times
/// readable in a right-to-left language.
/// </summary> /// </summary>
[WindowsOnly] [WindowsOnly]
[Serial] [Serial]
@@ -26,7 +35,9 @@ public sealed class ImportScreenSmokeTests
var import = app.Shell.Import; var import = app.Shell.Import;
await ShowAsync(app, "inserted"); await ShowAsync(app, "inserted");
await UseCaptureSizeAsync(app);
Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts), "the insertion toast"); Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts), "the insertion toast");
Assert.False(import.FolderPath.HasErrors, "the folder path is not checked while Archive is the destination");
await app.ExpectAsync<ImportView>("import-inserted"); await app.ExpectAsync<ImportView>("import-inserted");
await ShowAsync(app, "plan"); await ShowAsync(app, "plan");
@@ -40,11 +51,29 @@ public sealed class ImportScreenSmokeTests
await app.ExpectAsync<ImportView>("import-plan"); await app.ExpectAsync<ImportView>("import-plan");
Assert.True(ButtonFor(app, import.StartCommand).IsEnabled, "the Import button is enabled once the plan is ready"); Assert.True(ButtonFor(app, import.StartCommand).IsEnabled, "the Import button is enabled once the plan is ready");
Assert.True(ButtonFor(app, import.Sessions[1].MergeCommand).IsEnabled, "a session can merge into the one before"); Assert.True(ButtonFor(app, import.Sessions[1].MergeCommand).IsEnabled, "a session can merge into the one before");
Assert.False(Validation.GetHasError(Named<TextBox>(app, "FolderPathBox")), "the folder path is not checked while Archive is the destination");
foreach (var session in import.Sessions)
Assert.True(Fits(TextFor(app, session.Row.TimeText)), $"the session time '{session.Row.TimeText}' is cut at 1200 px");
foreach (var item in DeviceItems(app))
{
Assert.NotNull(item.FocusVisualStyle, "a device shows keyboard focus");
Assert.Equal(((ImportSource)item.DataContext).ToolTip, item.ToolTip as string);
}
AssertEveryButtonIsNamed(app);
await AssertFourDigitsFitAsync(app, import);
await AssertFolderPathIsCheckedOnlyForFolderAsync(app, import);
await ShowAsync(app, "showplan"); await ShowAsync(app, "showplan");
Assert.True(import.IsDetailsOpen); Assert.True(import.IsDetailsOpen);
Assert.Equal(50 + 3, import.Details!.Rows.Count); Assert.Equal(50 + 3, import.Details!.Rows.Count);
await app.ExpectAsync<ImportView>("import-showplan"); await app.ExpectAsync<ImportView>("import-showplan");
var file = import.Details.Rows[2];
Assert.True(Fits(TextFor(app, file.SourceText)), "a file's name on the card is shown whole");
Assert.True(Fits(TextFor(app, file.DestinationText)), "a file's new name is shown whole");
Assert.True(Fits(TextFor(app, import.Details.Rows[0].SourceText)), "a session heading is shown whole");
Assert.Within(Left(app, TextFor(app, Loc.L("Import.Details.Column.Action"))), 0, Left(app, TextFor(app, file.ActionText)), 0, 2,
"the Action header lines up with its cells");
AssertEveryButtonIsNamed(app);
await ShowAsync(app, "running"); await ShowAsync(app, "running");
Assert.True(import.IsRunning); Assert.True(import.IsRunning);
@@ -52,11 +81,27 @@ public sealed class ImportScreenSmokeTests
Assert.False(import.Sessions[0].IsEditable, "titles lock while copying"); Assert.False(import.Sessions[0].IsEditable, "titles lock while copying");
await app.ExpectAsync<ImportView>("import-running"); await app.ExpectAsync<ImportView>("import-running");
Assert.True(ButtonFor(app, import.CancelCommand).IsEnabled, "Cancel is enabled while copying"); Assert.True(ButtonFor(app, import.CancelCommand).IsEnabled, "Cancel is enabled while copying");
foreach (var item in DeviceItems(app))
{
Assert.False(item.IsEnabled, "the source of a running import stays selected");
Assert.Equal(Loc.L("Import.Blocked.Copying"), item.ToolTip as string);
}
Assert.Equal(0.4, TextFor(app, Loc.L("Import.Scan.Frames")).Opacity, "unit words dim with their field");
var progress = Named<TextBlock>(app, "ProgressLine");
Assert.Equal(AutomationLiveSetting.Polite, AutomationProperties.GetLiveSetting(progress));
Assert.Same(progress, AutomationProperties.GetLabeledBy(app.FindAll<ProgressBar>().First(p => p.IsVisible && IsInImport(p))));
await ShowAsync(app, "failed"); await ShowAsync(app, "failed");
Assert.True(import.IsFailed); Assert.True(import.IsFailed);
Assert.Equal("EOS R5 · card A is no longer available.", import.ErrorText);
Assert.Contains(SampleCards.Card(app.Services.Environment.DataDirectory).Root, import.FailureToolTip);
await app.ExpectAsync<ImportView>("import-failed"); await app.ExpectAsync<ImportView>("import-failed");
Assert.True(ButtonFor(app, import.RetryCommand).IsEnabled, "Retry is enabled after a failure"); Assert.True(ButtonFor(app, import.RetryCommand).IsEnabled, "Retry is enabled after a failure");
var failure = Named<TextBlock>(app, "FailureLine");
Assert.Equal(AutomationLiveSetting.Assertive, AutomationProperties.GetLiveSetting(failure));
Assert.True(Fits(failure), "the failure sentence is shown whole");
Assert.Null(app.FindAll<Button>().FirstOrDefault(b => b.IsVisible && ReferenceEquals(b.Command, app.Shell.NavigateCommand) && IsInImport(b)),
"an error offers one action");
await ShowAsync(app, "done"); await ShowAsync(app, "done");
Assert.True(import.IsDone); Assert.True(import.IsDone);
@@ -67,14 +112,55 @@ public sealed class ImportScreenSmokeTests
Assert.Equal(49, result.Actions.DeleteCount); Assert.Equal(49, result.Actions.DeleteCount);
Assert.False(result.Actions.CanFormat, "a photo touched since the import keeps the card from being formatted"); Assert.False(result.Actions.CanFormat, "a photo touched since the import keeps the card from being formatted");
Assert.Empty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts)); Assert.Empty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts));
Assert.False(import.IsFormEnabled, "a finished import keeps its form until New import");
Assert.False(import.TotalsText.Contains(Loc.L("Import.Plan.About", string.Empty).Trim(), StringComparison.Ordinal), "no estimate after the import");
Assert.Equal(string.Empty, import.SpaceText);
await app.ExpectAsync<ImportView>("import-done"); await app.ExpectAsync<ImportView>("import-done");
Assert.True(ButtonFor(app, result.DeleteCommand).IsEnabled, "the Delete button follows the dry run"); Assert.True(ButtonFor(app, result.DeleteCommand).IsEnabled, "the Delete button follows the dry run");
AssertEveryButtonIsNamed(app);
await ShowAsync(app, "newcard"); await ShowAsync(app, "newcard");
Assert.True(import.IsNicknameOpen, "a new card asks for its nickname"); Assert.True(import.IsNicknameOpen, "a new card asks for its nickname");
Assert.Equal("SONY", import.SourceTitle); Assert.Equal("SONY", import.SourceTitle);
Assert.False(import.SelectedSource!.IsKnown, "a card without a nickname is still new, though its plan remembered it");
Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts)); Assert.NotEmpty(app.FindAll<ToastHost>().SelectMany(host => host.Toasts));
await app.ExpectAsync<ImportView>("import-newcard"); await app.ExpectAsync<ImportView>("import-newcard");
AssertEveryButtonIsNamed(app);
});
[Test]
public Task PathsNumbersAndTimesStayReadableRightToLeft() => ScreenHost.RunAsync(async () =>
{
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
await app.Sample.FillAsync();
UiLanguage.Apply("ar");
try
{
var import = app.Shell.Import;
await ShowAsync(app, "plan");
Assert.Equal(ImportPhase.Ready, import.Phase);
Assert.Equal(FlowDirection.RightToLeft, WindowOf(app).FlowDirection);
Assert.Equal(FlowDirection.LeftToRight, Named<TextBox>(app, "FolderPathBox").FlowDirection);
Assert.Equal(FlowDirection.LeftToRight, Named<TextBox>(app, "GapBox").FlowDirection);
foreach (var template in app.FindAll<TextBox>().Where(t => EditBehavior.GetField(t) is { } f && (f == import.FolderTemplate || f == import.FileTemplate)))
Assert.Equal(FlowDirection.LeftToRight, template.FlowDirection, "name templates read left to right");
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, import.NamePreview).FlowDirection, "the name preview reads left to right");
var size = TextFor(app, import.Sessions[0].Row.SizeText);
Assert.Equal(FlowDirection.LeftToRight, size.FlowDirection);
Assert.Equal(TextAlignment.Right, size.TextAlignment, "numbers stay right-aligned");
Assert.Contains("←", import.Sessions[0].Row.TimeText);
await app.ExpectAsync<ImportView>("import-plan-ar");
await ShowAsync(app, "showplan");
var file = import.Details!.Rows[2];
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, file.SourceText).FlowDirection);
Assert.Equal(FlowDirection.LeftToRight, TextFor(app, file.DestinationText).FlowDirection);
await app.ExpectAsync<ImportView>("import-showplan-ar");
}
finally
{
UiLanguage.Apply("en");
}
}); });
/// <summary>As <c>--capture</c> does: toasts of the previous state go, those of an insertion state stay.</summary> /// <summary>As <c>--capture</c> does: toasts of the previous state go, those of an insertion state stay.</summary>
@@ -83,6 +169,7 @@ public sealed class ImportScreenSmokeTests
DismissToasts(app); DismissToasts(app);
await ImportScenes.ShowAsync(app.Shell, state); await ImportScenes.ShowAsync(app.Shell, state);
if (!ImportScenes.ShowsToast(state)) DismissToasts(app); if (!ImportScenes.ShowsToast(state)) DismissToasts(app);
await SettleAsync(app);
} }
private static void DismissToasts(ScreenSmokeTests.SampleApp app) private static void DismissToasts(ScreenSmokeTests.SampleApp app)
@@ -93,6 +180,119 @@ public sealed class ImportScreenSmokeTests
} }
} }
/// <summary>The size CI captures at (and the window's minimum width): nothing may be cut there.</summary>
private static async Task UseCaptureSizeAsync(ScreenSmokeTests.SampleApp app)
{
var window = WindowOf(app);
window.Width = 1200;
window.Height = 788;
await SettleAsync(app);
}
private static async Task SettleAsync(ScreenSmokeTests.SampleApp app)
{
var window = WindowOf(app);
window.UpdateLayout();
await window.Dispatcher.InvokeAsync(() => { }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
window.UpdateLayout();
}
private static async Task WaitUntilAsync(ScreenSmokeTests.SampleApp app, Func<bool> condition, string what)
{
for (var i = 0; i < 200 && !condition(); i++) await Task.Delay(25);
Assert.True(condition(), what);
await SettleAsync(app);
}
/// <summary>The empty folder path is fine for the archive; choosing Folder makes it invalid and offers "Choose folder".</summary>
private static async Task AssertFolderPathIsCheckedOnlyForFolderAsync(ScreenSmokeTests.SampleApp app, ImportViewModel import)
{
var box = Named<TextBox>(app, "FolderPathBox");
import.IsFolderDestination = true;
await WaitUntilAsync(app, () => import.Phase == ImportPhase.NoSource, "the plan stops without a folder");
Assert.True(Validation.GetHasError(box), "an empty path is an error once Folder is chosen");
Assert.True(import.HasStatusAction);
Assert.Equal(Loc.L("Import.Destination.Choose"), import.StatusActionText);
Assert.True(Named<Button>(app, "StatusActionButton").IsVisible, "the status sentence comes with its action");
import.IsArchiveDestination = true;
await WaitUntilAsync(app, () => import.Phase == ImportPhase.Ready, "the archive plan is back");
Assert.False(Validation.GetHasError(box));
Assert.Equal("Harbour sunset", import.Plan!.Sessions[^1].Title, "typed titles survive the round trip");
}
/// <summary>The 56 px gap box shows its largest value, 1440, whole.</summary>
private static async Task AssertFourDigitsFitAsync(ScreenSmokeTests.SampleApp app, ImportViewModel import)
{
import.GapMinutes.Text = "1440";
await SettleAsync(app);
var host = Descendants(Named<TextBox>(app, "GapBox")).OfType<ScrollViewer>().First();
Assert.LessOrEqual(host.ExtentWidth, host.ViewportWidth + 1, "1440 fits the gap box");
import.GapMinutes.Revert();
}
/// <summary>Every button, check box and radio button of the screen has a name screen readers can announce.</summary>
private static void AssertEveryButtonIsNamed(ScreenSmokeTests.SampleApp app)
{
foreach (var button in app.FindAll<ButtonBase>().Where(b => b.IsVisible && b.Focusable && IsInImport(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");
}
}
private static Window WindowOf(ScreenSmokeTests.SampleApp app) => Window.GetWindow(app.FindAll<FrameworkElement>().First())!;
private static ImportView View(ScreenSmokeTests.SampleApp app) => app.FindAll<ImportView>().First(v => v.IsVisible);
private static bool IsInImport(DependencyObject element) => FindAncestor<ImportView>(element) is not null;
private static T? FindAncestor<T>(DependencyObject element)
where T : DependencyObject
{
for (var node = VisualTreeHelper.GetParent(element); node is not null; node = VisualTreeHelper.GetParent(node))
{
if (node is T match) return match;
}
return null;
}
private static IEnumerable<DependencyObject> Descendants(DependencyObject root)
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = VisualTreeHelper.GetChild(root, i);
yield return child;
foreach (var below in Descendants(child)) yield return below;
}
}
private static T Named<T>(ScreenSmokeTests.SampleApp app, string name)
where T : FrameworkElement =>
Assert.NotNull(app.FindAll<T>().FirstOrDefault(e => e.Name == name), $"{typeof(T).Name} {name}");
private static TextBlock TextFor(ScreenSmokeTests.SampleApp app, string text) =>
Assert.NotNull(app.FindAll<TextBlock>().FirstOrDefault(t => t.IsVisible && t.Text == text && IsInImport(t)), $"a visible text '{text}'");
private static IEnumerable<ListBoxItem> DeviceItems(ScreenSmokeTests.SampleApp app) =>
app.FindAll<ListBoxItem>().Where(i => i.IsVisible && i.DataContext is ImportSource);
/// <summary>The text is shown whole: its formatted width fits the width the layout gave it.</summary>
private static bool Fits(TextBlock text)
{
var typeface = new Typeface(text.FontFamily, text.FontStyle, text.FontWeight, text.FontStretch);
var formatted = new FormattedText(text.Text, CultureInfo.CurrentUICulture, text.FlowDirection, typeface, text.FontSize, Brushes.Black,
VisualTreeHelper.GetDpi(text).PixelsPerDip);
if (text.TextWrapping != TextWrapping.NoWrap)
{
formatted.MaxTextWidth = System.Math.Max(1, text.ActualWidth - text.Padding.Left - text.Padding.Right + 1);
return formatted.Height <= text.ActualHeight + 0.5;
}
return formatted.WidthIncludingTrailingWhitespace <= text.ActualWidth - text.Padding.Left - text.Padding.Right + 1;
}
private static double Left(ScreenSmokeTests.SampleApp app, FrameworkElement element) => element.TranslatePoint(new Point(0, 0), View(app)).X;
private static Button ButtonFor(ScreenSmokeTests.SampleApp app, ICommand command) => 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"); Assert.NotNull(app.FindAll<Button>().FirstOrDefault(b => ReferenceEquals(b.Command, command) && b.IsVisible), "a visible button bound to the command");
} }