merge: integration branch claude/keen-knuth-uhxv8w (Archive manager and UI kit review) into the Library workstream

The Archive manager's reviewed dialogs (live status lines, one-sentence
errors, growing label columns, left-to-right paths) move into the shared
ArchiveDialogs.xaml with their styles, so the Library's Delete and the
Trash dialog use them too. Delete, Restore and Rate failures read as one
sentence through ArchiveFailures, which now knows a stale delete plan, a
newer sidecar and a sequence already back in the library
(SequenceInLibraryException). The confirmation's plan lines in the UI font
follow the reading direction; fingerprints stay left to right.

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-06 20:36:02 +00:00
commit 9f7907d903
77 files changed
+1966 -468

No files matched your search

@@ -16,13 +16,15 @@ namespace Titano.App.Archiving;
/// <summary>
/// An in-window dialog of the Archive screen: one primary action, one way out. While its action runs, the way out
/// stops it when it can be stopped, and is disabled otherwise; the close callback receives the dialog, so a late close
/// never closes another one.
/// never closes another one. A failure stays on screen as one sentence until the next attempt.
/// </summary>
public abstract class ArchiveDialogViewModel : LocalizedViewModel
{
private readonly Action<ArchiveDialogViewModel> _close;
private bool _isBusy;
private string? _busyText;
private string? _errorText;
private string? _errorToolTip;
protected ArchiveDialogViewModel(Action<ArchiveDialogViewModel> close)
{
@@ -61,11 +63,32 @@ public abstract class ArchiveDialogViewModel : LocalizedViewModel
public string? BusyText { get => _busyText; protected set => Set(ref _busyText, value); }
/// <summary>Why the last dry run or apply stopped (<see cref="ArchiveFailures.Cause"/>); null when nothing failed.</summary>
public string? ErrorText { get => _errorText; private set => Set(ref _errorText, value); }
/// <summary>The failure as the engine reported it, for the tooltip.</summary>
public string? ErrorToolTip { get => _errorToolTip; private set => Set(ref _errorToolTip, value); }
protected void Close() => _close(this);
protected void ShowError(Exception ex)
{
ErrorText = ArchiveFailures.Cause(ex);
ErrorToolTip = ex.Message;
}
protected void ClearError()
{
ErrorText = null;
ErrorToolTip = null;
}
}
/// <summary>A fact of the rebuild dialog ("Sidecars · 412").</summary>
public sealed record DialogFact(string Label, string Value);
/// <summary>A fact of the rebuild dialog ("Sidecars · 412"); a path stays left to right, a missing value says why in its tooltip.</summary>
public sealed record DialogFact(string Label, string Value, bool IsPath = false, string? Reason = null)
{
public string ToolTip => Reason ?? Value;
}
/// <summary>
/// "Rebuild index" (BRIEF §12.5): what the rebuild reads — the sidecars on disk, then a full metadata scan of folders
@@ -84,7 +107,7 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
Archive = archive;
Availability = availability;
Indexed = indexed;
_facts = Facts(null);
_facts = Facts(null, availability == ArchiveAvailability.Offline ? Loc.L("Archive.Error.Offline", Formatting.LeftToRight(archive.RootPath)) : null);
RebuildCommand = new AsyncRelayCommand(RebuildAsync, () => !IsBusy && availability == ArchiveAvailability.Online);
}
@@ -98,7 +121,10 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
public string RebuildToolTip => Availability == ArchiveAvailability.Online ? Loc.L("Tooltips.Archive.RebuildStart") : Loc.L("Archive.Blocked.NotOnline");
/// <summary>Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread).</summary>
/// <summary>
/// Counts sequence folders with and without a sidecar (a walk of the archive tree, off the UI thread). The counts
/// read "Counting…" only while the walk runs; an offline archive or a failed walk leaves "—" with the reason.
/// </summary>
public async Task CountAsync()
{
if (Availability == ArchiveAvailability.Offline) return;
@@ -107,11 +133,12 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
{
var root = Archive.RootPath;
var folders = await Task.Run(() => ArchiveScanner.FindSequenceFolders(new ArchivePaths(root)));
FactRows = Facts(folders);
FactRows = Facts(folders, null);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
Log.Warning("archive", "Counting sidecars failed", ex);
FactRows = Facts(null, ArchiveFailures.Cause(ex));
}
finally
{
@@ -120,19 +147,24 @@ public sealed class RebuildDialogViewModel : ArchiveDialogViewModel
}
/// <summary>Shows counts computed elsewhere (capture).</summary>
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders);
public void ShowFolders(IReadOnlyList<SequenceFolder> folders) => FactRows = Facts(folders, null);
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders)
/// <param name="folders">The counted folders; null while counting or when they cannot be counted.</param>
/// <param name="uncounted">Why the folders cannot be counted; null while counting.</param>
private IReadOnlyList<DialogFact> Facts(IReadOnlyList<SequenceFolder>? folders, string? uncounted)
{
var waiting = Loc.L("Archive.Rebuild.Counting");
DialogFact Count(string label, Func<SequenceFolder, bool> counted) =>
folders is not null ? new(label, Formatting.Count(folders.Count(counted)))
: uncounted is not null ? new(label, "—", Reason: uncounted)
: new(label, Loc.L("Archive.Rebuild.Counting"));
return
[
new(Loc.L("Archive.Rebuild.Archive"), Archive.Name),
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath),
new(Loc.L("Archive.Rebuild.Root"), Archive.RootPath, IsPath: true),
new(Loc.L("Archive.Rebuild.State"), Loc.L("Archive.Availability." + Availability)),
new(Loc.L("Archive.Rebuild.Indexed"), Loc.Plural("Shell.Status.Sequences", Indexed)),
new(Loc.L("Archive.Rebuild.Sidecars"), folders is null ? waiting : Formatting.Count(folders.Count(f => f.Sidecar is not null))),
new(Loc.L("Archive.Rebuild.Metadata"), folders is null ? waiting : Formatting.Count(folders.Count(f => f.Sidecar is null))),
Count(Loc.L("Archive.Rebuild.Sidecars"), f => f.Sidecar is not null),
Count(Loc.L("Archive.Rebuild.Metadata"), f => f.Sidecar is null),
];
}
@@ -163,6 +195,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
private readonly Func<int, Task> _applied;
private readonly DispatcherTimer _delay = new() { Interval = TimeSpan.FromMilliseconds(400) };
private RenamePlan? _plan;
private string? _planError;
private IReadOnlyList<RenameRow> _rows = [];
private CancellationTokenSource? _planning;
@@ -196,7 +229,7 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
private string? ApplyBlocker =>
IsBusy ? Loc.L("Archive.Blocked.Applying")
: Template.Error is { } error ? error
: _plan is null ? Loc.L("Archive.Blocked.Planning")
: _plan is null ? _planError ?? Loc.L("Archive.Blocked.Planning")
: _plan.Steps.Count == 0 ? Loc.L("Archive.Blocked.NoChanges")
: null;
@@ -221,14 +254,20 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
base.Dispose();
}
/// <summary>The dry run of the current template (the engine's plan; nothing changes on disk).</summary>
public async Task PlanAsync()
/// <summary>The dry run of the current template (the engine's plan; nothing changes on disk); it clears the last failure.</summary>
public Task PlanAsync()
{
ClearError();
return DryRunAsync();
}
private async Task DryRunAsync()
{
_planning?.Cancel();
_plan = null;
_planError = null;
Rows = [];
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
OnPlanChanged();
if (Template.HasErrors) return;
var cts = _planning = new CancellationTokenSource();
var template = Template.Text;
@@ -240,41 +279,57 @@ public sealed class RenameDialogViewModel : ArchiveDialogViewModel
if (cts.IsCancellationRequested) return;
_plan = plan;
Rows = MassRename.Rows(plan, Mode);
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
CommandManager.InvalidateRequerySuggested();
}
catch (OperationCanceledException) when (cts.IsCancellationRequested)
{
return;
}
catch (Exception ex) when (ex is ArgumentException or DatabaseException or FormatException)
{
Log.Warning("archive", "Rename plan failed", ex);
BusyText = ex.Message;
_planError = ArchiveFailures.Cause(ex);
ShowError(ex);
}
OnPlanChanged();
}
private void OnPlanChanged()
{
OnPropertyChanged(nameof(SummaryText));
OnPropertyChanged(nameof(ApplyToolTip));
CommandManager.InvalidateRequerySuggested();
}
private async Task ApplyAsync()
{
if (_plan is not { } plan) return;
ClearError();
IsBusy = true;
var progress = new Progress<int>(n => BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count)));
// A tick posted before the apply ended must not bring its progress back.
var progress = new Progress<int>(n =>
{
if (IsBusy) BusyText = Loc.L("Archive.Rename.Applying", Formatting.Count(n), Formatting.Count(plan.Steps.Count));
});
try
{
await Task.Run(() => _archives.ApplyRenameAsync(plan, progress));
Log.Info("archive", $"{Mode} applied to {plan.Steps.Count} sequence(s)");
await _applied(plan.Steps.Count);
Close();
return;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or ArchiveOfflineException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or StaleRenamePlanException or DatabaseException)
{
Log.Warning("archive", "Rename failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
IsBusy = false;
BusyText = null;
}
// Part of the plan may have been applied, or the archive changed under it: the dry run shows what is left.
await DryRunAsync();
}
}
@@ -338,6 +393,7 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
var changes = Changes();
var run = _run = new CancellationTokenSource();
var done = 0;
ClearError();
IsBusy = true;
try
{
@@ -351,16 +407,17 @@ public sealed class RetagDialogViewModel : ArchiveDialogViewModel
await _applied(done);
Close();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException or ArchiveOfflineException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Retag failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
_run = null;
run.Dispose();
IsBusy = false;
BusyText = null;
}
}
}
+81 -24
View File
@@ -3,13 +3,42 @@
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:ar="clr-namespace:Titano.App.Archiving"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:shell="clr-namespace:Titano.App.Shell">
<!-- In-window dialogs of the archive engine's operations, shared by the Archive manager and the Library. -->
<!-- Rows that only show text: focusable, so the arrow keys move through a long list. -->
<Style x:Key="ListBoxItem.Preview" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Padding" Value="0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="AutomationProperties.Name" Value="{Binding To}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding From}" />
</Style>
<!-- Dialog labels: a column at least 116 px wide that grows with the longest label (DESIGN §2: no fixed-width labels). -->
<Style x:Key="Text.DialogLabel" TargetType="TextBlock" BasedOn="{StaticResource Text.Label}">
<Setter Property="TextTrimming" Value="None" />
</Style>
<!-- A status line screen readers announce when it changes. -->
<Style x:Key="Text.Live" TargetType="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="AutomationProperties.LiveSetting" Value="Polite" />
</Style>
<!-- A dialog's failure: one sentence in the error colour with its glyph, the engine's own text in the tooltip, announced at once. -->
<Style x:Key="Status.DialogError" TargetType="ui:StatusGlyph" BasedOn="{StaticResource {x:Type ui:StatusGlyph}}">
<Setter Property="Kind" Value="Error" />
<Setter Property="FontSize" Value="12" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Text" Value="{Binding ErrorText}" />
<Setter Property="ToolTip" Value="{Binding ErrorToolTip}" />
<Setter Property="AutomationProperties.LiveSetting" Value="Assertive" />
<Setter Property="infra:LiveRegion.Text" Value="{Binding ErrorText}" />
<Setter Property="Visibility" Value="{Binding ErrorText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
</Style>
<!-- Dialog card (DESIGN §4: Surface, Stroke, radius 12, 24 px shadow, two buttons). -->
<Style x:Key="Border.Dialog" TargetType="Border">
<Setter Property="Background" Value="{DynamicResource Brush.Surface}" />
@@ -26,21 +55,29 @@
<Border Style="{StaticResource Border.Dialog}" Width="520">
<StackPanel>
<TextBlock Text="{l:Loc Archive.Rebuild.Heading}" Style="{StaticResource Text.Title}" />
<ItemsControl ItemsSource="{Binding FactRows}" Focusable="False" Margin="0,14,0,0">
<ItemsControl ItemsSource="{Binding FactRows}" Focusable="False" Margin="0,14,0,0" Grid.IsSharedSizeScope="True">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:DialogFact}">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" SharedSizeGroup="FactLabel" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.Label}" />
<TextBlock Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Value}" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding Label}" Style="{StaticResource Text.DialogLabel}" />
<TextBlock x:Name="Value" Grid.Column="1" Text="{Binding Value}" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}"
Typography.NumeralAlignment="Tabular" />
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsPath}" Value="True">
<Setter TargetName="Value" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="Value" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}"
Visibility="{Binding BusyText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,18,0,0">
<Button Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True" IsCancel="True"
MinWidth="96" />
@@ -64,12 +101,14 @@
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Grid.Row="1" Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Archive.Rename.Template}" Style="{StaticResource Text.Label}" />
<TextBox Grid.Column="1" Style="{StaticResource TextBox.Mono}" Text="{Binding Template.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Template}" ToolTip="{Binding Template.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Rename.Template}" />
<TextBlock Text="{l:Loc Archive.Rename.Template}" Style="{StaticResource Text.DialogLabel}" />
<!-- A naming template keeps its tokens and separators in order in every language. -->
<TextBox Grid.Column="1" Style="{StaticResource TextBox.Mono}" FlowDirection="LeftToRight"
Text="{Binding Template.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Template}"
ToolTip="{Binding Template.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Rename.Template}" />
</Grid>
<TextBlock Grid.Row="2" Text="{Binding SummaryText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,12,0,6" Typography.NumeralAlignment="Tabular" />
<ListBox Grid.Row="3" ItemsSource="{Binding Rows}" ItemContainerStyle="{StaticResource ListBoxItem.Preview}" MinHeight="120"
@@ -82,19 +121,31 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding From}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{Binding From}" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.Forward}" Margin="10,0" Foreground="{DynamicResource Brush.TextFaint}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding To}" ToolTip="{Binding To}" />
<TextBlock x:Name="From" Style="{StaticResource Text.Cell}" Text="{Binding From}" Foreground="{DynamicResource Brush.TextMuted}" ToolTip="{Binding From}" />
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.Forward}" Margin="10,0" VerticalAlignment="Center" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock x:Name="To" Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding To}" ToolTip="{Binding To}" />
</Grid>
<DataTemplate.Triggers>
<!-- Move lists folders: paths stay left to right; Rename lists titles, which read in the language's direction. -->
<DataTrigger Binding="{Binding DataContext.Mode, RelativeSource={RelativeSource AncestorType=ListBox}}" Value="Folders">
<Setter TargetName="From" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="From" Property="HorizontalAlignment" Value="Left" />
<Setter TargetName="To" Property="FlowDirection" Value="LeftToRight" />
<Setter TargetName="To" Property="HorizontalAlignment" Value="Left" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<DockPanel Grid.Row="4" Margin="0,16,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Rename.Apply}" Command="{Binding ApplyCommand}"
ToolTip="{Binding ApplyToolTip}" MinWidth="96" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True"
IsCancel="True" MinWidth="96" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</Grid>
</Border>
@@ -106,17 +157,17 @@
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="Auto" MinWidth="116" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{l:Loc Archive.Retag.Add}" Style="{StaticResource Text.Label}" />
<TextBlock Text="{l:Loc Archive.Retag.Add}" Style="{StaticResource Text.DialogLabel}" />
<TextBox Grid.Column="1" Text="{Binding Add.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Add}"
ToolTip="{Binding Add.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Retag.Add}" />
<TextBlock Grid.Row="1" Text="{l:Loc Archive.Retag.Remove}" Style="{StaticResource Text.Label}" Margin="0,10,14,0" />
<TextBlock Grid.Row="1" Text="{l:Loc Archive.Retag.Remove}" Style="{StaticResource Text.DialogLabel}" Margin="0,10,14,0" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="0,10,0,0" Text="{Binding Remove.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
shell:EditBehavior.Field="{Binding Remove}" ToolTip="{Binding Remove.ToolTip}" AutomationProperties.Name="{l:Loc Archive.Retag.Remove}" />
</Grid>
@@ -124,9 +175,12 @@
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Retag.Apply}" Command="{Binding ApplyCommand}"
ToolTip="{Binding ApplyToolTip}" MinWidth="96" Margin="8,0,0,0" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsDefault="True"
IsCancel="True" MinWidth="96" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</StackPanel>
</Border>
@@ -142,8 +196,8 @@
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Cancel}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
IsDefault="True" MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
Typography.NumeralAlignment="Tabular" Margin="0,0,12,0" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" Typography.NumeralAlignment="Tabular"
Margin="0,0,12,0" />
</DockPanel>
</StackPanel>
</Border>
@@ -188,7 +242,10 @@
<DockPanel Grid.Row="3" Margin="0,16,0,0">
<Button DockPanel.Dock="Right" Content="{l:Loc Archive.Dialog.Close}" Command="{Binding CloseCommand}" ToolTip="{Binding CloseToolTip}" IsCancel="True"
IsDefault="True" MinWidth="96" />
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<Grid Margin="0,0,12,0">
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding BusyText}" infra:LiveRegion.Text="{Binding BusyText}" />
<ui:StatusGlyph Style="{StaticResource Status.DialogError}" />
</Grid>
</DockPanel>
</Grid>
</Border>
+26
View File
@@ -0,0 +1,26 @@
using Titano.App.Infrastructure;
using Titano.Core.Archiving;
using Titano.Core.Localization;
using Titano.Data;
using Titano.Data.Archiving;
namespace Titano.App.Archiving;
/// <summary>
/// Why an Archive screen action stopped, as one localized sentence chosen by cause (BRIEF §0.2 rule 6). The
/// exception's own text, which may be technical or unlocalized, goes to the tooltip and the log only.
/// </summary>
public static class ArchiveFailures
{
public static string Cause(Exception ex) => ex switch
{
ArchiveOfflineException offline => Loc.L(offline.Availability == ArchiveAvailability.ReadOnly ? "Archive.Error.ReadOnly" : "Archive.Error.Offline",
Formatting.LeftToRight(offline.Root)),
// Already one localized sentence each.
LeaseUnavailableException or NewerFormatException or StaleRenamePlanException or StaleDeletePlanException or SequenceInLibraryException => ex.Message,
UnauthorizedAccessException => Loc.L("Archive.Failed.Access"),
DatabaseException => Loc.L("Archive.Failed.Index"),
ArgumentException => Loc.L("Archive.Failed.Gone"),
_ => Loc.L("Archive.Failed.Files"),
};
}
+32 -9
View File
@@ -23,6 +23,7 @@ public enum HealthAction
Proxies,
Analyse,
Duplicates,
MarkDuplicates,
Orphans,
}
@@ -44,7 +45,7 @@ public static class ArchiveFigures
var years = stats.ByYear.Select(y => y.Year).ToList();
var range = years.Count == 0 ? "—"
: years.Min() == years.Max() ? Year(years.Min())
: Loc.L("Archive.Tile.YearRange", Year(years.Min()), Year(years.Max()));
: Formatting.LeftToRight(Loc.L("Archive.Tile.YearRange", Year(years.Min()), Year(years.Max())));
var cameras = stats.ByCamera.Count(c => !string.IsNullOrWhiteSpace(c.Model) || !string.IsNullOrWhiteSpace(c.Make));
return
[
@@ -56,9 +57,22 @@ public static class ArchiveFigures
];
}
/// <summary>Culture month initials for the heatmap columns ("J F M …", "G F M …").</summary>
public static IReadOnlyList<string> MonthLabels() =>
[.. Loc.Culture.DateTimeFormat.AbbreviatedMonthNames.Take(12).Select(m => m.Length == 0 ? string.Empty : char.ToUpper(m[0], Loc.Culture).ToString())];
/// <summary>
/// The heatmap columns: month initials where the culture's month names start with a letter of a cased alphabet
/// ("J F M …", "G F M …"); month numbers in every other language, whose abbreviations are numbered ("1月",
/// "Tháng 1"), start alike or do not abbreviate to one letter (Thai, Arabic, Hebrew, Persian).
/// </summary>
public static IReadOnlyList<string> MonthLabels()
{
var culture = Loc.Culture;
var names = culture.DateTimeFormat.AbbreviatedMonthNames.Take(12).ToList();
return names.All(HasInitial)
? [.. names.Select(m => char.ToUpper(m[0], culture).ToString())]
: [.. Enumerable.Range(1, 12).Select(month => month.ToString("N0", culture))];
}
private static bool HasInitial(string month) =>
month.Length > 0 && char.IsLetter(month[0]) && char.ToUpperInvariant(month[0]) != char.ToLowerInvariant(month[0]) && !month.Any(char.IsDigit);
/// <summary>One row per year from the first to the last with photos, oldest first; months after <paramref name="today"/> are NaN.</summary>
public static IReadOnlyList<HeatRow> PhotosPerMonth(ArchiveStats stats, DateTime today)
@@ -125,8 +139,11 @@ public static class ArchiveFigures
_ => format.ToString().ToUpperInvariant(),
};
/// <summary>Index health (Archive.html): what needs attention, each with its fix.</summary>
public static IReadOnlyList<HealthLine> Health(ArchiveStats stats, int withoutProxies)
/// <summary>
/// Index health (Archive.html): what needs attention, each with its fix. Duplicates follow the last duplicates
/// search (<paramref name="duplicateGroups"/>, groups found by hash); before one, the copies already flagged.
/// </summary>
public static IReadOnlyList<HealthLine> Health(ArchiveStats stats, int withoutProxies, int? duplicateGroups = null)
{
var h = stats.Health;
var damaged = h.MissingFrames + h.CorruptFrames;
@@ -144,12 +161,18 @@ public static class ArchiveFigures
h.NotAnalyzed == 0
? new HealthLine(true, Loc.L("Archive.Health.AnalysedOk"), HealthAction.None)
: new HealthLine(false, Loc.Plural("Archive.Health.NotAnalysed", h.NotAnalyzed), HealthAction.Analyse),
h.DuplicateFrames == 0
? new HealthLine(true, Loc.L("Archive.Health.NoDuplicates"), HealthAction.None)
: new HealthLine(false, Loc.Plural("Archive.Health.Duplicates", h.DuplicateFrames), HealthAction.Duplicates),
Duplicates(h.DuplicateFrames, duplicateGroups),
];
}
private static HealthLine Duplicates(long flagged, int? groups) => groups switch
{
0 => new HealthLine(true, Loc.L("Archive.Health.NoDuplicates"), HealthAction.None),
{ } found => new HealthLine(false, Loc.Plural("Archive.Health.DuplicateGroups", found), HealthAction.MarkDuplicates),
null when flagged == 0 => new HealthLine(true, Loc.L("Archive.Health.NoneFlagged"), HealthAction.None),
null => new HealthLine(false, Loc.Plural("Archive.Health.Duplicates", flagged), HealthAction.Duplicates),
};
private static IReadOnlyList<BarValue> Shares(List<(string Name, long Photos)> ranked, int top, Func<int, string> restLabel, long total)
{
var bars = new List<BarValue>(top + 1);
+15 -6
View File
@@ -24,8 +24,18 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
public string ToggleToolTip => Loc.L(Node.IsExpanded ? "Tooltips.Archive.Collapse" : "Tooltips.Archive.Expand");
/// <summary>The row's figures; a year also says how the keyboard opens and closes it.</summary>
public string RowToolTip => IsYear ? Loc.L("Tooltips.Archive.YearRow", Detail) : Detail;
/// <summary>
/// The full title (the tree trims it) and its figures; a year also says how the keyboard opens and closes it, with
/// the arrow keys swapped in a right-to-left layout.
/// </summary>
public string RowToolTip
{
get
{
var text = Title + " · " + Detail;
return IsYear ? Loc.L(Loc.IsRightToLeft ? "Tooltips.Archive.YearRowRtl" : "Tooltips.Archive.YearRow", text) : text;
}
}
public ICommand ToggleCommand { get; } = new RelayCommand(() => toggle(node));
@@ -42,12 +52,12 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab
public string AvailabilityToolTip => Loc.L("Tooltips.Archive.Availability." + availability);
}
/// <summary>A line of "Index health" with its fix.</summary>
/// <summary>A line of "Index health" with its fix: ● ok or ▲ needs attention.</summary>
public sealed class HealthLineViewModel(HealthLine line, ICommand? fix) : ObservableObject
{
public HealthLine Line { get; } = line;
public string Text => Line.Text;
public StatusKind Kind => Line.IsOk ? StatusKind.Done : StatusKind.Warning;
public bool IsOk => Line.IsOk;
public string KindToolTip => Loc.L(Line.IsOk ? "Tooltips.Archive.HealthOk" : "Tooltips.Archive.HealthWarning");
public bool HasFix => FixCommand is not null && Line.Action != HealthAction.None;
public ICommand? FixCommand { get; } = fix;
@@ -64,11 +74,10 @@ public sealed class DuplicateRowViewModel(DuplicateRow row, ICommand open, IComm
public ICommand RevealCommand { get; } = reveal;
}
/// <summary>An orphan line with its fix (index, reconcile, remove the row, scan).</summary>
/// <summary>An orphan line with its fix (index, reconcile, remove the row, scan); every kind is a ▲ warning the fix resolves.</summary>
public sealed class OrphanRowViewModel(OrphanRow row, ICommand fix) : ObservableObject
{
public OrphanRow Row { get; } = row;
public StatusKind Kind => Row.Kind is OrphanKind.MissingFiles or OrphanKind.MissingSequence ? StatusKind.Warning : StatusKind.Queued;
public string KindText => Loc.L("Archive.Orphans.Kind." + Row.Kind);
public ICommand FixCommand { get; } = fix;
public string FixText => Loc.L("Archive.Orphans.Fix." + Row.Kind);
@@ -88,7 +88,7 @@ public sealed class DeleteDialogViewModel : ArchiveDialogViewModel
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Delete dry run failed", ex);
_shell.Notify(Loc.L("Archive.Delete.Failed"), ex.Message);
_shell.Notify(Loc.L("Archive.Delete.Failed"), ArchiveFailures.Cause(ex));
return null;
}
}
@@ -124,7 +124,7 @@ public sealed class DeleteDialogViewModel : ArchiveDialogViewModel
await SequenceDeletion.RefreshAsync(_shell);
var undo = moved.Count == 0 ? null : new AsyncRelayCommand(() => SequenceDeletion.RestoreAsync(_shell, moved));
if (failure is not null)
_shell.Notify(Loc.L("Archive.Delete.Failed"), failure.Message, undo is null ? null : Loc.L("Archive.Delete.Undo"), Loc.L("Tooltips.Archive.DeleteUndo"),
_shell.Notify(Loc.L("Archive.Delete.Failed"), ArchiveFailures.Cause(failure), undo is null ? null : Loc.L("Archive.Delete.Undo"), Loc.L("Tooltips.Archive.DeleteUndo"),
undo is null ? null : () => undo.Execute(null));
else if (moved.Count > 0)
_shell.Notify(Loc.Plural("Archive.Delete.Done", moved.Count), Loc.L("Archive.Delete.Kept"), Loc.L("Archive.Delete.Undo"),
+26 -6
View File
@@ -4,6 +4,7 @@ using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Archiving;
using Titano.Data.Repositories;
using Titano.Ui.Controls;
namespace Titano.App.Archiving;
@@ -30,11 +31,26 @@ public enum OrphanKind
public sealed record OrphanRow(OrphanKind Kind, string Title, string Detail, Guid? SequenceId);
/// <summary>A line of "Recent maintenance": date, operation and outcome.</summary>
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State);
public sealed record MaintenanceRow(Guid JobId, string DateText, string Text, string StateText, JobState State)
{
/// <summary>The outcome's glyph and colour, as on the Jobs screen (paired with the word, never colour alone).</summary>
public StatusKind StateKind => State switch
{
JobState.Running => StatusKind.Running,
JobState.Queued => StatusKind.Queued,
JobState.Paused => StatusKind.Paused,
JobState.Done => StatusKind.Done,
JobState.Failed => StatusKind.Failed,
_ => StatusKind.Offline,
};
public string StateToolTip => Loc.L("Tooltips.Jobs.State." + State);
}
/// <summary>
/// The Maintenance view's reports (BRIEF §12.5): duplicates across sequences, orphans with their safe fixes, and the
/// recent archive jobs. Nothing here deletes a file; the only removal is of index rows whose sidecar is gone.
/// recent archive jobs. Nothing here deletes a file; the only removal is of index rows whose sidecar is gone. Folders
/// and paths are kept left to right inside right-to-left text (BRIEF §16).
/// </summary>
public static class MaintenanceReports
{
@@ -50,7 +66,8 @@ public static class MaintenanceReports
{
var first = g.Frames[0];
var name = first.RelativePath[(first.RelativePath.LastIndexOf('/') + 1)..];
var places = g.Frames.Select(f => Loc.L("Archive.Duplicates.Place", titles.GetValueOrDefault(f.SequenceId, f.RelativePath), f.RelativePath)).ToList();
var places = g.Frames.Select(f => Loc.L("Archive.Duplicates.Place", titles.GetValueOrDefault(f.SequenceId, f.RelativePath),
Formatting.LeftToRight(f.RelativePath))).ToList();
return new DuplicateRow(name, Loc.Plural("Archive.Duplicates.Copies", g.Frames.Count), places, first.SequenceId);
}),
];
@@ -63,16 +80,19 @@ public static class MaintenanceReports
foreach (var s in report.Sequences)
{
byFolder.TryGetValue(s.Folder, out var location);
var title = location?.Title ?? s.Folder;
var title = location?.Title ?? Formatting.LeftToRight(s.Folder);
if (s.UnindexedFiles.Count > 0)
rows.Add(new OrphanRow(OrphanKind.UnlistedFiles, title, Loc.Plural("Archive.Orphans.Unlisted", s.UnindexedFiles.Count), location?.Id));
if (s.MissingFiles.Count > 0)
rows.Add(new OrphanRow(OrphanKind.MissingFiles, title, Loc.Plural("Archive.Orphans.Missing", s.MissingFiles.Count), location?.Id));
}
foreach (var missing in report.MissingSequences)
rows.Add(new OrphanRow(OrphanKind.MissingSequence, missing.Title ?? missing.Folder, Loc.L("Archive.Orphans.NoSidecar", missing.Folder), missing.Id));
{
var folder = Formatting.LeftToRight(missing.Folder);
rows.Add(new OrphanRow(OrphanKind.MissingSequence, missing.Title ?? folder, Loc.L("Archive.Orphans.NoSidecar", folder), missing.Id));
}
foreach (var folder in report.UnindexedFolders)
rows.Add(new OrphanRow(OrphanKind.NewFolder, folder.Length == 0 ? "/" : folder, Loc.L("Archive.Orphans.NewFolder"), null));
rows.Add(new OrphanRow(OrphanKind.NewFolder, Formatting.LeftToRight(folder.Length == 0 ? "/" : folder), Loc.L("Archive.Orphans.NewFolder"), null));
return rows;
}
+4 -3
View File
@@ -1,5 +1,6 @@
using System.IO;
using Titano.App.Shell;
using Titano.Core.Archiving;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data;
@@ -24,11 +25,11 @@ public static class SequenceDeletion
}
shell.Notify(Loc.Plural("Archive.Trash.Restored", restored));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or InvalidOperationException or ArgumentException
or DatabaseException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or SequenceInLibraryException or NewerFormatException
or ArgumentException or DatabaseException)
{
Log.Warning("archive", "Restore from the trash failed", ex);
shell.Notify(Loc.L("Archive.Trash.Failed"), ex.Message);
shell.Notify(Loc.L("Archive.Trash.Failed"), ArchiveFailures.Cause(ex));
}
await RefreshAsync(shell);
}
+14 -7
View File
@@ -1,6 +1,7 @@
using System.IO;
using System.Windows.Input;
using Titano.App.Infrastructure;
using Titano.Core.Archiving;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data;
@@ -15,8 +16,8 @@ public sealed class TrashRowViewModel(TrashEntry entry, ICommand restore)
public TrashEntry Entry { get; } = entry;
public string Title => Entry.Title;
/// <summary>"3,600 photos · 96.2 GB · 2026/2026-09-28 Canon EOS R5".</summary>
public string Detail => string.Join(" · ", Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Entry.Folder);
/// <summary>"3,600 photos · 96.2 GB · 2026/2026-09-28 Canon EOS R5" (the folder left to right in every language).</summary>
public string Detail => string.Join(" · ", Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Formatting.LeftToRight(Entry.Folder));
/// <summary>"Deleted 02/10/2026 18:04".</summary>
public string DeletedText => Loc.L("Archive.Trash.Deleted", Formatting.Date(Entry.DeletedAt) + " " + Formatting.TimeOfDay(Entry.DeletedAt));
@@ -69,17 +70,21 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
/// <summary>Reads the trash of the archive (off the UI thread).</summary>
public async Task LoadAsync()
{
ClearError();
BusyText = Loc.L("Archive.Trash.Reading");
try
{
var entries = await Task.Run(() => _archives.ListTrashAsync(_archive.Id));
Rows = [.. entries.Select(e => new TrashRowViewModel(e, new AsyncRelayCommand(() => RestoreAsync(e), () => !IsBusy)))];
BusyText = null;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or ArgumentException)
{
Log.Warning("archive", "Reading the trash failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
BusyText = null;
}
}
@@ -89,6 +94,7 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
private async Task RestoreAsync(TrashEntry entry)
{
ClearError();
IsBusy = true;
BusyText = Loc.L("Archive.Trash.Restoring", entry.Title);
try
@@ -99,15 +105,16 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel
BusyText = null;
await _restored();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or InvalidOperationException or DatabaseException
or ArgumentException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or SequenceInLibraryException or NewerFormatException
or DatabaseException or ArgumentException)
{
Log.Warning("archive", $"Restoring {entry.Title} failed", ex);
BusyText = ex.Message;
ShowError(ex);
}
finally
{
IsBusy = false;
BusyText = null;
}
}
}
+7 -10
View File
@@ -1,21 +1,22 @@
using System.Globalization;
using System.Windows;
using Titano.Core.Localization;
using Titano.Ui.Controls;
namespace Titano.App.Infrastructure;
/// <summary>Switches the UI language at run time without restart (BRIEF §16), mirroring right-to-left languages.</summary>
/// <summary>
/// Switches the UI language at run time without restart (BRIEF §16). A <see cref="TitanoWindow"/> takes the
/// language's direction when it is created and follows each switch, so right-to-left languages mirror windows opened
/// before and after this call alike; plain windows (the full-screen preview) take it when they load.
/// </summary>
public static class UiLanguage
{
static UiLanguage()
{
// Windows created later (the main window at start, every dialog) take the reading direction when they load.
EventManager.RegisterClassHandler(typeof(Window), FrameworkElement.LoadedEvent, new RoutedEventHandler((sender, _) => ((Window)sender).FlowDirection = Direction));
EventManager.RegisterClassHandler(typeof(Window), FrameworkElement.LoadedEvent, new RoutedEventHandler((sender, _) => ((Window)sender).FlowDirection = Bidi.UiDirection));
}
/// <summary>The reading direction of the current language.</summary>
public static FlowDirection Direction => Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
/// <summary>Applies <paramref name="code"/> (or the OS language when null) and returns the culture in use.</summary>
public static CultureInfo Apply(string? code)
{
@@ -32,10 +33,6 @@ public static class UiLanguage
CultureInfo.DefaultThreadCurrentUICulture = culture;
CultureInfo.CurrentUICulture = culture;
Loc.SetCulture(culture);
if (Application.Current is { } app)
{
foreach (Window window in app.Windows) window.FlowDirection = Direction;
}
return culture;
}
}
+2 -1
View File
@@ -1,5 +1,6 @@
using System.IO;
using System.Net.Http;
using Titano.App.Archiving;
using Titano.App.Jobs;
using Titano.App.Server;
using Titano.App.Shell;
@@ -168,7 +169,7 @@ public sealed class LibraryActions(ShellViewModel shell)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or ArgumentException or DatabaseException)
{
Log.Warning("library", "Rating failed", ex);
shell.Notify(Loc.L("Library.Rate.Failed"), ex.Message);
shell.Notify(Loc.L("Library.Rate.Failed"), ArchiveFailures.Cause(ex));
}
return changed;
}
+1 -2
View File
@@ -9,8 +9,7 @@
<Border Style="{StaticResource Border.Panel}" Padding="28,24" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="600">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,22">
<!-- The mark keeps its clockwise ring and its sun on the right in every reading direction. -->
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" FlowDirection="LeftToRight" />
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" />
<StackPanel Margin="16,0,0,0" VerticalAlignment="Center">
<TextBlock Text="{l:Loc Shell.AppName}" Style="{StaticResource Text.PageTitle}" FontSize="22" />
<TextBlock Text="{Binding Version}" Style="{StaticResource Text.Secondary}" Margin="0,2,0,0" Typography.NumeralAlignment="Tabular" />
+132 -61
View File
@@ -5,12 +5,44 @@
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:ar="clr-namespace:Titano.App.Archiving"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:shell="clr-namespace:Titano.App.Shell">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- The dialogs (and their styles) are shared with the Library, which runs Delete… too. -->
<ResourceDictionary Source="pack://application:,,,/Titano;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Keyboard focus drawn inside the row (DESIGN §4 ring): an outer ring would be clipped by the list's scroll viewer. -->
<Style x:Key="Focus.Inset">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="{DynamicResource Brush.Accent}" BorderThickness="2" CornerRadius="{StaticResource Radius.Control}" SnapsToDevicePixels="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
Lists keep their panel's fill while the screen behind a dialog is disabled: the system template would paint them
white. Rows and buttons dim themselves.
-->
<Style TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"
Padding="1" SnapsToDevicePixels="True">
<ScrollViewer Focusable="False" Padding="{TemplateBinding Padding}">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="Text.PanelHeading" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}">
<Setter Property="FontSize" Value="13" />
<Setter Property="VerticalAlignment" Value="Center" />
@@ -25,6 +57,7 @@
<!-- Report rows with their own buttons: Tab reaches every button. -->
<Style x:Key="ListBoxItem.Duplicate" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Row.Detail}" />
</Style>
<!-- A filter menu: its values, each checked while chosen. -->
<Style x:Key="MenuItem.Choice" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
@@ -58,10 +91,10 @@
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Duplicates}" Command="{Binding FindDuplicatesCommand}"
ToolTip="{Binding DuplicatesToolTip}" />
<Button Style="{StaticResource Button.Tool}" Content="{l:Loc Archive.Toolbar.Orphans}" Command="{Binding FindOrphansCommand}" ToolTip="{Binding OrphansToolTip}" />
<Button Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Adopt}">
<Button Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Adopt}" AutomationProperties.Name="{l:Loc Archive.Toolbar.AdoptMenu}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Archive.Toolbar.AdoptMenu}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
@@ -70,10 +103,11 @@
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button x:Name="MaintenanceButton" Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Maintenance}">
<Button x:Name="MaintenanceButton" Style="{StaticResource Button.Tool}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Maintenance}"
AutomationProperties.Name="{l:Loc Archive.Toolbar.Maintenance}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Archive.Toolbar.Maintenance}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
@@ -94,8 +128,7 @@
<DockPanel Grid.Row="1" Margin="0,0,0,12" Visibility="{Binding HasArchive, Converter={StaticResource BoolToVisibility}}">
<v:SegmentedControl DockPanel.Dock="Left" SelectedIndex="{Binding ViewIndex}" AutomationProperties.Name="{l:Loc Archive.View.Name}">
<v:SegmentedItem Content="{l:Loc Archive.View.Overview}" ToolTip="{l:Loc Tooltips.Archive.Overview}" AutomationProperties.Name="{l:Loc Archive.View.Overview}" />
<v:SegmentedItem Content="{l:Loc Archive.View.Maintenance}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceView}"
AutomationProperties.Name="{l:Loc Archive.View.Maintenance}" />
<v:SegmentedItem Content="{l:Loc Archive.View.Health}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceView}" AutomationProperties.Name="{l:Loc Archive.View.Health}" />
</v:SegmentedControl>
<TextBlock Text="{Binding LastScanText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="14,0,0,0"
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{l:Loc Tooltips.Archive.LastScan}" />
@@ -115,6 +148,7 @@
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="MinHeight" Value="32" />
<Setter Property="Padding" Value="6,0" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="ToolTip" Value="{Binding RowToolTip}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
<Setter Property="AutomationProperties.HelpText" Value="{Binding Detail}" />
@@ -160,13 +194,28 @@
</Border>
<Grid Grid.Column="2">
<!--
Chart labels in TextMuted as in Archive.html: the kit's charts draw them in TextFaint, too faint for 11 px data
labels (reported to the shared controls; remove this alias once they draw in TextMuted).
-->
<Grid.Resources>
<SolidColorBrush x:Key="Brush.TextFaint" Color="{DynamicResource Color.TextMuted}" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="14" />
<RowDefinition Height="*" />
<RowDefinition Height="14" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- One column split for both chart rows, so the gutter lines up; 14 px gaps throughout (Archive.html). -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" />
<ColumnDefinition Width="14" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Figure tiles (Archive.html). -->
<ItemsControl ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-10,0">
<ItemsControl Grid.ColumnSpan="3" ItemsSource="{Binding Tiles}" Focusable="False" Margin="0,0,-14,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1" />
@@ -174,7 +223,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type ar:ArchiveTile}">
<Border Style="{StaticResource Border.Panel}" Padding="14,8" Margin="0,0,10,0" ToolTip="{Binding Caption}">
<Border Style="{StaticResource Border.Panel}" Padding="14,8" Margin="0,0,14,0" ToolTip="{Binding Caption}">
<StackPanel>
<!-- A narrow tile (the window at its minimum width) shrinks the figure rather than cutting it. -->
<Viewbox StretchDirection="DownOnly" HorizontalAlignment="Left">
@@ -187,49 +236,59 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid Grid.Row="1" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.2*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Months}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:HeatmapStrip Rows="{Binding MonthRows}" ColumnLabels="{Binding MonthLabels}" ValueFormatter="{Binding CountFormatter}" MaxCellSize="18"
ToolTip="{l:Loc Tooltips.Archive.Months}" AutomationProperties.Name="{l:Loc Archive.Chart.Months}" />
<Border Grid.Row="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<!-- The colour scale sits in the header, at the end of the title (Archive.html). -->
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" FlowDirection="LeftToRight" VerticalAlignment="Center"
Visibility="{Binding HasMonthScale, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding MonthScaleLow}" Style="{StaticResource Text.Chip}" Typography.NumeralAlignment="Tabular" />
<Grid Width="60" Height="8" Margin="6,0">
<Border CornerRadius="2" Background="{DynamicResource Brush.Accent}" Opacity="0.08" />
<Border CornerRadius="2" Background="{DynamicResource Brush.Accent}">
<Border.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="Transparent" Offset="0" />
<GradientStop Color="Black" Offset="1" />
</LinearGradientBrush>
</Border.OpacityMask>
</Border>
</Grid>
<TextBlock Text="{Binding MonthScaleHigh}" Style="{StaticResource Text.Chip}" Typography.NumeralAlignment="Tabular" />
</StackPanel>
<TextBlock Text="{l:Loc Archive.Chart.Months}" Style="{StaticResource Text.PanelHeading}" />
</DockPanel>
</Border>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Storage}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding StorageBars}" MinimumOpacity="0.55" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Storage}"
AutomationProperties.Name="{l:Loc Archive.Chart.Storage}" />
</DockPanel>
</Border>
</Grid>
<Grid Grid.Row="2" Margin="0,12,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Cameras}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding CameraBars}" BrushKey="Brush.Sun" MinimumOpacity="0.45" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Cameras}"
AutomationProperties.Name="{l:Loc Archive.Chart.Cameras}" />
</DockPanel>
</Border>
<Border Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Formats}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding FormatBars}" MinimumOpacity="0.35" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Formats}"
AutomationProperties.Name="{l:Loc Archive.Chart.Formats}" />
</DockPanel>
</Border>
</Grid>
<v:HeatmapStrip Rows="{Binding MonthRows}" ColumnLabels="{Binding MonthLabels}" ValueFormatter="{Binding CountFormatter}" MaxCellSize="32" ShowScale="False"
ToolTip="{l:Loc Tooltips.Archive.Months}" AutomationProperties.Name="{l:Loc Archive.Chart.Months}"
AutomationProperties.HelpText="{Binding MonthsDescription}">
<!-- Months still to come in the Stroke tone: the kit fills them with Card, the panel's own colour in the light theme. -->
<v:HeatmapStrip.Resources>
<SolidColorBrush x:Key="Brush.Card" Color="{DynamicResource Color.Stroke}" />
</v:HeatmapStrip.Resources>
</v:HeatmapStrip>
</DockPanel>
</Border>
<Border Grid.Row="2" Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Storage}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding StorageBars}" MinimumOpacity="0.55" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Storage}"
AutomationProperties.Name="{l:Loc Archive.Chart.Storage}" AutomationProperties.HelpText="{Binding StorageDescription}" />
</DockPanel>
</Border>
<Border Grid.Row="4" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Cameras}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding CameraBars}" BrushKey="Brush.Sun" MinimumOpacity="0.45" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Cameras}"
AutomationProperties.Name="{l:Loc Archive.Chart.Cameras}" AutomationProperties.HelpText="{Binding CamerasDescription}" />
</DockPanel>
</Border>
<Border Grid.Row="4" Grid.Column="2" Style="{StaticResource Border.Panel}" Padding="14,10">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Archive.Chart.Formats}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<v:BarChart Items="{Binding FormatBars}" MinimumOpacity="0.35" BarThickness="12" ToolTip="{l:Loc Tooltips.Archive.Formats}"
AutomationProperties.Name="{l:Loc Archive.Chart.Formats}" AutomationProperties.HelpText="{Binding FormatsDescription}" />
</DockPanel>
</Border>
</Grid>
</Grid>
@@ -250,12 +309,21 @@
<TextBlock Text="{l:Loc Archive.Health.Title}" Style="{StaticResource Text.PanelHeading}" Margin="0,0,0,8" />
<ItemsControl ItemsSource="{Binding Health}" Focusable="False">
<ItemsControl.ItemTemplate>
<!-- Archive.html: a 14 px glyph in the state's colour (● ok, ▲ needs attention), the text in the normal colour. -->
<DataTemplate DataType="{x:Type ar:HealthLineViewModel}">
<DockPanel Height="32">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{Binding FixText}" Command="{Binding FixCommand}"
ToolTip="{Binding FixToolTip}" Visibility="{Binding HasFix, Converter={StaticResource BoolToVisibility}}" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" FontSize="13" VerticalAlignment="Center" ToolTip="{Binding KindToolTip}" />
<ui:Icon x:Name="Glyph" DockPanel.Dock="Left" Glyph="{StaticResource Icon.Warning}" Size="14" Margin="0,0,10,0" VerticalAlignment="Center"
Foreground="{DynamicResource Brush.Warning}" />
<TextBlock Text="{Binding Text}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding KindToolTip}" />
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsOk}" Value="True">
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.SuccessCircle}" />
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.Success}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -281,7 +349,9 @@
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding DateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<TextBlock Grid.Column="1" Text="{Binding Text}" Margin="12,0" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding Text}" />
<TextBlock Grid.Column="2" Text="{Binding StateText}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
<!-- The outcome in its state's colour and glyph (Archive.html: accent while running, green when done). -->
<ui:StatusGlyph Grid.Column="2" Kind="{Binding StateKind}" Text="{Binding StateText}" FontSize="12" VerticalAlignment="Center"
Typography.NumeralAlignment="Tabular" ToolTip="{Binding StateToolTip}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -300,12 +370,13 @@
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="8,0,0,0" Content="{l:Loc Archive.Duplicates.Mark}"
Command="{Binding MarkDuplicatesCommand}" ToolTip="{Binding MarkDuplicatesToolTip}" />
<!-- Cancel only in the card whose search runs; the other card's Find waits, its tooltip says why. -->
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Run}" Command="{Binding FindDuplicatesCommand}"
ToolTip="{Binding DuplicatesToolTip}" Visibility="{Binding IsSearching, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
ToolTip="{Binding DuplicatesToolTip}" Visibility="{Binding IsFindingDuplicates, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Cancel}" Command="{Binding CancelSearchCommand}"
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsSearching, Converter={StaticResource BoolToVisibility}}" />
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsFindingDuplicates, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Duplicates.Title}" Style="{StaticResource Text.PanelHeading}" />
<TextBlock Text="{Binding DuplicatesText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding DuplicatesText}" infra:LiveRegion.Text="{Binding DuplicatesText}" Margin="10,0,0,0" />
</DockPanel>
<ListBox ItemsSource="{Binding Duplicates}" ItemContainerStyle="{StaticResource ListBoxItem.Duplicate}" AutomationProperties.Name="{l:Loc Archive.Duplicates.Title}"
KeyboardNavigation.TabNavigation="Continue">
@@ -333,11 +404,11 @@
<DockPanel>
<DockPanel DockPanel.Dock="Top" Margin="0,0,0,8">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Run}" Command="{Binding FindOrphansCommand}"
ToolTip="{Binding OrphansToolTip}" Visibility="{Binding IsSearching, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
ToolTip="{Binding OrphansToolTip}" Visibility="{Binding IsFindingOrphans, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Margin="0" Content="{l:Loc Archive.Find.Cancel}" Command="{Binding CancelSearchCommand}"
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsSearching, Converter={StaticResource BoolToVisibility}}" />
ToolTip="{l:Loc Tooltips.Archive.CancelSearch}" Visibility="{Binding IsFindingOrphans, Converter={StaticResource BoolToVisibility}}" />
<TextBlock Text="{l:Loc Archive.Orphans.Title}" Style="{StaticResource Text.PanelHeading}" />
<TextBlock Text="{Binding OrphansText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="10,0,0,0" VerticalAlignment="Center" />
<TextBlock Style="{StaticResource Text.Live}" Text="{Binding OrphansText}" infra:LiveRegion.Text="{Binding OrphansText}" Margin="10,0,0,0" />
</DockPanel>
<ListBox ItemsSource="{Binding Orphans}" ItemContainerStyle="{StaticResource ListBoxItem.Duplicate}" AutomationProperties.Name="{l:Loc Archive.Orphans.Title}"
KeyboardNavigation.TabNavigation="Continue">
@@ -347,7 +418,7 @@
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Content="{Binding FixText}" Command="{Binding FixCommand}" ToolTip="{Binding FixToolTip}" />
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Row.Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" ToolTip="{Binding Row.Title}" />
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
<ui:StatusGlyph Kind="Warning" Text="{Binding Row.Detail}" FontSize="12" ToolTip="{Binding KindText}" />
</StackPanel>
</DockPanel>
</DataTemplate>
@@ -370,10 +441,10 @@
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="{l:Loc Archive.Set.Label}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="0,0,10,8" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" BorderBrush="{DynamicResource Brush.Accent}" Click="OnOpenMenu" ToolTip="{l:Loc Tooltips.Archive.Set}"
AutomationProperties.Name="{l:Loc Archive.Set.Filter}">
AutomationProperties.Name="{Binding SetFilterName}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding SetText}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" MaxWidth="260" TextTrimming="CharacterEllipsis" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" VerticalAlignment="Center" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu>
+36 -12
View File
@@ -3,6 +3,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Archiving;
@@ -12,6 +13,7 @@ public partial class ArchiveView : UserControl
{
private bool _restoring;
private string? _focusKey;
private IInputElement? _beforeDialog;
public ArchiveView()
{
@@ -79,26 +81,48 @@ public partial class ArchiveView : UserControl
});
}
/// <summary>On a year: Right opens it, Left closes it, Enter toggles it.</summary>
private void OnTreeKeyDown(object sender, KeyEventArgs e)
{
if (Model is not { } model || Keyboard.FocusedElement is not ListBoxItem { DataContext: ArchiveTreeRowViewModel row } || !row.HasChildren || row.IsArchive) return;
var toggle = e.Key switch
{
Key.Right => !row.IsExpanded,
Key.Left => row.IsExpanded,
Key.Enter => true,
_ => false,
};
if (!toggle) return;
if (!Toggles(e.Key, Tree.FlowDirection, row.IsExpanded)) return;
model.Toggle(row);
e.Handled = true;
}
/// <summary>A dialog that opens takes the keyboard: its first field or button.</summary>
/// <summary>
/// Whether <paramref name="key"/> opens or closes a year: the arrow towards the indented side opens it (Right, or
/// Left in a right-to-left layout, as a tree view does), the other arrow closes it, Enter toggles it.
/// </summary>
internal static bool Toggles(Key key, FlowDirection direction, bool isExpanded)
{
var (open, close) = direction == FlowDirection.RightToLeft ? (Key.Left, Key.Right) : (Key.Right, Key.Left);
return key == open ? !isExpanded
: key == close ? isExpanded
: key == Key.Enter;
}
/// <summary>
/// A dialog that opens takes the keyboard (its first field or button); when it closes, the keyboard goes back to the
/// control that opened it, or to the tree when that control can no longer take it.
/// </summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(ArchiveViewModel.Dialog) || Model?.Dialog is null || !IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
if (e.PropertyName != nameof(ArchiveViewModel.Dialog) || Model is not { } model) return;
if (model.Dialog is not null)
{
if (!IsVisible) return;
// Raised before the screen behind the dialog is disabled: the control that opened it still has the keyboard.
_beforeDialog ??= Keyboard.FocusedElement is Visual focused && IsAncestorOf(focused) ? Keyboard.FocusedElement : null;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
return;
}
var back = _beforeDialog;
_beforeDialog = null;
if (!IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () =>
{
if (back is UIElement { IsVisible: true, IsEnabled: true, Focusable: true } element && element.Focus()) return;
Tree.Focus();
});
}
}
+59 -18
View File
@@ -47,6 +47,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private Core.Model.Archive? _archive;
private ArchiveAvailability _availability = ArchiveAvailability.Offline;
private ArchiveStats? _stats;
private int _withoutProxies;
private ArchiveTree? _tree;
private int _viewIndex;
private bool _loaded;
@@ -129,7 +130,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public bool HasArchive => _archive is not null;
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", _archive.RootPath);
public string ArchiveToolTip => _archive is null ? Loc.L("Tooltips.Archive.Pick") : Loc.L("Tooltips.Archive.PickRoot", Formatting.LeftToRight(_archive.RootPath));
/// <summary>0 = overview (tree and figures), 1 = maintenance.</summary>
public int ViewIndex
@@ -171,7 +172,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public ICommand VerifyCommand { get; }
public ICommand AdoptCommand { get; }
/// <summary>"Adopt folder ▾ › Copy into the layout": the Import screen copies the folder into the archive with its templates.</summary>
/// <summary>"Adopt folder ▾ › Copy into archive": the Import screen copies the folder into the archive with its templates.</summary>
public ICommand CopyFolderCommand { get; }
public ICommand BackupCommand { get; }
@@ -195,6 +196,20 @@ public sealed class ArchiveViewModel : SectionViewModel
public IReadOnlyList<ChartItem> CameraBars { get => _cameras; private set => Set(ref _cameras, value); }
public IReadOnlyList<ChartItem> FormatBars { get => _formats; private set => Set(ref _formats, value); }
/// <summary>The heatmap's scale in the card header (Archive.html: "0 ▭ 21,000"); hidden without photos.</summary>
public bool HasMonthScale => MonthScaleMax > 0;
public string MonthScaleLow => Formatting.Count(0);
public string MonthScaleHigh => Formatting.Count((long)MonthScaleMax);
private double MonthScaleMax => _months.SelectMany(r => r.Values).Where(double.IsFinite).DefaultIfEmpty(0).Max();
/// <summary>What each chart shows, value by value, for screen readers (the charts themselves are images).</summary>
public string MonthsDescription => Describe(_months.SelectMany(r => r.Values.Select((photos, month) => photos > 0 ? r.ToolTips?[month] : null)));
public string StorageDescription => Describe(_storage.Select(b => b.ToolTip));
public string CamerasDescription => Describe(_cameras.Select(b => b.ToolTip));
public string FormatsDescription => Describe(_formats.Select(b => b.ToolTip));
/// <summary>Photos per month in the culture's digits.</summary>
public Func<double, string> CountFormatter { get; } = v => Formatting.Count((long)v);
@@ -212,6 +227,9 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>The set button's accessible name: what it is and the set it shows.</summary>
public string SetFilterName => Loc.L("Archive.Set.Filter") + " · " + SetText;
/// <summary>Camera, status and tag on top of the tree selection.</summary>
public ArchiveSetFilter Filter
{
@@ -286,7 +304,9 @@ public sealed class ArchiveViewModel : SectionViewModel
get => _duplicates;
private set
{
if (Set(ref _duplicates, value)) OnPropertyChanged(nameof(DuplicatesText));
if (!Set(ref _duplicates, value)) return;
OnPropertyChanged(nameof(DuplicatesText));
ShowHealth();
}
}
@@ -299,8 +319,11 @@ public sealed class ArchiveViewModel : SectionViewModel
}
}
/// <summary>A duplicates or orphans search runs; it can be cancelled.</summary>
public bool IsSearching => _search is not null;
/// <summary>The duplicates search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingDuplicates => _findingDuplicates;
/// <summary>The orphans search runs: its card offers Cancel; the other card's Find waits for it.</summary>
public bool IsFindingOrphans => _findingOrphans;
/// <summary>"3 groups", "None found", or empty before the first search.</summary>
public string DuplicatesText => _findingDuplicates ? Loc.L("Archive.Find.Searching")
@@ -428,19 +451,28 @@ public sealed class ArchiveViewModel : SectionViewModel
private void ShowFigures(ArchiveStats stats, int withoutProxies)
{
_withoutProxies = withoutProxies;
Tiles = ArchiveFigures.Tiles(stats);
MonthRows = [.. ArchiveFigures.PhotosPerMonth(stats, DateTime.Today).Select(r => new ChartRow(r.Label, r.Values, r.ToolTips))];
StorageBars = Bars(ArchiveFigures.StorageByYear(stats));
CameraBars = Bars(ArchiveFigures.ByCamera(stats));
FormatBars = Bars(ArchiveFigures.ByFormat(stats));
ShowHealth();
}
/// <summary>The health lines of the last figures; the duplicates line follows the last duplicates search.</summary>
private void ShowHealth()
{
if (_stats is not { } stats) return;
Health =
[
.. ArchiveFigures.Health(stats, withoutProxies).Select(line => new HealthLineViewModel(line, line.Action switch
.. ArchiveFigures.Health(stats, _withoutProxies, _duplicates?.Count).Select(line => new HealthLineViewModel(line, line.Action switch
{
HealthAction.Verify => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.Verified, ids => ArchiveJobs.Verify(_archive!, ids))),
HealthAction.Proxies => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.ProxiesBuilt, ids => ArchiveJobs.Proxies(ids, CountLabel(ids)))),
HealthAction.Analyse => new AsyncRelayCommand(() => QueueStatusAsync(SequenceStatus.AnalyzedLight, ids => ProcessingJobs.LightAnalysis(ids, CountLabel(ids)))),
HealthAction.Duplicates => FindDuplicatesCommand,
HealthAction.MarkDuplicates => MarkDuplicatesCommand,
HealthAction.Orphans => FindOrphansCommand,
_ => null,
})),
@@ -450,6 +482,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private static IReadOnlyList<ChartItem> Bars(IReadOnlyList<BarValue> values) =>
[.. values.Select(v => new ChartItem(v.Label, v.Value, v.ValueText, v.ToolTip))];
private static string Describe(IEnumerable<string?> values) => string.Join(Environment.NewLine, values.Where(v => !string.IsNullOrEmpty(v)));
/// <summary>A reloaded tree keeps the open years and the selection (nodes that still exist).</summary>
private void ShowTree(ArchiveTree tree)
{
@@ -498,6 +532,7 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSetChanged()
{
OnPropertyChanged(nameof(SetText));
OnPropertyChanged(nameof(SetFilterName));
OnPropertyChanged(nameof(CameraChoices));
OnPropertyChanged(nameof(StatusChoices));
OnPropertyChanged(nameof(TagChoices));
@@ -714,13 +749,13 @@ public sealed class ArchiveViewModel : SectionViewModel
try
{
var path = await db.BackupAsync(Services.Environment.BackupDirectory);
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Path.GetFileName(path), Loc.L("Library.Export.Show"), Loc.L("Tooltips.Library.ShowExport"),
() => ShellActions.Reveal(path));
Shell.Notify(Loc.L("Settings.Advanced.BackupDone"), Formatting.LeftToRight(Path.GetFileName(path)), Loc.L("Library.Export.Show"),
Loc.L("Tooltips.Library.ShowExport"), () => ShellActions.Reveal(path));
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or DatabaseException or NotSupportedException)
{
Log.Warning("archive", "Database backup failed", ex);
Shell.Notify(Loc.L("Archive.Backup.Failed"), ex.Message);
NotifyFailure("Archive.Backup.Failed", ex, BackupCommand);
}
}
@@ -737,13 +772,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Services.SaveSettings();
_archive = archive;
await Services.QueueScanAsync(archive, full: false);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), archive.RootPath);
Shell.Notify(Loc.L("Archive.Relink.Done", archive.Name), Formatting.LeftToRight(archive.RootPath));
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", $"Relinking {folder} failed", ex);
Shell.Notify(Loc.L("Archive.Relink.Failed"), ex.Message);
// Retry asks for the folder again: the same one once its drive is back, or the right one.
NotifyFailure("Archive.Relink.Failed", ex, RelinkCommand);
}
}
@@ -777,7 +813,8 @@ public sealed class ArchiveViewModel : SectionViewModel
}
catch (DatabaseException ex)
{
Shell.ReportError(ex);
Log.Warning("archive", "Duplicates search failed", ex);
NotifyFailure("Archive.Duplicates.Failed", ex, FindDuplicatesCommand);
}
finally
{
@@ -803,10 +840,10 @@ public sealed class ArchiveViewModel : SectionViewModel
catch (OperationCanceledException) when (search.IsCancellationRequested)
{
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException)
{
Log.Warning("archive", "Orphan search failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.Failed"), ex.Message);
NotifyFailure("Archive.Orphans.Failed", ex, FindOrphansCommand);
}
finally
{
@@ -831,7 +868,8 @@ public sealed class ArchiveViewModel : SectionViewModel
private void OnSearchChanged()
{
OnPropertyChanged(nameof(IsSearching));
OnPropertyChanged(nameof(IsFindingDuplicates));
OnPropertyChanged(nameof(IsFindingOrphans));
OnPropertyChanged(nameof(DuplicatesText));
OnPropertyChanged(nameof(OrphansText));
OnPropertyChanged(nameof(DuplicatesToolTip));
@@ -888,11 +926,14 @@ public sealed class ArchiveViewModel : SectionViewModel
Orphans = Orphans?.Where(o => o.Row != row).ToList();
await LoadAsync();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or ArchiveOfflineException or DatabaseException
or ArgumentException)
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or DatabaseException or ArgumentException)
{
Log.Warning("archive", $"Fixing {row.Title} failed", ex);
Shell.Notify(Loc.L("Archive.Orphans.FixFailed"), ex.Message);
NotifyFailure("Archive.Orphans.FixFailed", ex, new AsyncRelayCommand(() => FixAsync(row)));
}
}
/// <summary>An action stopped: what stopped, why in one sentence, and Retry to run it again (BRIEF §0.2 rule 6).</summary>
private void NotifyFailure(string titleKey, Exception ex, ICommand retry) =>
Shell.Notify(Loc.L(titleKey), ArchiveFailures.Cause(ex), Loc.L("Archive.Failed.Retry"), Loc.L("Tooltips.Archive.Retry"), () => retry.Execute(null));
}
+1 -4
View File
@@ -102,10 +102,7 @@
</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.
-->
<!-- Up to four digits (gap ≤ 1440) in 56 px: half the usual side padding. -->
<Style x:Key="TextBox.Small" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}">
<Setter Property="Width" Value="56" />
<Setter Property="Height" Value="30" />
+1 -1
View File
@@ -262,7 +262,7 @@ public sealed class JobsViewModel : SectionViewModel
private void UpdateShell()
{
if (_model.Current is { } current)
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null);
Shell.SetJob(JobText.Bar(current), current.Fraction ?? 0, indeterminate: current.Fraction is null, name: JobText.Name(current.Job));
else
Shell.SetJob(null, 0);
// The rail badge, the status strip and the Running chip count the same jobs: running or paused (Jobs.html).
+1 -1
View File
@@ -55,7 +55,7 @@
<DockPanel LastChildFill="True">
<ComboBox DockPanel.Dock="Right" VerticalAlignment="Top" MinWidth="120" ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage}"
DisplayMemberPath="Name" ToolTip="{l:Loc Tooltips.Welcome.Language}" AutomationProperties.Name="{l:Loc Settings.General.Language}" />
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" FlowDirection="LeftToRight" />
<ui:BrandMarkIcon Width="56" Height="56" ShowPlate="True" />
<StackPanel Margin="16,0,16,0" VerticalAlignment="Center">
<TextBlock Text="{l:Loc Shell.Welcome.Title}" FontSize="20" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{l:Loc Shell.Welcome.Question}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,4,0,0" TextTrimming="CharacterEllipsis" />
+5 -19
View File
@@ -43,8 +43,9 @@
<Setter Property="TextAlignment" Value="Right" />
</Style>
<!-- Log tail: monospaced, muted. -->
<!-- Log tail: monospaced, muted, left to right in every language (paths, times, codes). -->
<Style x:Key="Text.Log" TargetType="TextBlock">
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="FontFamily" Value="{StaticResource Font.Mono}" />
<Setter Property="FontSize" Value="12" />
<Setter Property="LineHeight" Value="18" />
@@ -89,7 +90,7 @@
<!-- Section list entry of Settings: 34 px, active = Card fill + 3 px accent edge (Settings.html). -->
<Style x:Key="ListBoxItem.Section" TargetType="ListBoxItem">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
<Setter Property="Height" Value="34" />
<Setter Property="Margin" Value="0,0,0,2" />
@@ -145,21 +146,6 @@
<Setter Property="Margin" Value="0,0,6,0" />
</Style>
<!-- "Auto · 8" pill (DESIGN §4 Auto/manual): accent outline, 24 px, 11 px text. -->
<Style x:Key="Button.AutoPill" TargetType="Button" BasedOn="{StaticResource Button.Base}">
<Setter Property="Height" Value="24" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Padding" Value="8,0" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.CornerRadius" Value="12" />
<Setter Property="ui:ControlState.HoverBackground" Value="{DynamicResource Brush.AccentSubtle}" />
<Setter Property="ui:ControlState.HoverBorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="ui:ControlState.PressedBackground" Value="{DynamicResource Brush.AccentSubtle}" />
</Style>
<!-- Toolbar dropdown (Library filters): accent border while a filter is active (bind Tag to the active flag). -->
<Style x:Key="ComboBox.Filter" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="MinWidth" Value="88" />
@@ -213,8 +199,8 @@
<Setter Property="VerticalContentAlignment" Value="Top" />
</Style>
<!-- Path and template fields in Settings (360 px, DESIGN mockup). -->
<Style x:Key="TextBox.Setting" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
<!-- Path, address and template fields in Settings (360 px, DESIGN mockup), left to right in every language. -->
<Style x:Key="TextBox.Setting" TargetType="TextBox" BasedOn="{StaticResource TextBox.Path}">
<Setter Property="Width" Value="360" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
+7 -4
View File
@@ -5,14 +5,17 @@
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
Title="{l:Loc Shell.AppName}"
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="460"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
<!-- DESIGN §4 dialog: two buttons, safe action left and default, the action on the right. -->
WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
AutomationProperties.Name="{Binding Heading}" AutomationProperties.HelpText="{Binding Message}">
<!-- DESIGN §4 dialog: two buttons, safe action left and default, the action on the right. Screen readers hear the
heading and the message as the dialog opens on the safe button. -->
<StackPanel Margin="24,18,24,20">
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" TextWrapping="Wrap" TextTrimming="None" />
<TextBlock Text="{Binding Message}" Margin="0,8,0,0" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18" />
<Border Style="{StaticResource Border.Card}" Margin="0,16,0,0" Padding="12,10" ToolTip="{Binding DetailToolTip}"
Visibility="{Binding Detail, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
<TextBlock x:Name="DetailText" Text="{Binding Detail}" FontFamily="{StaticResource Font.Mono}" FontSize="{StaticResource Size.Secondary}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18" />
<TextBlock x:Name="DetailText" Text="{Binding Detail}" FontFamily="{StaticResource Font.Mono}" FontSize="{StaticResource Size.Secondary}" TextWrapping="Wrap" TextTrimming="None" LineHeight="18"
FlowDirection="LeftToRight" />
</Border>
<StackPanel x:Name="Typing" Margin="0,16,0,0" Visibility="Collapsed">
<TextBlock Text="{Binding TypedPrompt}" Foreground="{DynamicResource Brush.TextMuted}" TextWrapping="Wrap" />
@@ -20,7 +23,7 @@
AutomationProperties.Name="{Binding TypedPrompt}" TextChanged="OnTyped" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,24,0,0">
<Button Content="{Binding SafeText}" ToolTip="{Binding SafeToolTip}" IsDefault="True" IsCancel="True" MinWidth="96" Click="OnSafe" />
<Button x:Name="Safe" Content="{Binding SafeText}" ToolTip="{Binding SafeToolTip}" IsDefault="True" IsCancel="True" MinWidth="96" Click="OnSafe" />
<Button x:Name="Action" Content="{Binding ActionText}" ToolTip="{Binding ActionToolTip}" MinWidth="96" Margin="8,0,0,0" Click="OnAction" />
</StackPanel>
</StackPanel>
+11 -2
View File
@@ -12,8 +12,17 @@ public sealed partial class ConfirmDialog : TitanoWindow
DataContext = request;
InitializeComponent();
Action.SetResourceReference(StyleProperty, request.IsDestructive ? "Button.Destructive" : "Button.Primary");
if (!request.IsDetailMonospaced) DetailText.SetResourceReference(FontFamilyProperty, "Font.Ui");
if (request.TypedConfirmation is null) return;
if (!request.IsDetailMonospaced)
{
// Names and sentences follow the reading direction; only fingerprints stay left to right.
DetailText.SetResourceReference(FontFamilyProperty, "Font.Ui");
DetailText.ClearValue(FlowDirectionProperty);
}
if (request.TypedConfirmation is null)
{
Loaded += (_, _) => Safe.Focus();
return;
}
Typing.Visibility = Visibility.Visible;
Loaded += (_, _) => Typed.Focus();
EnableAction(false);
+37
View File
@@ -0,0 +1,37 @@
using System.Reflection;
using Titano.Core.Archiving;
using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Core.Render;
using Titano.Data.Archiving;
using Titano.Data.Sync;
using Titano.Protocol.Client;
namespace Titano.App.Shell;
/// <summary>
/// The sentence an error toast shows (BRIEF §0.2: one sentence saying what happened plus one action). Only failures
/// that carry a catalog sentence say what happened; anything else (framework and OS messages, often technical
/// English) reads "Something went wrong." and stays in the log.
/// </summary>
public static class ErrorText
{
public static string For(Exception ex) => Describe(Unwrap(ex)) ?? Loc.L("Errors.Unexpected");
private static string? Describe(Exception ex) => ex switch
{
LeaseUnavailableException or ArchiveOfflineException or NewerFormatException or ImportSourceUnavailableException
or CopyVerificationException or StaleRenamePlanException or SyncConflictChangedException => ex.Message,
// The server words its errors in the client's language (Accept-Language).
TitanoApiException api when !string.IsNullOrWhiteSpace(api.Error.Message) => api.Error.Message,
RenderException render => Loc.Get(render.ReasonKey, Loc.Culture) is null ? null : Loc.L(render.ReasonKey, [.. render.Args]),
_ => null,
};
/// <summary>Awaited tasks and reflection wrap the real failure in one layer or more.</summary>
private static Exception Unwrap(Exception ex)
{
while (ex is AggregateException { InnerExceptions.Count: 1 } or TargetInvocationException && ex.InnerException is { } inner) ex = inner;
return ex;
}
}
+2 -2
View File
@@ -5,11 +5,11 @@
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
Title="{l:Loc Shell.AppName}"
IsDialog="True" ResizeMode="NoResize" SizeToContent="Height" Width="440"
WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
WindowStartupLocation="CenterOwner" ShowInTaskbar="False" AutomationProperties.Name="{l:Loc Server.Login.Title}">
<!-- BRIEF §12.7 login modal: the server is already identified and its certificate trusted. -->
<StackPanel Margin="24,18,24,20">
<TextBlock Text="{l:Loc Server.Login.Title}" Style="{StaticResource Text.Title}" />
<TextBlock x:Name="ServerText" Margin="0,4,0,0" Style="{StaticResource Text.Secondary}" />
<TextBlock x:Name="ServerText" Margin="0,4,0,0" Style="{StaticResource Text.Secondary}" FlowDirection="LeftToRight" HorizontalAlignment="Left" />
<Grid Margin="0,18,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="92" />
+8 -1
View File
@@ -1,4 +1,6 @@
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using Titano.Ui.Controls;
namespace Titano.App.Shell;
@@ -6,7 +8,8 @@ namespace Titano.App.Shell;
/// <summary>
/// The login form (BRIEF §12.7). It calls back the connection with the credentials and stays open with the
/// error sentence until the sign-in succeeds or the user cancels. The password never leaves the PasswordBox
/// except for that call.
/// except for that call. A failed sign-in is announced to screen readers and marks the password box (error border,
/// sentence as its help text) until the next attempt.
/// </summary>
public sealed partial class LoginDialog : TitanoWindow
{
@@ -40,6 +43,7 @@ public sealed partial class LoginDialog : TitanoWindow
{
SignIn.IsEnabled = false;
Error.Visibility = Visibility.Collapsed;
Field.SetError(Password, null);
try
{
var error = await _signIn(User.Text, Password.Password);
@@ -50,8 +54,11 @@ public sealed partial class LoginDialog : TitanoWindow
}
Error.Text = error;
Error.Visibility = Visibility.Visible;
Field.SetError(Password, error);
Password.Clear();
Password.Focus();
UIElementAutomationPeer.CreatePeerForElement(this)?.RaiseNotificationEvent(
AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, error, "Titano.SignIn");
}
finally
{
+38 -15
View File
@@ -4,6 +4,7 @@
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:shell="clr-namespace:Titano.App.Shell"
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
xmlns:s="clr-namespace:Titano.App.Sections"
Title="{Binding WindowTitle}"
Width="1440" Height="900" MinWidth="1200" MinHeight="760"
@@ -14,8 +15,24 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Navigation rail: full names, collapsible to icons (BRIEF §12.1). -->
<Border x:Name="Rail" Background="{DynamicResource Brush.Chrome}" Width="128" ui:NavRail.IsCollapsed="{Binding IsRailCollapsed}">
<!-- Navigation rail: full names, collapsible to icons (BRIEF §12.1). Expanded it is at least 128 px and grows with
the longest label of the language (up to 200 px); collapsed it is 48 px of icons. While the first-run dialog is
open the shell behind it takes no input. The buttons of both lists form one group (GroupName); their check
binds one way, the section the shell navigates to (a GroupName spans every window not yet on screen). -->
<Border x:Name="Rail" Background="{DynamicResource Brush.Chrome}" ui:NavRail.IsCollapsed="{Binding IsRailCollapsed}"
IsEnabled="{Binding IsShellEnabled}">
<Border.Style>
<Style TargetType="Border">
<Setter Property="MinWidth" Value="128" />
<Setter Property="MaxWidth" Value="200" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsRailCollapsed}" Value="True">
<Setter Property="MinWidth" Value="0" />
<Setter Property="Width" Value="48" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<DockPanel Margin="8,8,8,8" LastChildFill="False">
<Button DockPanel.Dock="Top" Style="{StaticResource Button.IconSubtle}" HorizontalAlignment="Left" Margin="0,0,0,6"
ui:ButtonIcon.Glyph="{StaticResource Icon.Menu}" Command="{Binding ToggleRailCommand}"
@@ -24,7 +41,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
IsChecked="{Binding IsSelected}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
IsChecked="{Binding IsSelected, Mode=OneWay}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -33,7 +50,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
IsChecked="{Binding IsSelected}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
IsChecked="{Binding IsSelected, Mode=OneWay}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -41,17 +58,19 @@
</DockPanel>
</Border>
<Grid Grid.Column="1">
<Grid Grid.Column="1" IsEnabled="{Binding IsShellEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor. -->
<ui:JobBar Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" ActionGlyph="{StaticResource Icon.Pause}"
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}" />
<!-- Job bar (DESIGN §4): current job, progress, time left, pause; "Ready" when idle, hidden when idle in the editor.
Screen readers hear which job starts and when the queue empties, not its progress ticks. -->
<ui:JobBar x:Name="JobBar" Text="{Binding JobText}" Progress="{Binding JobProgress}" IsActive="{Binding IsJobActive}" IsIndeterminate="{Binding IsJobIndeterminate}"
StopCommand="{Binding StopJobCommand}" StopToolTip="{l:Loc Tooltips.Shell.PauseJob}" StopName="{l:Loc Shell.JobBar.Pause}" ActionGlyph="{StaticResource Icon.Pause}"
Visibility="{Binding IsJobBarVisible, Converter={StaticResource BoolToVisibility}}"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding JobAnnouncement}" />
<ContentControl Grid.Row="1" Content="{Binding Current}" Focusable="False" />
@@ -61,18 +80,22 @@
<TextBlock Text="{Binding SequencesText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding PhotosText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock Text="{Binding StorageText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center" />
<TextBlock x:Name="Connection" Text="{Binding ConnectionText}" Margin="0,0,18,0" VerticalAlignment="Center"
AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding ConnectionText}" />
<TextBlock Text="{Binding JobsText}" VerticalAlignment="Center" />
</StackPanel>
</Border>
<ui:ToastHost x:Name="Toasts" Grid.Row="0" Grid.RowSpan="3" />
</Grid>
<!-- First run (Welcome.html): the shell dimmed behind one dialog. -->
<Grid Grid.ColumnSpan="2" Visibility="{Binding IsWelcomeOpen, Converter={StaticResource BoolToVisibility}}">
<!-- First run (Welcome.html): the shell dimmed behind one dialog that keeps the keyboard. -->
<Grid x:Name="WelcomeOverlay" Grid.ColumnSpan="2" Visibility="{Binding IsWelcomeOpen, Converter={StaticResource BoolToVisibility}}"
KeyboardNavigation.TabNavigation="Cycle" KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border Background="{DynamicResource Brush.Scrim}" />
<s:WelcomeView DataContext="{Binding Welcome}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,114,0,0" />
<s:WelcomeView DataContext="{Binding Welcome}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,114,0,0"
AutomationProperties.Name="{l:Loc Shell.Welcome.Title}" />
</Grid>
<!-- Above the first-run dialog too, so a card inserted meanwhile can still be acted on (Welcome.html). -->
<ui:ToastHost x:Name="Toasts" Grid.ColumnSpan="2" />
</Grid>
</ui:TitanoWindow>
+37 -4
View File
@@ -1,5 +1,9 @@
using System.Collections.Specialized;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Titano.App.Infrastructure;
using Titano.Ui.Controls;
@@ -14,21 +18,50 @@ public partial class MainWindow : TitanoWindow
_shell = shell;
DataContext = shell;
InitializeComponent();
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
UpdateConnection();
shell.PropertyChanged += (_, e) =>
{
if (e.PropertyName is nameof(ShellViewModel.IsRailCollapsed) or "")
Rail.Width = shell.IsRailCollapsed ? 48 : 128;
if (e.PropertyName is nameof(ShellViewModel.IsConnected) or "") UpdateConnection();
if (e.PropertyName is nameof(ShellViewModel.IsWelcomeOpen) or "") FocusWelcome();
};
shell.PendingToasts.CollectionChanged += OnToastRequested;
Loaded += (_, _) => FocusWelcome();
RestorePlacement();
Closing += (_, _) => SavePlacement();
}
/// <summary>F6 moves the keyboard to the newest notification (as in Windows apps), Esc there dismisses it.</summary>
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (!e.Handled && e.Key == Key.F6 && Keyboard.Modifiers == ModifierKeys.None) e.Handled = Toasts.FocusNewest();
}
private void UpdateConnection() =>
Connection.SetResourceReference(System.Windows.Controls.TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
Connection.SetResourceReference(TextBlock.ForegroundProperty, _shell.IsConnected ? "Brush.Accent" : "Brush.TextMuted");
/// <summary>The first-run dialog takes the keyboard on its chosen option once it is on screen.</summary>
private void FocusWelcome()
{
if (!_shell.IsWelcomeOpen) return;
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () =>
{
if (!_shell.IsWelcomeOpen || !IsLoaded) return;
if (FindChecked(WelcomeOverlay) is { } choice) choice.Focus();
else WelcomeOverlay.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
});
}
private static RadioButton? FindChecked(DependencyObject root)
{
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(root); i++)
{
var child = VisualTreeHelper.GetChild(root, i);
if (child is RadioButton { IsChecked: true } radio) return radio;
if (FindChecked(child) is { } nested) return nested;
}
return null;
}
private void OnToastRequested(object? sender, NotifyCollectionChangedEventArgs e)
{
+45 -1
View File
@@ -7,6 +7,7 @@ using Titano.App.Archiving;
using Titano.App.DesignTime;
using Titano.App.Editor;
using Titano.App.Import;
using Titano.App.Infrastructure;
using Titano.App.Library;
using Titano.App.Server;
using Titano.App.Settings;
@@ -18,7 +19,9 @@ namespace Titano.App.Shell;
/// <summary>
/// <c>Titano.exe --capture &lt;dir&gt;</c>: renders every client screen at 1440×900 in the dark and light themes to
/// <c>&lt;screen&gt;-&lt;theme&gt;.png</c> from <see cref="SampleData"/> (first run on an empty index, then a populated
/// one, then the sync table with transfers, a conflict and its confirmation), for visual review and phase reports (BRIEF §20.2), then exits.
/// one, then the sync table with transfers, a conflict and its confirmation), plus the Library, the editor's Exposure
/// tab and the import plan in Arabic (<c>*-rtl-dark.png</c>, right to left), for visual review and phase reports
/// (BRIEF §20.2), then exits.
/// </summary>
public static class ScreenCapture
{
@@ -82,6 +85,9 @@ public static class ScreenCapture
written += await SaveAsync(window, directory, "library-list", theme, waitForThumbnails: shell);
shell.Library.LayoutIndex = 0;
shell.Library.ClearSelectionCommand.Execute(null);
shell.IsRailCollapsed = true;
written += await SaveAsync(window, directory, "library-rail-collapsed", theme, waitForThumbnails: shell);
shell.IsRailCollapsed = false;
written += await CaptureLibraryScenesAsync(window, shell, directory, theme);
shell.Navigate(SectionKey.Jobs);
@@ -241,6 +247,8 @@ public static class ScreenCapture
foreach (var toast in window.Toasts.Toasts.ToList()) window.Toasts.Dismiss(toast);
}
written += await CaptureRightToLeftAsync(window, shell, editor, directory);
// Last, as it stays: an analysis of the sequence running (settings disabled, viewing tools live).
await sample.MarkAnalysingAsync(id);
await editor.AttachJobsAsync();
@@ -252,6 +260,41 @@ public static class ScreenCapture
return written;
}
/// <summary>
/// The Library, the editor's Exposure tab and the import plan in Arabic, dark: the layout mirrors while photos,
/// charts, the filmstrip and templates stay left to right. English is restored whatever happens.
/// </summary>
private static async Task<int> CaptureRightToLeftAsync(MainWindow window, ShellViewModel shell, EditorViewModel editor, string directory)
{
var written = 0;
var frame = editor.CurrentIndex;
ThemeManager.Apply(AppTheme.Dark);
UiLanguage.Apply("ar");
try
{
DismissToasts(window);
shell.Navigate(SectionKey.Library);
written += await SaveAsync(window, directory, "library-rtl", AppTheme.Dark, waitForThumbnails: shell);
shell.Navigate(SectionKey.Sequence);
editor.SelectedTab = editor.Exposure;
editor.IsCompare = true;
editor.CurrentIndex = 45;
written += await SaveEditorAsync(window, editor, directory, "sequence-exposure-rtl", AppTheme.Dark);
await ImportScenes.ShowAsync(shell, "plan");
DismissToasts(window);
written += await SaveAsync(window, directory, "import-plan-rtl", AppTheme.Dark);
}
finally
{
UiLanguage.Apply("en");
}
shell.Navigate(SectionKey.Sequence);
editor.CurrentIndex = frame;
return written;
}
private static async Task<int> SaveEditorAsync(Window window, EditorViewModel editor, string directory, string screen, AppTheme theme)
{
await Settle(window);
@@ -306,6 +349,7 @@ public static class ScreenCapture
return false;
}
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
// A right-to-left window's content already renders mirrored, as on screen.
bitmap.Render(root);
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
+26 -8
View File
@@ -16,6 +16,7 @@ public sealed class ShellViewModel : LocalizedViewModel
private SectionViewModel _current;
private bool _isRailCollapsed;
private string? _jobText;
private string? _jobName;
private double _jobProgress;
private bool _jobActive;
private bool _jobIndeterminate;
@@ -85,12 +86,17 @@ public sealed class ShellViewModel : LocalizedViewModel
get => _welcome;
private set
{
if (Set(ref _welcome, value)) OnPropertyChanged(nameof(IsWelcomeOpen));
if (!Set(ref _welcome, value)) return;
OnPropertyChanged(nameof(IsWelcomeOpen));
OnPropertyChanged(nameof(IsShellEnabled));
}
}
public bool IsWelcomeOpen => _welcome is not null;
/// <summary>The rail and the sections take input only while no first-run dialog covers them.</summary>
public bool IsShellEnabled => _welcome is null;
public SectionViewModel Current
{
get => _current;
@@ -105,7 +111,7 @@ public sealed class ShellViewModel : LocalizedViewModel
}
}
public string WindowTitle => Current == Library ? "Titano" : "Titano — " + Current.Title;
public string WindowTitle => Current == Library ? Loc.L("Shell.AppName") : Loc.L("Shell.WindowTitle", Loc.L("Shell.AppName"), Current.Title);
public bool IsRailCollapsed
{
@@ -160,7 +166,7 @@ public sealed class ShellViewModel : LocalizedViewModel
// ---- Job bar ----
public string JobText => _jobActive && _jobText is not null
? _jobText
: _queuedCount > 0 ? Loc.L("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
: _queuedCount > 0 ? Loc.Plural("Shell.JobBar.Ready", _queuedCount) : Loc.L("Shell.JobBar.Idle");
public double JobProgress { get => _jobProgress; private set => Set(ref _jobProgress, value); }
public bool IsJobActive
@@ -179,14 +185,25 @@ public sealed class ShellViewModel : LocalizedViewModel
/// <summary>Pauses the job the bar shows.</summary>
public ICommand? StopJobCommand => Jobs.PauseCurrentCommand;
/// <summary>Updates the global job bar (and the taskbar progress through the window).</summary>
public void SetJob(string? text, double progress, bool indeterminate = false)
/// <summary>
/// What screen readers hear from the job bar: the job when one starts, the idle line when the last one ends; not its
/// progress, speed or time left, which change every second.
/// </summary>
public string JobAnnouncement => _jobActive && _jobName is not null ? _jobName : JobText;
/// <summary>
/// Updates the global job bar (and the taskbar progress through the window). <paramref name="name"/> says which job
/// it is without its progress ("Render: Harbour sunset"); null reads <paramref name="text"/>.
/// </summary>
public void SetJob(string? text, double progress, bool indeterminate = false, string? name = null)
{
_jobText = text;
_jobName = text is null ? null : name ?? text;
IsJobActive = text is not null;
JobProgress = progress;
IsJobIndeterminate = indeterminate;
OnPropertyChanged(nameof(JobText));
OnPropertyChanged(nameof(JobAnnouncement));
}
// ---- Status strip ----
@@ -222,6 +239,7 @@ public sealed class ShellViewModel : LocalizedViewModel
_queuedCount = queued;
OnPropertyChanged(nameof(JobsText));
OnPropertyChanged(nameof(JobText));
OnPropertyChanged(nameof(JobAnnouncement));
}
public void Navigate(SectionKey key)
@@ -250,14 +268,14 @@ public sealed class ShellViewModel : LocalizedViewModel
ActionCommand = action is null ? null : new RelayCommand(action),
});
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6).</summary>
/// <summary>Errors are one sentence saying what happened plus one action (BRIEF §0.2 rule 6); the details go to the log.</summary>
public void ReportError(Exception ex)
{
Log.Error("ui", "Operation failed", ex);
ShowToast(new Toast
{
Title = Loc.L("Errors.Unexpected"),
Message = ex.Message,
Title = ErrorText.For(ex),
IsError = true,
ActionText = Loc.L("Common.OpenLogs"),
ActionToolTip = Loc.L("Tooltips.Common.OpenLogs"),
ActionCommand = new RelayCommand(() => ShellActions.Reveal(Services.Environment.LogDirectory)),