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:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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"),
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user