feat(app): complete the Library: timeline, saved views, quick and mass actions, remote cards

The Library gets a third layout (year bands of photos per month over the card
grid; a month narrows to its year and scrolls to it), saved views stored as
app-scope settings rows, hover quick actions on cards and rows (open, analyse,
render the sequence's preset, sync), the full mass actions bar (analyse,
proxies, verify, tags, rating, move, upload, download, delete into the trash,
CSV) with each button's reason when it cannot run, and, while signed in, the
server's sequences without a local copy as remote cards filterable by origin.
Delete shows the engine's dry run behind a typed confirmation and offers Undo;
the Archive manager gets Delete… and a Trash dialog that restores sequences.

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-03 11:50:43 +00:00
1 parent 453fb63687
commit 20b9654c33
27 files changed
+2582 -422

No files matched your search

+177
View File
@@ -0,0 +1,177 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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: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="AutomationProperties.Name" Value="{Binding To}" />
</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}" />
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Stroke}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="{StaticResource Radius.Dialog}" />
<Setter Property="Padding" Value="24,18,24,20" />
<Setter Property="Effect" Value="{StaticResource Shadow.Popup}" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<DataTemplate DataType="{x:Type ar:RebuildDialogViewModel}">
<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.ItemTemplate>
<DataTemplate DataType="{x:Type ar:DialogFact}">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<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" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" 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" />
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Rebuild.Start}" Command="{Binding RebuildCommand}" ToolTip="{Binding RebuildToolTip}"
MinWidth="96" Margin="8,0,0,0" />
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type ar:RenameDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="720" MaxHeight="560">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<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="*" />
</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}" />
</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"
AutomationProperties.Name="{l:Loc Archive.Rename.Preview}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ar:RenameRow}">
<Grid Height="30" TextElement.FontSize="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="120" />
<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}" />
</Grid>
</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" />
</DockPanel>
</Grid>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type ar:RetagDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="520">
<StackPanel>
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<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}" />
<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" />
<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>
<TextBlock Text="{Binding SummaryText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,12,0,0" Typography.NumeralAlignment="Tabular" />
<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" />
</DockPanel>
</StackPanel>
</Border>
</DataTemplate>
<!-- The archive's trash: deleted sequences, newest first, each with Restore. -->
<DataTemplate DataType="{x:Type ar:TrashDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="640" MaxHeight="520">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" TextTrimming="CharacterEllipsis" />
<TextBlock Grid.Row="1" Text="{Binding SummaryText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,8,0,8" Typography.NumeralAlignment="Tabular" />
<ListBox Grid.Row="2" ItemsSource="{Binding Rows}" MinHeight="120" AutomationProperties.Name="{l:Loc Archive.Trash.List}" KeyboardNavigation.TabNavigation="Continue">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ar:TrashRowViewModel}">
<DockPanel Height="48">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Row}" Content="{l:Loc Archive.Trash.Restore}" Command="{Binding RestoreCommand}"
ToolTip="{l:Loc Tooltips.Archive.TrashRestore}" />
<TextBlock DockPanel.Dock="Right" Text="{Binding DeletedText}" Style="{StaticResource Text.Secondary}" VerticalAlignment="Center" Margin="12,0"
Typography.NumeralAlignment="Tabular" />
<StackPanel VerticalAlignment="Center">
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" ToolTip="{Binding Title}" />
<TextBlock Text="{Binding Detail}" Style="{StaticResource Text.Secondary}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Detail}"
Typography.NumeralAlignment="Tabular" />
</StackPanel>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<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" />
</DockPanel>
</Grid>
</Border>
</DataTemplate>
</ResourceDictionary>
+47
View File
@@ -0,0 +1,47 @@
using System.Globalization;
using Titano.App.Infrastructure;
using Titano.Core.Localization;
using Titano.Data.Archiving;
namespace Titano.App.Archiving;
/// <summary>The words of a delete dry run (<see cref="DeletePlan"/>): the destructive confirmation and the lines of what cannot move.</summary>
public static class DeletePlans
{
/// <summary>Sequences named one by one in the confirmation; the rest are counted.</summary>
public const int ListedLines = 8;
/// <summary>The destructive confirmation of a plan; null when nothing in it can move.</summary>
public static ConfirmRequest? Request(DeletePlan plan)
{
if (plan.Steps.Count == 0) return null;
var count = plan.Steps.Count.ToString(CultureInfo.InvariantCulture);
var lines = plan.Steps.Take(ListedLines).Select(s => Loc.L("Archive.Delete.Line", s.Sequence.DisplayTitle,
Loc.Plural("Shell.Status.Photos", s.Sequence.FrameCount), Formatting.Bytes(s.Bytes))).ToList();
if (plan.Steps.Count > ListedLines) lines.Add(Loc.Plural("Archive.Delete.More", plan.Steps.Count - ListedLines));
lines.AddRange(Blocked(plan, ListedLines));
return new ConfirmRequest
{
Heading = Loc.Plural("Archive.Delete.Heading", plan.Steps.Count),
Message = Loc.L("Archive.Delete.Message", Loc.Plural("Shell.Status.Photos", plan.Frames), Loc.Plural("Archive.Delete.Files", plan.Files),
Formatting.Bytes(plan.Bytes)),
Detail = string.Join(Environment.NewLine, lines),
DetailToolTip = Loc.L("Tooltips.Archive.DeletePlan"),
SafeText = Loc.L("Archive.Delete.Keep"),
SafeToolTip = Loc.L("Tooltips.Archive.DeleteKeep"),
ActionText = Loc.L("Archive.Delete.Action"),
ActionToolTip = Loc.Plural("Tooltips.Archive.DeleteAction", plan.Steps.Count),
IsDestructive = true,
TypedConfirmation = count,
TypedPrompt = Loc.L("Archive.Delete.Type", count),
};
}
/// <summary>"Not moved: Comet over the ridge · a job is working on it", at most <paramref name="max"/> lines.</summary>
public static IReadOnlyList<string> Blocked(DeletePlan plan, int max)
{
var lines = plan.Blocked.Take(max).Select(b => Loc.L("Archive.Delete.Blocked", b.Sequence.DisplayTitle, Loc.L("Archive.Delete.Reason." + b.Reason))).ToList();
if (plan.Blocked.Count > max) lines.Add(Loc.Plural("Archive.Delete.More", plan.Blocked.Count - max));
return lines;
}
}
@@ -0,0 +1,78 @@
using System.IO;
using Titano.App.Infrastructure;
using Titano.App.Shell;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data;
using Titano.Data.Archiving;
namespace Titano.App.Archiving;
/// <summary>
/// "Delete" of the Library and the Archive manager (BRIEF §0.2 rule 8, §12.2, §12.5): the archive engine's dry run is
/// shown in a destructive confirmation that asks to type the number of sequences (DESIGN §4), then the sequences move to
/// their archive's trash; the toast that follows brings them back.
/// </summary>
public static class SequenceDeletion
{
/// <summary>Plans, asks, deletes and offers to undo; true when something moved to the trash.</summary>
public static async Task<bool> RunAsync(ShellViewModel shell, IReadOnlyList<Guid> sequenceIds)
{
if (shell.Services.Archives is not { } archives || sequenceIds.Count == 0) return false;
try
{
var plan = await Task.Run(() => archives.PlanDeleteAsync(sequenceIds));
if (DeletePlans.Request(plan) is not { } request)
{
shell.Notify(Loc.L("Archive.Delete.Nothing"), string.Join(Environment.NewLine, DeletePlans.Blocked(plan, DeletePlans.ListedLines)));
return false;
}
if (!shell.Services.Dialogs.Confirm(request)) return false;
var entries = await Task.Run(() => archives.DeleteAsync(plan, Environment.UserName));
Log.Info("archive", $"{entries.Count} sequence(s) moved to the trash, {plan.Steps.Count - entries.Count} removed from the index only");
await RefreshAsync(shell);
shell.Notify(Loc.Plural("Archive.Delete.Done", plan.Steps.Count), Loc.L("Archive.Delete.Kept"),
entries.Count == 0 ? null : Loc.L("Archive.Delete.Undo"), Loc.L("Tooltips.Archive.DeleteUndo"),
entries.Count == 0 ? null : () => _ = RestoreAsync(shell, entries));
return true;
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or StaleDeletePlanException or ArgumentException
or DatabaseException)
{
Log.Warning("archive", "Delete failed", ex);
shell.Notify(Loc.L("Archive.Delete.Failed"), ex.Message);
await RefreshAsync(shell);
return false;
}
}
/// <summary>Brings deleted sequences back from their archives' trash and indexes them again.</summary>
public static async Task RestoreAsync(ShellViewModel shell, IReadOnlyList<TrashEntry> entries)
{
if (shell.Services.Archives is not { } archives) return;
var restored = 0;
try
{
foreach (var entry in entries)
{
await Task.Run(() => archives.RestoreAsync(entry.ArchiveId, entry.Name));
restored++;
}
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)
{
Log.Warning("archive", "Restore from the trash failed", ex);
shell.Notify(Loc.L("Archive.Trash.Failed"), ex.Message);
}
await RefreshAsync(shell);
}
private static async Task RefreshAsync(ShellViewModel shell)
{
await shell.Library.RefreshAsync();
await shell.Archive.LoadAsync();
shell.Services.Sync.RequestRefresh();
}
}
@@ -0,0 +1,109 @@
using System.IO;
using System.Windows.Input;
using Titano.App.Infrastructure;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data;
using Titano.Data.Archiving;
using Titano.Ui.Mvvm;
namespace Titano.App.Archiving;
/// <summary>One deleted sequence in the trash: what it was, when it went, and Restore.</summary>
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>"Deleted 02/10/2026 18:04".</summary>
public string DeletedText => Loc.L("Archive.Trash.Deleted", Formatting.Date(Entry.DeletedAt) + " " + Formatting.TimeOfDay(Entry.DeletedAt));
public ICommand RestoreCommand { get; } = restore;
}
/// <summary>
/// The archive's trash (BRIEF §0.2 rule 8): every sequence deleted from the Library or the Archive manager, newest
/// first, each restorable into its folder (or a free one next to it) with its ids, settings and renders.
/// </summary>
public sealed class TrashDialogViewModel : ArchiveDialogViewModel
{
private readonly ArchiveService _archives;
private readonly Core.Model.Archive _archive;
private readonly Func<Task> _restored;
private IReadOnlyList<TrashRowViewModel> _rows = [];
public TrashDialogViewModel(ArchiveService archives, Core.Model.Archive archive, Func<Task> restored, Action<ArchiveDialogViewModel> close)
: base(close)
{
_archives = archives;
_archive = archive;
_restored = restored;
}
public string Heading => Loc.L("Archive.Trash.Heading", _archive.Name);
public IReadOnlyList<TrashRowViewModel> Rows
{
get => _rows;
private set
{
if (!Set(ref _rows, value)) return;
OnPropertyChanged(nameof(IsEmpty));
OnPropertyChanged(nameof(SummaryText));
}
}
public bool IsEmpty => _rows.Count == 0;
/// <summary>"3 sequences · 182 GB", or "The trash is empty".</summary>
public string SummaryText => _rows.Count == 0 ? Loc.L("Archive.Trash.Empty")
: Loc.Plural("Shell.Status.Sequences", _rows.Count) + " · " + Formatting.Bytes(_rows.Sum(r => r.Entry.Bytes));
/// <summary>Reads the trash of the archive (off the UI thread).</summary>
public async Task LoadAsync()
{
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;
}
}
/// <summary>Shows entries read elsewhere (capture).</summary>
public void Show(IReadOnlyList<TrashEntry> entries) =>
Rows = [.. entries.Select(e => new TrashRowViewModel(e, new AsyncRelayCommand(() => Task.CompletedTask)))];
private async Task RestoreAsync(TrashEntry entry)
{
IsBusy = true;
BusyText = Loc.L("Archive.Trash.Restoring", entry.Title);
try
{
await Task.Run(() => _archives.RestoreAsync(entry.ArchiveId, entry.Name));
Log.Info("archive", $"{entry.Title} restored from the trash");
Rows = [.. _rows.Where(r => r.Entry != entry)];
BusyText = null;
await _restored();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidDataException or InvalidOperationException or DatabaseException
or ArgumentException)
{
Log.Warning("archive", $"Restoring {entry.Title} failed", ex);
BusyText = ex.Message;
}
finally
{
IsBusy = false;
}
}
}
@@ -13,6 +13,9 @@ public enum LibraryLayout
{
Grid,
List,
/// <summary>Year bands with photos per month above the card grid.</summary>
Timeline,
}
/// <summary>Rendering quality profile (Settings › Rendering).</summary>
+217
View File
@@ -0,0 +1,217 @@
using System.IO;
using System.Net.Http;
using Titano.App.Jobs;
using Titano.App.Server;
using Titano.App.Shell;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Core.Project;
using Titano.Data;
using Titano.Data.Archiving;
using Titano.Data.Archiving.Jobs;
using Titano.Data.Processing;
using Titano.Data.Sync;
using Titano.Protocol;
using Titano.Protocol.Client;
namespace Titano.App.Library;
/// <summary>
/// What the Library's quick and mass actions run (BRIEF §12.2): analyses, proxies, verifies and renders as jobs on
/// this PC's engine, or posted to the server for a sequence that only lives there; uploads, downloads and settings
/// exchanges through the sync engine (as the Server screen does); ratings through the archive engine (sidecar and
/// index together). Every queued job is announced with a toast that opens the Jobs screen.
/// </summary>
public sealed class LibraryActions(ShellViewModel shell)
{
/// <summary>Wire names of the job kinds a remote card posts (<c>POST /api/v1/jobs</c>).</summary>
private const string RenderKind = "render";
private const string DeepAnalyseKind = "deep-analyse";
private Infrastructure.AppServices Services => shell.Services;
/// <summary>The signed-in server's sync engine and connection; null while signed out.</summary>
public RemoteSource? Remote() =>
Services.Sync is { Service: { } service, Server: { } server, Remote: { } remote } ? new RemoteSource(service, server, remote) : null;
/// <summary>What the signed-in account may do; nothing while signed out.</summary>
public SyncRights Rights => Services.Server.User is { } user ? SyncRights.Of(user.Permissions) : default;
/// <summary>Deep analysis of sequences on this PC (one job), or of a remote card on the server.</summary>
public async Task AnalyseAsync(IReadOnlyList<Sequence> sequences)
{
if (sequences is [{ Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly } remote])
{
await PostAsync(() => Task.FromResult(new CreateJobRequest(DeepAnalyseKind, [remote.Id], null)), JobKind.DeepAnalyse, remote.DisplayTitle);
return;
}
await QueueAsync(ProcessingJobs.DeepAnalysis([.. sequences.Select(s => s.Id)], Label(sequences)));
}
public Task ProxiesAsync(IReadOnlyList<Sequence> sequences) => QueueAsync(ArchiveJobs.Proxies([.. sequences.Select(s => s.Id)], Label(sequences)));
/// <summary>Verification is an archive job: one per archive, naming its sequences.</summary>
public async Task VerifyAsync(IReadOnlyList<Sequence> sequences)
{
if (Services.Database is not { } db) return;
foreach (var group in sequences.GroupBy(s => s.ArchiveId))
{
if (await db.Archives.GetAsync(group.Key) is { } archive) await QueueAsync(ArchiveJobs.Verify(archive, [.. group.Select(s => s.Id)]));
}
}
/// <summary>
/// The Render quick action: the sequence's own export (its recommended preset, else the default) with its project as
/// stored, on this PC's engine — or posted to the server for a remote card, which renders it where the originals are.
/// </summary>
public async Task RenderAsync(Sequence sequence)
{
if (sequence is { Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly })
{
if (Remote() is not { } remote) return;
await PostAsync(async () =>
{
var (project, width, height) = await RemoteProjectAsync(remote, sequence.Id);
return new CreateJobRequest(RenderKind, [sequence.Id], ProcessingJobs.Render(sequence, project.Export with { Batch = [] }, width, height).ParametersJson);
}, JobKind.Render, sequence.DisplayTitle);
return;
}
if (Services.Database is not { } db) return;
var first = (await db.Frames.ListBySequenceAsync(sequence.Id, -1, 1)).FirstOrDefault();
var (w, h) = first is null ? (0, 0) : first.Orientation is >= 5 and <= 8 ? (first.Height, first.Width) : (first.Width, first.Height);
var export = Project(sequence.SettingsJson).Export with { Batch = [] };
await QueueAsync(ProcessingJobs.Render(sequence, export, w, h));
}
/// <summary>Runs one row action of the sync table on a sequence (the card's Sync, a mass Upload or Download); false when it could not start.</summary>
public async Task<bool> SyncAsync(SelectedSequence selected, SyncAction action)
{
if (Remote() is not { } remote || Services.Engine is not { } engine) return false;
var entry = selected.Sync;
switch (action)
{
case SyncAction.Upload when !selected.IsRemote:
await remote.Service.EnqueueUploadAsync(engine, remote.Server, selected.Sequence);
return true;
case SyncAction.SendExports when !selected.IsRemote:
await remote.Service.EnqueueSendExportsAsync(engine, remote.Server, selected.Sequence);
return true;
case SyncAction.DownloadOriginals when entry is not null:
if ((entry.Local?.ArchiveId ?? (await Services.Sync.CurrentArchiveAsync())?.Id) is not { } archive)
{
shell.Notify(Loc.L("Errors.Sync.NoArchive"));
return false;
}
await remote.Service.EnqueueDownloadAsync(engine, remote.Server, entry.Id, entry.Title, SyncDownloadMode.Originals, archive);
return true;
case SyncAction.GetExports when entry is not null:
await remote.Service.EnqueueDownloadAsync(engine, remote.Server, entry.Id, entry.Title, SyncDownloadMode.Exports, null);
return true;
case SyncAction.SyncSettings when entry is not null:
await remote.Service.SyncSettingsAsync(remote.Remote, entry.Id, Services.Sync.Policy, CancellationToken.None);
return true;
default:
return false;
}
}
/// <summary>
/// Opens a remote card with proxies (BRIEF §14.5): at once when its proxies are cached here, otherwise after the
/// proxy download this queues. Returns that download job, or null when the editor opened (or nothing could start).
/// </summary>
public async Task<Guid?> OpenRemoteAsync(Sequence sequence)
{
if (Remote() is not { } remote || Services.Engine is not { } engine) return null;
if (remote.Service.OpenRemote(remote.Server, sequence.Id) is not null)
{
shell.OpenSequence(sequence.Id);
return null;
}
var job = await remote.Service.EnqueueDownloadAsync(engine, remote.Server, sequence.Id, sequence.DisplayTitle, SyncDownloadMode.Proxies, null);
Queued(JobKind.Download, sequence.DisplayTitle);
return job.Id;
}
/// <summary>Sets the rating of sequences on this PC (sidecar and index together); returns how many changed.</summary>
public async Task<int> RateAsync(IReadOnlyList<Sequence> sequences, int rating)
{
if (Services.Archives is not { } archives) return 0;
var changed = 0;
try
{
foreach (var s in sequences.Where(s => s.Rating != rating))
{
await Task.Run(() => archives.SetSequenceInfoAsync(s.Id, s.Title, s.Tags, rating, s.Notes));
changed++;
}
}
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);
}
return changed;
}
/// <summary>"Deep analysis queued · Harbour sunset", with a way to the Jobs screen.</summary>
public void Queued(JobKind kind, string label) =>
shell.Notify(Loc.L("Library.Queued", JobText.Kind(kind), label), actionText: Loc.L("Shell.Nav.Jobs"), actionToolTip: Loc.L("Tooltips.Nav.Jobs"),
action: () => shell.Navigate(SectionKey.Jobs));
public static string Label(IReadOnlyList<Sequence> sequences) =>
sequences.Count == 1 ? sequences[0].DisplayTitle : Loc.Plural("Library.Selection.Count", sequences.Count);
private async Task QueueAsync(ArchiveJobRequest request)
{
if (Services.Engine is not { } engine || request.Targets.Count == 0) return;
await engine.EnqueueAsync(request);
Queued(request.Kind, request.Label ?? string.Empty);
}
/// <summary>Posts a job to the signed-in server, which runs it or hands it to a render node (BRIEF §14.6, §14.7).</summary>
private async Task PostAsync(Func<Task<CreateJobRequest>> build, JobKind kind, string label)
{
var session = Services.Server;
if (!session.IsConnected || session.Flow is not { Address: { } address, Token: { } token }) return;
try
{
var request = await build();
using var client = new TitanoClient(address, new CertificatePinning(session.Fingerprints), $"Titano ({Environment.MachineName})") { Token = token };
await client.CreateJobAsync(request);
shell.Notify(Loc.L("Library.QueuedServer", JobText.Kind(kind), label));
}
catch (Exception ex) when (ex is TitanoApiException or HttpRequestException or IOException or TaskCanceledException)
{
Log.Warning("library", $"Posting a {kind} job to {address} failed", ex);
shell.Notify(Loc.L("Library.Post.Failed"), ex.Message);
}
}
/// <summary>The project of a remote card: from its proxy cache when it was opened here, else from the server's manifest; and its frame size when cached.</summary>
private static async Task<(ProjectSettings Project, int Width, int Height)> RemoteProjectAsync(RemoteSource remote, Guid id)
{
if (remote.Service.OpenRemote(remote.Server, id) is { } cached)
{
var frame = cached.Frames.FirstOrDefault(f => f.Width > 0);
var size = frame is null ? (0, 0) : frame.Orientation is >= 5 and <= 8 ? (frame.Height, frame.Width) : (frame.Width, frame.Height);
return (Project(cached.Sequence.SettingsJson), size.Item1, size.Item2);
}
var manifest = await remote.Remote.GetManifestAsync(id, CancellationToken.None);
return (Project(manifest.SettingsJson), 0, 0);
}
private static ProjectSettings Project(string? json)
{
try
{
return json is null ? new ProjectSettings() : ProjectSettings.FromJson(json);
}
catch (System.Text.Json.JsonException ex)
{
Log.Warning("library", "Unreadable project settings; rendering the defaults", ex);
return new ProjectSettings();
}
}
}
+53 -2
View File
@@ -16,7 +16,15 @@ public enum StatusFilter
Warnings,
}
/// <summary>Library filters (search, year, camera, status, tag) and sort; immutable so a page request can carry it.</summary>
/// <summary>Where the sequences of the Library live (BRIEF §4.4 mixed mode): both, this PC, or only the signed-in server.</summary>
public enum OriginFilter
{
Any,
Local,
Server,
}
/// <summary>Library filters (search, year, camera, status, tag, origin) and sort; immutable so a page request can carry it.</summary>
public sealed record LibraryFilter
{
public string? Text { get; init; }
@@ -24,10 +32,12 @@ public sealed record LibraryFilter
public string? Camera { get; init; }
public StatusFilter Status { get; init; }
public string? Tag { get; init; }
public OriginFilter Origin { get; init; }
public SequenceSort Sort { get; init; } = SequenceSort.Newest;
/// <summary>No filter narrows the list (the sort may differ): an empty result means an empty library.</summary>
public bool IsUnfiltered => string.IsNullOrWhiteSpace(Text) && Year is null && Camera is null && Status == StatusFilter.Any && Tag is null;
public bool IsUnfiltered => string.IsNullOrWhiteSpace(Text) && Year is null && Camera is null && Status == StatusFilter.Any && Tag is null
&& Origin == OriginFilter.Any;
/// <summary>The same sort without filters ("Clear filters").</summary>
public LibraryFilter Cleared() => new() { Sort = Sort };
@@ -50,6 +60,47 @@ public sealed record LibraryFilter
};
}
/// <summary>
/// The same test the index applies to its rows (<see cref="ToQuery"/>), for sequences that are not in the index
/// (server sequences without a local copy): title, camera or tag text, capture year, camera model, status, tag.
/// </summary>
public bool Matches(Sequence sequence)
{
if (Year is { } year && sequence.FirstCapture?.Year != year) return false;
if (Camera is not null && sequence.CameraModel != Camera) return false;
var (with, without) = Flags(Status);
if ((sequence.Status & with) != with || (sequence.Status & without) != 0) return false;
if (Tag is not null && !sequence.Tags.Contains(TagRepository.Normalize(Tag), StringComparer.OrdinalIgnoreCase)) return false;
if (string.IsNullOrWhiteSpace(Text)) return true;
var text = Text.Trim();
return new[] { sequence.Title, sequence.CameraMake, sequence.CameraModel }.Any(v => v?.Contains(text, StringComparison.OrdinalIgnoreCase) == true)
|| sequence.Tags.Any(t => t.Contains(text, StringComparison.OrdinalIgnoreCase));
}
/// <summary>The index's order of <see cref="Sort"/> (missing values last, the id as tie-breaker), for merging pages with other sequences.</summary>
public int Compare(Sequence a, Sequence b)
{
var order = Sort switch
{
SequenceSort.Newest => Nullable(a.FirstCapture, b.FirstCapture, descending: true),
SequenceSort.Oldest => Nullable(a.FirstCapture, b.FirstCapture, descending: false),
SequenceSort.Title => string.CompareOrdinal(a.DisplayTitle.ToLowerInvariant(), b.DisplayTitle.ToLowerInvariant()),
SequenceSort.FrameCount => b.FrameCount.CompareTo(a.FrameCount),
_ => b.TotalBytes.CompareTo(a.TotalBytes),
};
if (order != 0) return order;
var ids = string.CompareOrdinal(a.Id.ToString(), b.Id.ToString());
return Sort is SequenceSort.Oldest or SequenceSort.Title ? ids : -ids;
static int Nullable(DateTime? x, DateTime? y, bool descending) => (x, y) switch
{
(null, null) => 0,
(null, _) => 1,
(_, null) => -1,
_ => descending ? y!.Value.CompareTo(x!.Value) : x!.Value.CompareTo(y!.Value),
};
}
/// <summary>Flags that must be set and clear for a status choice.</summary>
public static (SequenceStatus With, SequenceStatus Without) Flags(StatusFilter status) => status switch
{
+63
View File
@@ -0,0 +1,63 @@
using Titano.App.Archiving;
using Titano.Core.Model;
using Titano.Data.Repositories;
namespace Titano.App.Library;
/// <summary>
/// The Library's timeline layout (BRIEF §12.2): one band per capture year, newest first, with the density of photos
/// per month (the Archive heatmap's figures), and the way between a band's month and the sequences of the grid.
/// </summary>
public sealed class LibraryTimeline
{
private LibraryTimeline(IReadOnlyList<HeatRow> bands, IReadOnlyList<int> years)
{
Bands = bands;
Years = years;
}
public static LibraryTimeline Empty { get; } = new([], []);
/// <summary>One row per year, newest first; months to come are NaN.</summary>
public IReadOnlyList<HeatRow> Bands { get; }
/// <summary>The year of each band.</summary>
public IReadOnlyList<int> Years { get; }
public static LibraryTimeline From(ArchiveStats stats, DateTime today)
{
var rows = ArchiveFigures.PhotosPerMonth(stats, today).Reverse().ToList();
var first = stats.ByMonth.Count == 0 ? 0 : stats.ByMonth.Max(m => m.Year);
return new LibraryTimeline(rows, [.. Enumerable.Range(0, rows.Count).Select(i => first - i)]);
}
/// <summary>Year and month of a band's slot; null outside the bands.</summary>
public (int Year, int Month)? MonthAt(int band, int slot) =>
band >= 0 && band < Years.Count && slot is >= 0 and < 12 ? (Years[band], slot + 1) : null;
/// <summary>Band and slot of a month; (−1, −1) when no band shows that year.</summary>
public (int Band, int Slot) SlotOf(int year, int month)
{
var band = IndexOf(Years, year);
return band < 0 || month is < 1 or > 12 ? (-1, -1) : (band, month - 1);
}
/// <summary>Position of the first sequence first captured in that month, in list order; −1 when none of <paramref name="sequences"/> is.</summary>
public static int FirstOfMonth(IReadOnlyList<Sequence> sequences, int year, int month)
{
for (var i = 0; i < sequences.Count; i++)
{
if (sequences[i].FirstCapture is { } at && at.Year == year && at.Month == month) return i;
}
return -1;
}
private static int IndexOf(IReadOnlyList<int> values, int value)
{
for (var i = 0; i < values.Count; i++)
{
if (values[i] == value) return i;
}
return -1;
}
}
+126
View File
@@ -0,0 +1,126 @@
using Titano.App.Server;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Data.Sync;
namespace Titano.App.Library;
/// <summary>The actions of the Library's mass actions bar (BRIEF §12.2).</summary>
public enum MassAction
{
Analyse,
Proxies,
Verify,
Tag,
Rate,
Move,
Upload,
Download,
Delete,
ExportList,
}
/// <summary>A selected sequence and, while signed in, its row of the sync table.</summary>
public sealed record SelectedSequence(Sequence Sequence, SyncEntry? Sync)
{
/// <summary>Only on the server: no copy on this PC (a remote card).</summary>
public bool IsRemote => Sequence is { Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly };
}
/// <summary>What this PC can do right now.</summary>
/// <param name="HasEngine">The index and the job engine are open.</param>
/// <param name="IsSignedIn">A server session is open (uploads, downloads, remote cards).</param>
public sealed record SelectionContext(bool HasEngine, bool IsSignedIn, SyncRights Rights);
/// <summary>
/// Which selected sequences each mass action works on and, when it works on none, why (the disabled button's
/// tooltip, DESIGN §4). Archive actions touch sequences on this PC; Upload and Download follow the sync table's own
/// row actions (<see cref="SyncText.Actions"/>), so the Library and the Server screen never disagree.
/// </summary>
public static class MassActions
{
/// <summary>The selected sequences <paramref name="action"/> works on.</summary>
public static IReadOnlyList<SelectedSequence> Targets(MassAction action, IReadOnlyList<SelectedSequence> selection, SelectionContext context) => action switch
{
MassAction.ExportList => selection,
MassAction.Upload => [.. selection.Where(s => !s.IsRemote && UploadStep(s, context.Rights) is not null)],
MassAction.Download => [.. selection.Where(s => DownloadStep(s, context.Rights) is not null)],
_ => [.. selection.Where(s => !s.IsRemote)],
};
/// <summary>Why <paramref name="action"/> cannot run on the selection, localized; null when it can.</summary>
public static string? Blocker(MassAction action, IReadOnlyList<SelectedSequence> selection, SelectionContext context)
{
if (selection.Count == 0) return Loc.L("Library.Blocked.NoSelection");
if (action == MassAction.ExportList) return null;
if (!context.HasEngine) return Loc.L("Library.Blocked.NoIndex");
var targets = Targets(action, selection, context);
switch (action)
{
case MassAction.Upload or MassAction.Download when !context.IsSignedIn:
return Loc.L("Library.Blocked.NotConnected");
case MassAction.Upload when !context.Rights.CanUpload:
return Loc.L("Library.Blocked.NoUploadRight");
case MassAction.Download when !context.Rights.CanFetchOriginals:
return Loc.L("Library.Blocked.NoDownloadRight");
case MassAction.Upload when targets.Count == 0:
return Loc.L("Library.Blocked.NothingToUpload");
case MassAction.Download when targets.Count == 0:
return Loc.L("Library.Blocked.NothingToDownload");
case MassAction.Upload or MassAction.Download:
return null;
}
if (targets.Count == 0) return Loc.L("Library.Blocked.ServerOnly");
return action == MassAction.Move && targets.Select(t => t.Sequence.ArchiveId).Distinct().Count() > 1 ? Loc.L("Library.Blocked.Archives") : null;
}
/// <summary>The enabled tooltip: what the action does to how many sequences.</summary>
public static string ToolTip(MassAction action, int targets) => Loc.Plural("Tooltips.Library.Mass." + action, targets);
/// <summary>What an upload of a selected local sequence sends: its originals and settings, or only its renders; null when nothing.</summary>
public static SyncAction? UploadStep(SelectedSequence selected, SyncRights rights)
{
// Compared before the table lists it: the sequence is only here.
if (selected.Sync is not { } entry) return rights.CanUpload && !selected.IsRemote ? SyncAction.Upload : null;
var actions = SyncText.Actions(entry, rights);
return actions.Contains(SyncAction.Upload) ? SyncAction.Upload : actions.Contains(SyncAction.SendExports) ? SyncAction.SendExports : null;
}
/// <summary>What a download of a selected sequence fetches: the server's originals, or only its renders; null when nothing.</summary>
public static SyncAction? DownloadStep(SelectedSequence selected, SyncRights rights)
{
if (selected.Sync is not { } entry) return null;
var actions = SyncText.Actions(entry, rights);
return actions.Contains(SyncAction.DownloadOriginals) ? SyncAction.DownloadOriginals : actions.Contains(SyncAction.GetExports) ? SyncAction.GetExports : null;
}
/// <summary>
/// The card's Sync quick action: the first transfer or settings exchange the sync table offers, or Resolve
/// (on the Server screen) for a conflict; null with <paramref name="blocker"/> when there is nothing to do.
/// </summary>
public static SyncAction? QuickSync(SelectedSequence selected, SelectionContext context, out string? blocker)
{
blocker = null;
if (!context.IsSignedIn)
{
blocker = Loc.L("Library.Blocked.NotConnected");
return null;
}
if (selected.Sync is not { } entry) return UploadStep(selected, context.Rights) ?? Blocked(Loc.L("Library.Blocked.NoUploadRight"), out blocker);
if (entry.Transfer is not null) return Blocked(Loc.L("Library.Blocked.Transferring"), out blocker);
if (entry.Status == SyncStatus.Conflict) return SyncAction.KeepMine;
var actions = SyncText.Actions(entry, context.Rights);
SyncAction[] preferred = [SyncAction.Upload, SyncAction.DownloadOriginals, SyncAction.SyncSettings, SyncAction.SendExports, SyncAction.GetExports];
foreach (var action in preferred)
{
if (actions.Contains(action)) return action;
}
return Blocked(Loc.L(entry.Status == SyncStatus.InSync ? "Library.Blocked.InSync" : "Library.Blocked.NoSyncRight"), out blocker);
static SyncAction? Blocked(string reason, out string? why)
{
why = reason;
return null;
}
}
}
+109
View File
@@ -0,0 +1,109 @@
using Titano.Core.Model;
using Titano.Data.Sync;
using Titano.Protocol;
namespace Titano.App.Library;
/// <summary>
/// Server sequences without a copy on this PC, as Library cards (BRIEF §4.4 mixed mode): from the sync table of the
/// signed-in server, with the details of the server's listing when it was read, else what the table keeps.
/// </summary>
public static class RemoteCards
{
/// <summary>Entries of the sync table that have no local copy (only on the server, or kept here as proxies).</summary>
public static IEnumerable<SyncEntry> RemoteOnly(IEnumerable<SyncEntry> entries) => entries.Where(e => e is { Local: null, Link: not null });
/// <summary>One card per remote-only entry: the listing's sequence when known, else the table's title, counts and status.</summary>
public static IReadOnlyList<Sequence> Build(IEnumerable<SyncEntry> entries, IReadOnlyDictionary<Guid, SequenceDto>? listing) =>
[
.. RemoteOnly(entries).Select(e => listing is not null && listing.TryGetValue(e.Link!.RemoteId, out var dto) ? ToSequence(dto) : FromLink(e.Link!)),
];
/// <summary>A server sequence as a card: origin server, remote only, no archive on this PC.</summary>
public static Sequence ToSequence(SequenceDto dto) => new()
{
Id = dto.Id,
ArchiveId = Guid.Empty,
Title = dto.Title,
Folder = dto.Folder,
CameraMake = dto.CameraMake,
CameraModel = dto.CameraModel,
Lens = dto.Lens,
FirstCapture = dto.FirstCapture,
LastCapture = dto.LastCapture,
FrameCount = dto.FrameCount,
MedianInterval = dto.MedianInterval,
TotalBytes = dto.TotalBytes,
Status = (SequenceStatus)dto.Status,
RenderedCount = dto.RenderedCount,
HeroFrameId = dto.HeroFrameId,
Tags = dto.Tags,
Rating = dto.Rating,
Notes = dto.Notes,
SettingsVersion = dto.SettingsVersion,
FramesVersion = dto.FramesVersion,
WarningCount = dto.WarningCount,
OwnerUserId = dto.OwnerUserId,
UpdatedAt = dto.UpdatedAt,
Origin = SequenceOrigin.Server,
SyncState = SyncState.RemoteOnly,
};
/// <summary>What the sync table knows of a server sequence when its listing could not be read.</summary>
public static Sequence FromLink(SyncLink link) => new()
{
Id = link.RemoteId,
ArchiveId = Guid.Empty,
Title = link.Title,
Folder = string.Empty,
FrameCount = link.FrameCount,
TotalBytes = link.TotalBytes,
Status = link.RemoteStatus,
RenderedCount = link.RenderCount,
SettingsVersion = link.RemoteSettingsVersion,
FramesVersion = link.RemoteFramesVersion,
UpdatedAt = link.RemoteUpdatedAt,
Origin = SequenceOrigin.Server,
SyncState = SyncState.RemoteOnly,
};
}
/// <summary>
/// Interleaves remote cards with the index's pages in the order of the filter's sort: each page brings the remote
/// cards that sort before its last row; the last page brings the rest. Not thread-safe: call from one thread (the UI).
/// </summary>
public sealed class RemoteMerge
{
private readonly List<Sequence> _pending = [];
private LibraryFilter _filter = new();
/// <summary>Remote cards not yet handed out.</summary>
public int Pending => _pending.Count;
/// <summary>Starts over with the cards that match <paramref name="filter"/>, in its order.</summary>
public void Reset(LibraryFilter filter, IEnumerable<Sequence> remote)
{
_filter = filter;
_pending.Clear();
if (filter.Origin != OriginFilter.Local) _pending.AddRange(remote.Where(filter.Matches));
_pending.Sort(filter.Compare);
}
/// <summary>A page of the index with the remote cards that belong among it, in order; <paramref name="last"/> adds every card left.</summary>
public IReadOnlyList<Sequence> Merge(IReadOnlyList<Sequence> page, bool last)
{
var take = last ? _pending.Count
: page.Count == 0 ? 0
: _pending.FindIndex(r => _filter.Compare(r, page[^1]) > 0) is var after and >= 0 ? after : _pending.Count;
if (take == 0) return page;
var merged = new List<Sequence>(page.Count + take);
int a = 0, b = 0;
while (a < page.Count || b < take)
{
if (b >= take || (a < page.Count && _filter.Compare(page[a], _pending[b]) <= 0)) merged.Add(page[a++]);
else merged.Add(_pending[b++]);
}
_pending.RemoveRange(0, take);
return merged;
}
}
@@ -0,0 +1,87 @@
using System.Collections.Concurrent;
using System.IO;
using System.Windows.Media;
using Titano.Core.Model;
using Titano.Data.Sync;
using Titano.Ui.Visuals;
namespace Titano.App.Library;
/// <summary>Hero thumbnails (and hover-scrub frames, where there are any) of the Library's cards.</summary>
public interface ISequenceThumbnails
{
Task<ImageSource?> HeroAsync(Sequence sequence, int pixelWidth, CancellationToken ct);
/// <summary>Frames for hover scrubbing; null when the sequence has none to scrub.</summary>
IThumbnailSource? ScrubSource(Sequence sequence);
}
/// <summary>The signed-in server as remote cards see it: its sync engine, its key and a connection.</summary>
public sealed record RemoteSource(SyncService Service, string Server, ISyncRemote Remote);
/// <summary>
/// Thumbnails of server sequences without a copy here (BRIEF §4.4): the hero frame (else the first) from the proxy
/// cache when the sequence was fetched with proxies, otherwise the server's thumbnail of that frame through the API.
/// Decoded at a 64 px width step and kept in an LRU cache; failed downloads are not cached, so they are tried again.
/// </summary>
public sealed class RemoteThumbnails(Func<RemoteSource?> source, int capacity = 256) : ISequenceThumbnails, IDisposable
{
private const int WidthStep = 64;
private readonly ConcurrentDictionary<Guid, Guid?> _heroes = new();
private ThumbnailCache<(Guid Sequence, int Width), ImageSource>? _cache;
private ThumbnailCache<(Guid Sequence, int Width), ImageSource> Cache => _cache ??= new(capacity, LoadAsync, maxConcurrentLoads: 4);
public Task<ImageSource?> HeroAsync(Sequence sequence, int pixelWidth, CancellationToken ct)
{
_heroes[sequence.Id] = sequence.HeroFrameId;
return Cache.GetAsync((sequence.Id, Math.Clamp((pixelWidth + WidthStep - 1) / WidthStep * WidthStep, WidthStep, 1024)), ct);
}
/// <summary>Remote cards do not scrub: every frame would be a download.</summary>
public IThumbnailSource? ScrubSource(Sequence sequence) => null;
/// <summary>Forgets every thumbnail (another server, or the cache was cleared).</summary>
public void Clear() => _cache?.Clear();
public void Dispose() => _cache?.Dispose();
private async Task<ImageSource?> LoadAsync((Guid Sequence, int Width) key, CancellationToken ct)
{
if (source() is not { } connection) return null;
var hero = _heroes.GetValueOrDefault(key.Sequence);
if (connection.Service.OpenRemote(connection.Server, key.Sequence) is { CachedCount: > 0 } cached)
{
var index = hero is { } id ? IndexOf(cached.Frames, id) : -1;
if (index < 0 || cached.Files[index] is null) index = FirstCached(cached.Files);
await using var file = new FileStream(cached.Files[index]!, FileMode.Open, FileAccess.Read, FileShare.Read, 1 << 16, FileOptions.Asynchronous);
return ThumbnailService.DecodeStream(file, cached.Frames[index].Orientation, key.Width);
}
var frameId = hero ?? (await connection.Remote.GetManifestAsync(key.Sequence, ct).ConfigureAwait(false)).Frames.FirstOrDefault()?.Id;
if (frameId is null) return null;
using var thumbnail = new MemoryStream();
await connection.Remote.DownloadFrameAsync(frameId.Value, "thumb", thumbnail, ct).ConfigureAwait(false);
thumbnail.Position = 0;
// The server draws its thumbnails upright.
return ThumbnailService.DecodeStream(thumbnail, 1, key.Width);
}
private static int IndexOf(IReadOnlyList<Frame> frames, Guid id)
{
for (var i = 0; i < frames.Count; i++)
{
if (frames[i].Id == id) return i;
}
return -1;
}
private static int FirstCached(IReadOnlyList<string?> files)
{
for (var i = 0; i < files.Count; i++)
{
if (files[i] is not null) return i;
}
return -1;
}
}
+91
View File
@@ -0,0 +1,91 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Titano.Core.Diagnostics;
using Titano.Core.Localization;
using Titano.Data.Repositories;
namespace Titano.App.Library;
/// <summary>A named set of Library filters and sort ("Night, 4K, not analysed"), BRIEF §12.2.</summary>
public sealed record SavedView
{
public const int MaxName = 40;
public required Guid Id { get; init; }
public required string Name { get; init; }
public string? Text { get; init; }
public int? Year { get; init; }
public string? Camera { get; init; }
public StatusFilter Status { get; init; }
public string? Tag { get; init; }
public OriginFilter Origin { get; init; }
public SequenceSort Sort { get; init; } = SequenceSort.Newest;
public static SavedView Of(Guid id, string name, LibraryFilter filter) => new()
{
Id = id,
Name = name.Trim(),
Text = string.IsNullOrWhiteSpace(filter.Text) ? null : filter.Text.Trim(),
Year = filter.Year,
Camera = filter.Camera,
Status = filter.Status,
Tag = filter.Tag,
Origin = filter.Origin,
Sort = filter.Sort,
};
public LibraryFilter ToFilter() => new() { Text = Text, Year = Year, Camera = Camera, Status = Status, Tag = Tag, Origin = Origin, Sort = Sort };
/// <summary>The Library shows exactly this view (search text compared trimmed and case-insensitively).</summary>
public bool Matches(LibraryFilter filter) =>
string.Equals(Text ?? string.Empty, filter.Text?.Trim() ?? string.Empty, StringComparison.OrdinalIgnoreCase)
&& Year == filter.Year && Camera == filter.Camera && Status == filter.Status && Tag == filter.Tag && Origin == filter.Origin && Sort == filter.Sort;
/// <summary>The problem of a view name, localized; null when it can be used.</summary>
/// <param name="others">Names of the other saved views (a name is used once).</param>
public static string? Validate(string? name, IEnumerable<string> others)
{
var trimmed = name?.Trim() ?? string.Empty;
if (trimmed.Length == 0) return Loc.L("Library.Views.Error.Empty");
if (trimmed.Length > MaxName || trimmed.Any(char.IsControl)) return Loc.L("Library.Views.Error.Long", MaxName);
return others.Contains(trimmed, StringComparer.CurrentCultureIgnoreCase) ? Loc.L("Library.Views.Error.Taken") : null;
}
}
/// <summary>Saved views as app-scope settings rows (<c>library.view.&lt;id&gt;</c>), one row per view.</summary>
public sealed class SavedViewStore(SettingsRepository settings)
{
private const string Prefix = "library.view.";
/// <summary>Every saved view by name; unreadable rows are skipped.</summary>
public async Task<IReadOnlyList<SavedView>> ListAsync(CancellationToken cancellationToken = default)
{
var views = new List<SavedView>();
foreach (var (key, json) in await settings.ListAsync(SettingScope.App, null, cancellationToken))
{
if (!key.StartsWith(Prefix, StringComparison.Ordinal)) continue;
try
{
if (JsonSerializer.Deserialize(json, SavedViewJson.Default.SavedView) is { } view) views.Add(view);
}
catch (JsonException ex)
{
Log.Warning("library", $"Saved view {key} is unreadable", ex);
}
}
return [.. views.OrderBy(v => v.Name, StringComparer.CurrentCultureIgnoreCase)];
}
/// <summary>Adds the view or replaces the one with its id.</summary>
public Task SaveAsync(SavedView view, CancellationToken cancellationToken = default) =>
settings.SetAsync(SettingScope.App, null, Key(view.Id), view, SavedViewJson.Default.SavedView, cancellationToken);
public Task<bool> DeleteAsync(Guid id, CancellationToken cancellationToken = default) => settings.DeleteAsync(SettingScope.App, null, Key(id), cancellationToken);
private static string Key(Guid id) => Prefix + id.ToString("N");
}
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
UseStringEnumConverter = true)]
[JsonSerializable(typeof(SavedView))]
internal sealed partial class SavedViewJson : JsonSerializerContext;
+54 -3
View File
@@ -1,20 +1,29 @@
using System.Text.Json;
using System.Windows.Media;
using Titano.App.Infrastructure;
using Titano.Core.Diagnostics;
using Titano.Core.Export;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Core.Naming;
using Titano.Core.Project;
using Titano.Data.Processing;
using Titano.Data.Sync;
using Titano.Ui.Controls;
using Titano.Ui.Mvvm;
using Titano.Ui.Visuals;
namespace Titano.App.Library;
/// <summary>One sequence of the Library grid and list (BRIEF §12.2).</summary>
/// <summary>One sequence of the Library grid and list (BRIEF §12.2): on this PC, or a server sequence without a copy here (a remote card).</summary>
public sealed class SequenceItem : ObservableObject
{
private readonly ThumbnailService? _thumbnails;
private readonly ISequenceThumbnails? _thumbnails;
private Sequence _sequence;
private SyncEntry? _sync;
private string? _syncToolTip;
private bool _canSync;
private string? _presetName;
private ImageSource? _thumbnail;
private IThumbnailSource? _scrub;
private CancellationTokenSource? _loading;
@@ -22,7 +31,7 @@ public sealed class SequenceItem : ObservableObject
private bool _isSelected;
private bool _isAnalysing;
public SequenceItem(Sequence sequence, ThumbnailService? thumbnails)
public SequenceItem(Sequence sequence, ISequenceThumbnails? thumbnails)
{
_sequence = sequence;
_thumbnails = thumbnails;
@@ -31,6 +40,23 @@ public sealed class SequenceItem : ObservableObject
public Sequence Sequence => _sequence;
public Guid Id => _sequence.Id;
/// <summary>Only on the signed-in server (the editor opens it with proxies; archive actions do not apply).</summary>
public bool IsRemote => _sequence is { Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly };
/// <summary>Its row of the sync table of the signed-in server; null while signed out or not compared yet.</summary>
public SyncEntry? Sync => _sync;
/// <summary>The Sync quick action can run (<see cref="SyncToolTip"/> says what it does, or why not).</summary>
public bool CanSync => _canSync;
public string SyncToolTip => _syncToolTip ?? Loc.L("Library.Blocked.NotConnected");
/// <summary>"Render · 4K archive": the preset the Render quick action queues, the recommended one or the default.</summary>
public string RenderToolTip => Loc.L(IsRemote ? "Tooltips.Library.QuickRenderServer" : "Tooltips.Library.QuickRender", PresetName);
/// <summary>The export preset of the sequence's project (the advisor's choice when it made one, else the default).</summary>
public string PresetName => _presetName ??= ResolvePreset(_sequence.SettingsJson);
/// <summary>User title or "{date} {camera}".</summary>
public string Title => _sequence.DisplayTitle;
@@ -70,6 +96,17 @@ public sealed class SequenceItem : ObservableObject
/// <summary>Frames for hover scrubbing; created on first use.</summary>
public IThumbnailSource? ScrubSource => _thumbnails is null || _sequence.FrameCount == 0 ? null : _scrub ??= _thumbnails.ScrubSource(_sequence);
/// <summary>The sync table's row of this sequence and what its Sync quick action does (or why it cannot).</summary>
public void SetSync(SyncEntry? entry, bool canSync, string toolTip)
{
_sync = entry;
_canSync = canSync;
_syncToolTip = toolTip;
OnPropertyChanged(nameof(Sync));
OnPropertyChanged(nameof(CanSync));
OnPropertyChanged(nameof(SyncToolTip));
}
public bool IsSelected
{
get => _isSelected;
@@ -90,6 +127,7 @@ public sealed class SequenceItem : ObservableObject
public void Update(Sequence sequence)
{
var heroChanged = sequence.HeroFrameId != _sequence.HeroFrameId || sequence.FrameCount != _sequence.FrameCount;
if (sequence.SettingsJson != _sequence.SettingsJson) _presetName = null;
_sequence = sequence;
if (heroChanged)
{
@@ -141,6 +179,19 @@ public sealed class SequenceItem : ObservableObject
}
}
private static string ResolvePreset(string? settingsJson)
{
try
{
var project = settingsJson is null ? new ProjectSettings() : ProjectSettings.FromJson(settingsJson);
return ProcessingJobs.PresetName(ExportResolver.Resolve(project.Export));
}
catch (JsonException)
{
return ProcessingJobs.PresetName(ExportResolver.Resolve(new ExportSettings()));
}
}
private void RaiseStatuses()
{
OnPropertyChanged(nameof(Statuses));
+3 -1
View File
@@ -17,7 +17,7 @@ public readonly record struct ThumbnailKey(Guid FrameId, int Width);
/// original and decoded by WIC at the requested width (falling back to decoding the original), turned upright,
/// frozen and kept in an LRU cache. Loads run off the UI thread and stop when the card scrolls away.
/// </summary>
public sealed class ThumbnailService : IDisposable
public sealed class ThumbnailService : ISequenceThumbnails, IDisposable
{
/// <summary>Embedded previews larger than this are not read (a damaged index would make us read gigabytes).</summary>
private const long MaxPreviewBytes = 64L << 20;
@@ -81,6 +81,8 @@ public sealed class ThumbnailService : IDisposable
/// <summary>Hover-scrub frames of a sequence, sampled to at most <paramref name="positions"/> positions.</summary>
public IThumbnailSource ScrubSource(Sequence sequence, int positions = 120) => new ScrubFrames(this, sequence, positions);
IThumbnailSource? ISequenceThumbnails.ScrubSource(Sequence sequence) => ScrubSource(sequence);
/// <summary>Drops decoded thumbnails (Settings › Storage › Clear).</summary>
public void Clear()
{
@@ -0,0 +1,52 @@
using System.Windows.Input;
using Titano.App.Archiving;
using Titano.App.Settings;
using Titano.Core.Localization;
using Titano.Ui.Mvvm;
namespace Titano.App.Library;
/// <summary>Names a saved view: "Save view" (the current filters under a new name) or "Rename view".</summary>
public sealed class ViewNameDialogViewModel : ArchiveDialogViewModel
{
private readonly Func<string, Task> _save;
/// <param name="others">Names of the other saved views (each name is used once).</param>
public ViewNameDialogViewModel(bool rename, string name, IReadOnlyList<string> others, Func<string, Task> save, Action<ArchiveDialogViewModel> close)
: base(close)
{
IsRename = rename;
_save = save;
Name = new EditableField(name, n => SavedView.Validate(n, others), _ => { }, () => Loc.L("Tooltips.Library.ViewName"));
Name.PropertyChanged += (_, _) =>
{
OnPropertyChanged(nameof(SaveToolTip));
CommandManager.InvalidateRequerySuggested();
};
SaveCommand = new AsyncRelayCommand(SaveAsync, () => !IsBusy && !Name.HasErrors);
}
public bool IsRename { get; }
public string Heading => Loc.L(IsRename ? "Library.Views.RenameHeading" : "Library.Views.SaveHeading");
public EditableField Name { get; }
public ICommand SaveCommand { get; }
public string SaveToolTip => Name.Error ?? Loc.L(IsRename ? "Tooltips.Library.ViewRenameApply" : "Tooltips.Library.ViewSaveApply");
private async Task SaveAsync()
{
IsBusy = true;
try
{
await _save(Name.Text.Trim());
Close();
}
finally
{
IsBusy = false;
}
}
}
+32 -151
View File
@@ -7,156 +7,34 @@
xmlns:ar="clr-namespace:Titano.App.Archiving"
xmlns:shell="clr-namespace:Titano.App.Shell">
<UserControl.Resources>
<Style x:Key="Text.PanelHeading" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}">
<Setter Property="FontSize" Value="13" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="Button.Bar" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="0,0,8,0" />
</Style>
<Style x:Key="Button.Tool" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Margin" Value="0,0,8,8" />
</Style>
<!-- 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="AutomationProperties.Name" Value="{Binding To}" />
</Style>
<!-- Report rows with their own buttons: Tab reaches every button. -->
<Style x:Key="ListBoxItem.Duplicate" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.Title}" />
</Style>
<!-- A filter menu: its values, each checked while chosen. -->
<Style x:Key="MenuItem.Choice" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Label}" />
<Setter Property="IsChecked" Value="{Binding IsChecked, Mode=OneWay}" />
<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Archive.FilterChoice}" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
</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}" />
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Stroke}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="{StaticResource Radius.Dialog}" />
<Setter Property="Padding" Value="24,18,24,20" />
<Setter Property="Effect" Value="{StaticResource Shadow.Popup}" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<DataTemplate DataType="{x:Type ar:RebuildDialogViewModel}">
<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.ItemTemplate>
<DataTemplate DataType="{x:Type ar:DialogFact}">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<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" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBlock Text="{Binding BusyText}" Foreground="{DynamicResource Brush.TextMuted}" 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" />
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Archive.Rebuild.Start}" Command="{Binding RebuildCommand}" ToolTip="{Binding RebuildToolTip}"
MinWidth="96" Margin="8,0,0,0" />
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type ar:RenameDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="720" MaxHeight="560">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<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="*" />
</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}" />
</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"
AutomationProperties.Name="{l:Loc Archive.Rename.Preview}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type ar:RenameRow}">
<Grid Height="30" TextElement.FontSize="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="120" />
<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}" />
</Grid>
</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" />
</DockPanel>
</Grid>
</Border>
</DataTemplate>
<DataTemplate DataType="{x:Type ar:RetagDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="520">
<StackPanel>
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<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}" />
<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" />
<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>
<TextBlock Text="{Binding SummaryText}" Foreground="{DynamicResource Brush.TextMuted}" Margin="0,12,0,0" Typography.NumeralAlignment="Tabular" />
<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" />
</DockPanel>
</StackPanel>
</Border>
</DataTemplate>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Titano;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="Text.PanelHeading" TargetType="TextBlock" BasedOn="{StaticResource Text.Section}">
<Setter Property="FontSize" Value="13" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="Button.Bar" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="0,0,8,0" />
</Style>
<Style x:Key="Button.Tool" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Margin" Value="0,0,8,8" />
</Style>
<!-- Report rows with their own buttons: Tab reaches every button. -->
<Style x:Key="ListBoxItem.Duplicate" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.PlainRow}">
<Setter Property="AutomationProperties.Name" Value="{Binding Row.Title}" />
</Style>
<!-- A filter menu: its values, each checked while chosen. -->
<Style x:Key="MenuItem.Choice" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Label}" />
<Setter Property="IsChecked" Value="{Binding IsChecked, Mode=OneWay}" />
<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Archive.FilterChoice}" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
@@ -203,6 +81,7 @@
<MenuItem Header="{l:Loc Archive.Maintenance.DryRun}" Command="{Binding MaintenanceDryRunCommand}" ToolTip="{l:Loc Tooltips.Archive.MaintenanceDryRun}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.Proxies}" Command="{Binding RebuildProxiesCommand}" ToolTip="{Binding RebuildProxiesToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.Backup}" Command="{Binding BackupCommand}" ToolTip="{l:Loc Tooltips.Archive.Backup}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Archive.Maintenance.Trash}" Command="{Binding TrashCommand}" ToolTip="{l:Loc Tooltips.Archive.Trash}" ToolTipService.ShowOnDisabled="True" />
<Separator />
<MenuItem Header="{l:Loc Archive.Maintenance.Relink}" Command="{Binding RelinkCommand}" ToolTip="{l:Loc Tooltips.Archive.Relink}" ToolTipService.ShowOnDisabled="True" />
</ContextMenu>
@@ -513,6 +392,8 @@
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Move}" Command="{Binding MoveSetCommand}" ToolTip="{Binding MoveSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Retag}" Command="{Binding RetagSetCommand}" ToolTip="{Binding RetagSetToolTip}" />
<Button Style="{StaticResource Button.Bar}" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Export}" Command="{Binding ExportSetCommand}" ToolTip="{Binding ExportSetToolTip}" />
<Button Style="{StaticResource Button.Destructive}" Height="30" Margin="0,0,8,8" Content="{l:Loc Archive.Set.Delete}" Command="{Binding DeleteSetCommand}"
ToolTip="{Binding DeleteSetToolTip}" />
</WrapPanel>
</Border>
@@ -521,7 +402,7 @@
</ui:EmptyState>
</Grid>
<!-- In-window dialogs (rebuild, rename, retag) over a scrim; the keyboard stays inside the dialog. -->
<!-- In-window dialogs (rebuild, rename, retag, trash) over a scrim; the keyboard stays inside the dialog. -->
<Grid Visibility="{Binding IsDialogOpen, Converter={StaticResource BoolToVisibility}}" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border Background="{DynamicResource Brush.Scrim}" />
+27 -3
View File
@@ -25,8 +25,9 @@ namespace Titano.App.Sections;
/// <summary>
/// Archive manager (BRIEF §12.5, Archive.html): the archive's tree (years, sequences) with its availability, its
/// figures and charts, mass operations on the selected and filtered set (analyse, proxies, thumbnails, verify, rename,
/// move, retag, CSV), and the operations on the whole archive as jobs (scan, rebuild with its dialog, verify,
/// maintenance), plus the maintenance view: index health, duplicates and orphans with safe fixes, recent runs. The
/// move, retag, CSV, delete into the trash), and the operations on the whole archive as jobs (scan, rebuild with its
/// dialog, verify, maintenance), the trash, plus the maintenance view: index health, duplicates and orphans with safe
/// fixes, recent runs. The
/// tree selection is only ever changed by the user: reloads and expanding keep it.
/// </summary>
public sealed class ArchiveViewModel : SectionViewModel
@@ -96,6 +97,8 @@ public sealed class ArchiveViewModel : SectionViewModel
MoveSetCommand = new AsyncRelayCommand(() => OpenRenameDialogAsync(RenameMode.Folders), () => HasSet() && IsOnline());
RetagSetCommand = new RelayCommand(OpenRetag, () => HasSet() && IsOnline());
ExportSetCommand = new AsyncRelayCommand(ExportAsync, HasSet);
DeleteSetCommand = new AsyncRelayCommand(() => SequenceDeletion.RunAsync(Shell, [.. Set().Select(s => s.Id)]), () => HasSet() && IsOnline());
TrashCommand = new AsyncRelayCommand(OpenTrashAsync, () => _archive is not null);
FindDuplicatesCommand = new AsyncRelayCommand(FindDuplicatesAsync, () => _archive is not null && _search is null);
FindOrphansCommand = new AsyncRelayCommand(FindOrphansAsync, () => IsOnline() && _search is null);
@@ -161,6 +164,7 @@ public sealed class ArchiveViewModel : SectionViewModel
public string RenameSetToolTip => WhenSet("Tooltips.Archive.SetRename", needsOnline: true);
public string MoveSetToolTip => WhenSet("Tooltips.Archive.SetMove", needsOnline: true);
public string RetagSetToolTip => WhenSet("Tooltips.Archive.SetRetag", needsOnline: true);
public string DeleteSetToolTip => WhenSet("Tooltips.Archive.SetDelete", needsOnline: true);
public ICommand ScanCommand { get; }
public ICommand RebuildCommand { get; }
@@ -177,6 +181,9 @@ public sealed class ArchiveViewModel : SectionViewModel
public ICommand RelinkCommand { get; }
public ICommand HistoryCommand { get; }
/// <summary>"Maintenance ▾ › Trash…": the sequences deleted from this archive, each restorable.</summary>
public ICommand TrashCommand { get; }
// ---------------- Overview ----------------
public ObservableCollection<ArchiveTreeRowViewModel> TreeRows { get; } = [];
@@ -239,6 +246,9 @@ public sealed class ArchiveViewModel : SectionViewModel
public ICommand RetagSetCommand { get; }
public ICommand ExportSetCommand { get; }
/// <summary>Moves the set to the archive's trash after its dry run and a typed confirmation.</summary>
public ICommand DeleteSetCommand { get; }
/// <summary>The view reports the rows the user selected; the list's own clearing while rows are rebuilt is not a choice.</summary>
public void SetSelection(IEnumerable<ArchiveTreeRowViewModel> rows)
{
@@ -310,7 +320,7 @@ public sealed class ArchiveViewModel : SectionViewModel
// ---------------- Dialogs ----------------
/// <summary>The open in-window dialog (rebuild, rename, retag); null when none.</summary>
/// <summary>The open in-window dialog (rebuild, rename, retag, trash); null when none.</summary>
public ArchiveDialogViewModel? Dialog
{
get => _dialog;
@@ -499,6 +509,7 @@ public sealed class ArchiveViewModel : SectionViewModel
OnPropertyChanged(nameof(RenameSetToolTip));
OnPropertyChanged(nameof(MoveSetToolTip));
OnPropertyChanged(nameof(RetagSetToolTip));
OnPropertyChanged(nameof(DeleteSetToolTip));
CommandManager.InvalidateRequerySuggested();
}
@@ -625,6 +636,19 @@ public sealed class ArchiveViewModel : SectionViewModel
await dialog.PlanAsync();
}
/// <summary>Opens the trash of the archive and reads it.</summary>
public async Task OpenTrashAsync()
{
if (Services.Archives is not { } archives || _archive is not { } archive) return;
var dialog = new TrashDialogViewModel(archives, archive, async () =>
{
await LoadAsync();
await Shell.Library.RefreshAsync();
}, CloseDialog);
OpenDialog(dialog);
await dialog.LoadAsync();
}
private void OpenRetag()
{
if (Services.Archives is not { } archives) return;
+338 -186
View File
@@ -4,180 +4,310 @@
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
xmlns:lib="clr-namespace:Titano.App.Library">
xmlns:lib="clr-namespace:Titano.App.Library"
xmlns:shell="clr-namespace:Titano.App.Shell">
<UserControl.Resources>
<Style x:Key="ListBoxItem.LibraryCard" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Card}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
</Style>
<Style x:Key="ListBoxItem.LibraryRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Height" Value="38" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
</Style>
<Style x:Key="Button.Header" TargetType="Button" BasedOn="{StaticResource Button.Subtle}">
<Setter Property="Height" Value="28" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="ui:ControlState.HoverBackground" Value="Transparent" />
</Style>
<DataTemplate x:Key="Template.Status" DataType="{x:Type v:CardStatus}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ToolTip}" Margin="0,0,8,0" />
</DataTemplate>
<ItemsPanelTemplate x:Key="Panel.Row">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Titano;component/Archive/ArchiveDialogs.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="ListBoxItem.LibraryCard" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Card}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
</Style>
<Style x:Key="ListBoxItem.LibraryRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
<Setter Property="Height" Value="38" />
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
</Style>
<Style x:Key="Button.Header" TargetType="Button" BasedOn="{StaticResource Button.Subtle}">
<Setter Property="Height" Value="28" />
<Setter Property="MinWidth" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontSize" Value="11" />
<Setter Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="ui:ControlState.HoverBackground" Value="Transparent" />
</Style>
<Style x:Key="Button.Bar" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="0,0,8,8" />
</Style>
<!-- Quick actions revealed on a card (28 px) or a row (26 px, DESIGN §4). -->
<Style x:Key="Button.Quick" TargetType="Button" BasedOn="{StaticResource Button.Icon}">
<Setter Property="Width" Value="28" />
<Setter Property="Height" Value="28" />
<Setter Property="MinWidth" Value="28" />
<Setter Property="Margin" Value="6,0,0,0" />
</Style>
<Style x:Key="Button.RowQuick" TargetType="Button" BasedOn="{StaticResource Button.Quick}">
<Setter Property="Width" Value="26" />
<Setter Property="Height" Value="26" />
<Setter Property="MinWidth" Value="26" />
</Style>
<!-- A menu of choices (saved views, ratings): each checked while it is the one in force. -->
<Style x:Key="MenuItem.View" TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Label}" />
<Setter Property="IsChecked" Value="{Binding IsChecked, Mode=OneWay}" />
<Setter Property="Command" Value="{Binding Command}" />
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Library.ViewChoice}" />
</Style>
<Style x:Key="MenuItem.Rating" TargetType="MenuItem" BasedOn="{StaticResource MenuItem.View}">
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Library.RateChoice}" />
</Style>
<DataTemplate x:Key="Template.Status" DataType="{x:Type v:CardStatus}">
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ToolTip}" Margin="0,0,8,0" />
</DataTemplate>
<ItemsPanelTemplate x:Key="Panel.Row">
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
<!-- Save view / Rename view: one name field. -->
<DataTemplate DataType="{x:Type lib:ViewNameDialogViewModel}">
<Border Style="{StaticResource Border.Dialog}" Width="460">
<StackPanel>
<TextBlock Text="{Binding Heading}" Style="{StaticResource Text.Title}" />
<Grid Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{StaticResource Grid.LabelColumn}" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{l:Loc Library.Views.Name}" Style="{StaticResource Text.Label}" />
<TextBox Grid.Column="1" Text="{Binding Name.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" shell:EditBehavior.Field="{Binding Name}"
ToolTip="{Binding Name.ToolTip}" AutomationProperties.Name="{l:Loc Library.Views.Name}" />
</Grid>
<DockPanel Margin="0,18,0,0">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Views.Save}" Command="{Binding SaveCommand}"
ToolTip="{Binding SaveToolTip}" IsDefault="True" 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" />
</DockPanel>
</StackPanel>
</Border>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="56" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid IsEnabled="{Binding IsContentEnabled}">
<Grid.RowDefinitions>
<RowDefinition Height="56" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- Toolbar (Main.html): search, filters, sort · view switch, rescan. -->
<DockPanel Grid.ColumnSpan="2" Margin="20,0" LastChildFill="False">
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Icon}" ui:ButtonIcon.Glyph="{StaticResource Icon.Refresh}" Command="{Binding RescanCommand}"
ToolTip="{l:Loc Tooltips.Library.Rescan}" AutomationProperties.Name="{l:Loc Library.Rescan}" Margin="10,0,0,0" />
<v:SegmentedControl DockPanel.Dock="Right" SelectedIndex="{Binding LayoutIndex, Mode=TwoWay}" AutomationProperties.Name="{l:Loc Library.View}">
<v:SegmentedItem Glyph="{StaticResource Icon.ViewGrid}" ToolTip="{l:Loc Tooltips.Library.Grid}" AutomationProperties.Name="{l:Loc Library.View.Grid}" />
<v:SegmentedItem Glyph="{StaticResource Icon.ViewList}" ToolTip="{l:Loc Tooltips.Library.List}" AutomationProperties.Name="{l:Loc Library.View.List}" />
</v:SegmentedControl>
<TextBox Width="260" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Library.Search}" ToolTip="{l:Loc Tooltips.Library.Search}" AutomationProperties.Name="{l:Loc Library.Search}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Years}" SelectedItem="{Binding SelectedYear}" Tag="{Binding IsYearFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Year}" AutomationProperties.Name="{l:Loc Library.Filter.Year}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Cameras}" SelectedItem="{Binding SelectedCamera}" Tag="{Binding IsCameraFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Camera}" AutomationProperties.Name="{l:Loc Library.Filter.Camera}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Statuses}" SelectedItem="{Binding SelectedStatus}" Tag="{Binding IsStatusFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Status}" AutomationProperties.Name="{l:Loc Library.Filter.Status}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Tags}" SelectedItem="{Binding SelectedTag}" Tag="{Binding IsTagFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Tags}" AutomationProperties.Name="{l:Loc Library.Filter.Tags}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Sorts}" SelectedItem="{Binding SelectedSort}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Sort}" AutomationProperties.Name="{l:Loc Library.Sort}" />
</DockPanel>
<!-- Grid view: virtualised, recycling card grid. -->
<ListBox x:Name="CardGrid" Grid.Row="1" Style="{StaticResource ListBox.Cards}" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource ListBoxItem.LibraryCard}"
Visibility="{Binding IsGrid, Converter={StaticResource BoolToVisibility}}" AutomationProperties.Name="{l:Loc Shell.Nav.Library}"
ScrollViewer.ScrollChanged="OnScrollChanged">
<ListBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenCommand}" />
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<v:SequenceCard Title="{Binding Title}" Subtitle="{Binding Subtitle}" Statuses="{Binding Statuses}" Thumbnail="{Binding Thumbnail}"
ScrubSource="{Binding ScrubSource}" lib:ThumbnailLoading.Width="236"
IsSelected="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}, Mode=TwoWay}"
SelectToolTip="{l:Loc Tooltips.Library.Select}" ToolTip="{l:Loc Tooltips.Library.Card}">
<v:SequenceCard.ActionsContent>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Button.Icon}" Width="28" Height="28" MinWidth="28" ui:ButtonIcon.Glyph="{StaticResource Icon.Sequence}"
Command="{Binding DataContext.OpenItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Open}" AutomationProperties.Name="{l:Loc Library.Action.Open}" Margin="0,0,6,0" />
<Button Style="{StaticResource Button.Icon}" Width="28" Height="28" MinWidth="28" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}"
Command="{Binding DataContext.AnalyseItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Analyse}" AutomationProperties.Name="{l:Loc Library.Action.Analyse}" />
</StackPanel>
</v:SequenceCard.ActionsContent>
</v:SequenceCard>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- List view: virtualised table with sortable headers. -->
<Border Grid.Row="1" Style="{StaticResource Border.Panel}" Margin="20,4,20,12" Visibility="{Binding IsList, Converter={StaticResource BoolToVisibility}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="180" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="170" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Button Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Sequence}" Command="{Binding SortByCommand}" CommandParameter="Title" ToolTip="{l:Loc Tooltips.Library.SortTitle}" />
<Button Grid.Column="1" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Date}" Command="{Binding SortByCommand}" CommandParameter="Date" ToolTip="{l:Loc Tooltips.Library.SortDate}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Camera}" Margin="10,0,0,0" />
<Button Grid.Column="3" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Frames}" HorizontalContentAlignment="Right" Command="{Binding SortByCommand}" CommandParameter="FrameCount" ToolTip="{l:Loc Tooltips.Library.SortFrames}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Span}" TextAlignment="Right" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Interval}" TextAlignment="Right" Margin="10,0,0,0" />
<Button Grid.Column="6" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Size}" HorizontalContentAlignment="Right" Command="{Binding SortByCommand}" CommandParameter="Size" ToolTip="{l:Loc Tooltips.Library.SortSize}" Margin="10,0,0,0" />
<TextBlock Grid.Column="7" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.State}" Margin="16,0,0,0" />
</Grid>
</Border>
<ListBox x:Name="RowList" Grid.Row="1" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource ListBoxItem.LibraryRow}" SelectionMode="Extended"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.ScrollChanged="OnScrollChanged" AutomationProperties.Name="{l:Loc Shell.Nav.Library}">
<ListBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenCommand}" />
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<Grid ToolTip="{l:Loc Tooltips.Library.Row}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="180" />
<ColumnDefinition Width="110" />
<ColumnDefinition Width="170" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="90" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding DateText}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding Camera}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.CellNumber}" Text="{Binding FramesText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.CellNumber}" Text="{Binding SpanText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.CellNumber}" Text="{Binding IntervalText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="6" Style="{StaticResource Text.CellNumber}" Text="{Binding SizeText}" Margin="10,0,0,0" />
<ItemsControl Grid.Column="7" Margin="16,0,0,0" ItemsSource="{Binding Statuses}" ItemTemplate="{StaticResource Template.Status}"
ItemsPanel="{StaticResource Panel.Row}" VerticalAlignment="Center" Focusable="False" ClipToBounds="True" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Toolbar (Main.html): search, filters, sort · saved views, layout switch, rescan. The search box gives way first. -->
<Grid Grid.ColumnSpan="2" Margin="20,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="140" MaxWidth="260" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBox VerticalAlignment="Center" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" ui:Field.Glyph="{StaticResource Icon.Search}"
ui:Field.Placeholder="{l:Loc Library.Search}" ToolTip="{l:Loc Tooltips.Library.Search}" AutomationProperties.Name="{l:Loc Library.Search}" />
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Years}" SelectedItem="{Binding SelectedYear}" Tag="{Binding IsYearFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Year}" AutomationProperties.Name="{l:Loc Library.Filter.Year}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" MaxWidth="170" ItemsSource="{Binding Cameras}" SelectedItem="{Binding SelectedCamera}"
Tag="{Binding IsCameraFiltered}" ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Camera}"
AutomationProperties.Name="{l:Loc Library.Filter.Camera}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Statuses}" SelectedItem="{Binding SelectedStatus}" Tag="{Binding IsStatusFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Status}" AutomationProperties.Name="{l:Loc Library.Filter.Status}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" MaxWidth="170" ItemsSource="{Binding Tags}" SelectedItem="{Binding SelectedTag}" Tag="{Binding IsTagFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Tags}" AutomationProperties.Name="{l:Loc Library.Filter.Tags}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Origins}" SelectedItem="{Binding SelectedOrigin}" Tag="{Binding IsOriginFiltered}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Origin}" AutomationProperties.Name="{l:Loc Library.Filter.Origin}"
Visibility="{Binding ShowsOrigin, Converter={StaticResource BoolToVisibility}}" />
<ComboBox Style="{StaticResource ComboBox.Filter}" Margin="10,0,0,0" ItemsSource="{Binding Sorts}" SelectedItem="{Binding SelectedSort}"
ItemTemplate="{StaticResource Template.FilterOption}" ToolTip="{l:Loc Tooltips.Library.Sort}" AutomationProperties.Name="{l:Loc Library.Sort}" />
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
<Button x:Name="ViewsButton" Click="OnOpenMenu" ui:ButtonIcon.Glyph="{StaticResource Icon.Filter}" ToolTip="{Binding ViewsToolTip}"
AutomationProperties.Name="{l:Loc Library.Views}" Margin="0,0,10,0">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource Button.Icon}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsViewActive}" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}" />
<Setter Property="Foreground" Value="{DynamicResource Brush.Accent}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="{l:Loc Library.Views.Apply}" ItemsSource="{Binding ViewChoices}" ItemContainerStyle="{StaticResource MenuItem.View}"
IsEnabled="{Binding HasViews}" ToolTip="{l:Loc Tooltips.Library.ViewsApply}" ToolTipService.ShowOnDisabled="True" />
<Separator />
<MenuItem Header="{l:Loc Library.Views.SaveMenu}" Command="{Binding SaveViewCommand}" ToolTip="{l:Loc Tooltips.Library.ViewSave}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Library.Views.RenameMenu}" Command="{Binding RenameViewCommand}" ToolTip="{l:Loc Tooltips.Library.ViewRename}"
ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Library.Views.Delete}" Command="{Binding DeleteViewCommand}" ToolTip="{l:Loc Tooltips.Library.ViewDelete}"
ToolTipService.ShowOnDisabled="True" />
</ContextMenu>
</Button.ContextMenu>
</Button>
<v:SegmentedControl SelectedIndex="{Binding LayoutIndex, Mode=TwoWay}" AutomationProperties.Name="{l:Loc Library.View}">
<v:SegmentedItem Glyph="{StaticResource Icon.ViewGrid}" ToolTip="{l:Loc Tooltips.Library.Grid}" AutomationProperties.Name="{l:Loc Library.View.Grid}" />
<v:SegmentedItem Glyph="{StaticResource Icon.ViewList}" ToolTip="{l:Loc Tooltips.Library.List}" AutomationProperties.Name="{l:Loc Library.View.List}" />
<v:SegmentedItem Glyph="{StaticResource Icon.ViewTimeline}" ToolTip="{l:Loc Tooltips.Library.Timeline}" AutomationProperties.Name="{l:Loc Library.View.Timeline}" />
</v:SegmentedControl>
<Button Style="{StaticResource Button.Icon}" ui:ButtonIcon.Glyph="{StaticResource Icon.Refresh}" Command="{Binding RescanCommand}"
ToolTip="{l:Loc Tooltips.Library.Rescan}" AutomationProperties.Name="{l:Loc Library.Rescan}" Margin="10,0,0,0" />
</StackPanel>
</Grid>
</Border>
<!-- Empty states: one sentence plus the first actions (Components.html). -->
<ui:EmptyState Grid.Row="1" Message="{l:Loc Library.Empty}" Visibility="{Binding IsLibraryEmpty, Converter={StaticResource BoolToVisibility}}">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Empty.ImportCard}" Command="{Binding ImportCardCommand}" ToolTip="{l:Loc Tooltips.Library.ImportCard}" Margin="0,0,8,0" />
<Button Content="{l:Loc Library.Empty.Adopt}" Command="{Binding AdoptFolderCommand}" ToolTip="{l:Loc Tooltips.Library.Adopt}" Margin="0,0,8,0" />
<Button Content="{l:Loc Library.Empty.Connect}" Command="{Binding ConnectCommand}" ToolTip="{l:Loc Tooltips.Library.Connect}" />
</StackPanel>
</ui:EmptyState>
<ui:EmptyState Grid.Row="1" Message="{l:Loc Library.NoMatch}" Visibility="{Binding IsNoMatch, Converter={StaticResource BoolToVisibility}}">
<Button Content="{l:Loc Library.ClearFilters}" Command="{Binding ClearFiltersCommand}" ToolTip="{l:Loc Tooltips.Library.ClearFilters}" />
</ui:EmptyState>
<!-- Timeline: one band per year, photos per month; a month narrows to its year and scrolls the grid to it. -->
<Border Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource Border.Panel}" Margin="20,4,20,8" Padding="14,8"
Visibility="{Binding IsTimeline, Converter={StaticResource BoolToVisibility}}">
<ScrollViewer MaxHeight="172" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
<v:TimelineBands x:Name="Timeline" Bands="{Binding TimelineBands}" SlotLabels="{Binding MonthLabels}" BandHeight="56"
CurrentBand="{Binding TimelineBand, Mode=OneWay}" CurrentSlot="{Binding TimelineSlot, Mode=OneWay}" ValueFormatter="{Binding CountFormatter}"
SlotActivated="OnSlotActivated" ToolTip="{l:Loc Tooltips.Library.TimelineBands}" AutomationProperties.Name="{l:Loc Library.View.Timeline}" />
</ScrollViewer>
</Border>
<!-- Selection panel (320 px, DESIGN §3). -->
<Border Grid.Row="1" Grid.Column="1" Width="320" Margin="0,4,20,12" Style="{StaticResource Border.Panel}" Padding="16"
Visibility="{Binding HasSelection, Converter={StaticResource BoolToVisibility}}">
<Grid>
<!-- One sequence -->
<ScrollViewer VerticalScrollBarVisibility="Auto" Focusable="False" DataContext="{Binding Selected}"
Visibility="{Binding DataContext.IsSingleSelection, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource BoolToVisibility}}">
<!-- Grid view (also under the timeline): virtualised, recycling card grid. -->
<ListBox x:Name="CardGrid" Grid.Row="2" Style="{StaticResource ListBox.Cards}" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource ListBoxItem.LibraryCard}"
Visibility="{Binding IsGrid, Converter={StaticResource BoolToVisibility}}" AutomationProperties.Name="{l:Loc Shell.Nav.Library}"
ScrollViewer.ScrollChanged="OnScrollChanged">
<ListBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenCommand}" />
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<v:SequenceCard Title="{Binding Title}" Subtitle="{Binding Subtitle}" Statuses="{Binding Statuses}" Thumbnail="{Binding Thumbnail}"
ScrubSource="{Binding ScrubSource}" lib:ThumbnailLoading.Width="236"
IsSelected="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=ListBoxItem}, Mode=TwoWay}"
SelectToolTip="{l:Loc Tooltips.Library.Select}" ToolTip="{l:Loc Tooltips.Library.Card}">
<v:SequenceCard.ActionsContent>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sequence}"
Command="{Binding DataContext.OpenItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Open}" AutomationProperties.Name="{l:Loc Library.Action.Open}" />
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}"
Command="{Binding DataContext.AnalyseItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Analyse}" AutomationProperties.Name="{l:Loc Library.Action.Analyse}" />
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Render}"
Command="{Binding DataContext.RenderItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding RenderToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Render}" />
<Button Style="{StaticResource Button.Quick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sync}"
Command="{Binding DataContext.SyncItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding SyncToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Sync}" />
</StackPanel>
</v:SequenceCard.ActionsContent>
</v:SequenceCard>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- List view: virtualised table with sortable headers; columns share the width, row actions appear on the hovered row. -->
<Border Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource Border.Panel}" Margin="20,4,20,12" Visibility="{Binding IsList, Converter={StaticResource BoolToVisibility}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border BorderBrush="{DynamicResource Brush.Stroke}" BorderThickness="0,0,0,1" Padding="14,2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" MinWidth="160" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="72" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="64" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<Button Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Sequence}" Command="{Binding SortByCommand}" CommandParameter="Title" ToolTip="{l:Loc Tooltips.Library.SortTitle}" />
<Button Grid.Column="1" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Date}" Command="{Binding SortByCommand}" CommandParameter="Date" ToolTip="{l:Loc Tooltips.Library.SortDate}" Margin="10,0,0,0" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Camera}" Margin="10,0,0,0" />
<Button Grid.Column="3" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Frames}" HorizontalContentAlignment="Right" Command="{Binding SortByCommand}" CommandParameter="FrameCount" ToolTip="{l:Loc Tooltips.Library.SortFrames}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Span}" TextAlignment="Right" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.Interval}" TextAlignment="Right" Margin="10,0,0,0" />
<Button Grid.Column="6" Style="{StaticResource Button.Header}" Content="{l:Loc Library.Column.Size}" HorizontalContentAlignment="Right" Command="{Binding SortByCommand}" CommandParameter="Size" ToolTip="{l:Loc Tooltips.Library.SortSize}" Margin="10,0,0,0" />
<TextBlock Grid.Column="7" Style="{StaticResource Text.Header}" Text="{l:Loc Library.Column.State}" Margin="16,0,0,0" />
</Grid>
</Border>
<ListBox x:Name="RowList" Grid.Row="1" ItemsSource="{Binding Items}" ItemContainerStyle="{StaticResource ListBoxItem.LibraryRow}" SelectionMode="Extended"
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.ScrollChanged="OnScrollChanged" AutomationProperties.Name="{l:Loc Shell.Nav.Library}">
<ListBox.InputBindings>
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenCommand}" />
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
</ListBox.InputBindings>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type lib:SequenceItem}">
<Grid ToolTip="{l:Loc Tooltips.Library.Row}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" MinWidth="160" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="72" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="64" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" MinWidth="120" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource Text.Cell}" Text="{Binding Title}" />
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding DateText}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding Camera}" Margin="10,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
<TextBlock Grid.Column="3" Style="{StaticResource Text.CellNumber}" Text="{Binding FramesText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="4" Style="{StaticResource Text.CellNumber}" Text="{Binding SpanText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="5" Style="{StaticResource Text.CellNumber}" Text="{Binding IntervalText}" Margin="10,0,0,0" />
<TextBlock Grid.Column="6" Style="{StaticResource Text.CellNumber}" Text="{Binding SizeText}" Margin="10,0,0,0" />
<ItemsControl Grid.Column="7" Margin="16,0,0,0" ItemsSource="{Binding Statuses}" ItemTemplate="{StaticResource Template.Status}"
ItemsPanel="{StaticResource Panel.Row}" VerticalAlignment="Center" Focusable="False" ClipToBounds="True" />
<Border Grid.Column="7" HorizontalAlignment="Right" Background="{DynamicResource Brush.Card}" Padding="6,0,0,0"
Visibility="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource BoolToVisibility}}">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sequence}"
Command="{Binding DataContext.OpenItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Open}" AutomationProperties.Name="{l:Loc Library.Action.Open}" />
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}"
Command="{Binding DataContext.AnalyseItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{l:Loc Tooltips.Library.Analyse}" AutomationProperties.Name="{l:Loc Library.Action.Analyse}" />
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Render}"
Command="{Binding DataContext.RenderItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding RenderToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Render}" />
<Button Style="{StaticResource Button.RowQuick}" ui:ButtonIcon.Glyph="{StaticResource Icon.Sync}"
Command="{Binding DataContext.SyncItemCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding}"
ToolTip="{Binding SyncToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Sync}" />
</StackPanel>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
<!-- Empty states: one sentence plus the first actions (Components.html). -->
<ui:EmptyState Grid.Row="2" Grid.ColumnSpan="2" Message="{l:Loc Library.Empty}" Visibility="{Binding IsLibraryEmpty, Converter={StaticResource BoolToVisibility}}">
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Empty.ImportCard}" Command="{Binding ImportCardCommand}" ToolTip="{l:Loc Tooltips.Library.ImportCard}" Margin="0,0,8,0" />
<Button Content="{l:Loc Library.Empty.Adopt}" Command="{Binding AdoptFolderCommand}" ToolTip="{l:Loc Tooltips.Library.Adopt}" Margin="0,0,8,0" />
<Button Content="{l:Loc Library.Empty.Connect}" Command="{Binding ConnectCommand}" ToolTip="{l:Loc Tooltips.Library.Connect}" />
</StackPanel>
</ui:EmptyState>
<ui:EmptyState Grid.Row="2" Grid.ColumnSpan="2" Message="{l:Loc Library.NoMatch}" Visibility="{Binding IsNoMatch, Converter={StaticResource BoolToVisibility}}">
<Button Content="{l:Loc Library.ClearFilters}" Command="{Binding ClearFiltersCommand}" ToolTip="{l:Loc Tooltips.Library.ClearFilters}" />
</ui:EmptyState>
<!-- One sequence selected in the grid or the timeline: its details (320 px, DESIGN §3). -->
<Border Grid.Row="2" Grid.Column="1" Width="320" Margin="0,4,20,12" Style="{StaticResource Border.Panel}" Padding="16"
Visibility="{Binding ShowsDetails, Converter={StaticResource BoolToVisibility}}">
<ScrollViewer VerticalScrollBarVisibility="Auto" Focusable="False" DataContext="{Binding Selected}">
<StackPanel>
<v:AspectRatioDecorator>
<Border CornerRadius="6" Background="{DynamicResource Brush.Preview}">
@@ -225,31 +355,53 @@
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Library.Action.Open}" HorizontalAlignment="Stretch" Margin="0,18,0,0"
Command="{Binding DataContext.OpenCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" ToolTip="{l:Loc Tooltips.Library.Open}" />
<WrapPanel Margin="0,8,0,0">
<Button Content="{l:Loc Library.Action.Analyse}" Command="{Binding DataContext.AnalyseCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{l:Loc Tooltips.Library.Analyse}" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Proxies}" Command="{Binding DataContext.ProxiesCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{l:Loc Tooltips.Library.Proxies}" ui:ButtonIcon.Glyph="{StaticResource Icon.Layers}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Verify}" Command="{Binding DataContext.VerifyCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{l:Loc Tooltips.Library.Verify}" ui:ButtonIcon.Glyph="{StaticResource Icon.Verify}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Render}" Command="{Binding DataContext.RenderItemCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
CommandParameter="{Binding}" ToolTip="{Binding RenderToolTip}" ui:ButtonIcon.Glyph="{StaticResource Icon.Render}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Folder}" Command="{Binding DataContext.RevealCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
ToolTip="{l:Loc Tooltips.Library.Folder}" ui:ButtonIcon.Glyph="{StaticResource Icon.FolderOpen}" Margin="0,0,8,8" />
</WrapPanel>
</StackPanel>
</ScrollViewer>
</Border>
<!-- Several sequences: mass actions. -->
<StackPanel Visibility="{Binding IsMultiSelection, Converter={StaticResource BoolToVisibility}}">
<TextBlock Text="{Binding SelectionTitle}" Style="{StaticResource Text.Title}" />
<TextBlock Text="{Binding SelectionSummary}" Style="{StaticResource Text.Secondary}" Margin="0,4,0,0" />
<WrapPanel Margin="0,16,0,0">
<Button Content="{l:Loc Library.Action.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{l:Loc Tooltips.Library.AnalyseAll}" ui:ButtonIcon.Glyph="{StaticResource Icon.Analyse}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Proxies}" Command="{Binding ProxiesCommand}" ToolTip="{l:Loc Tooltips.Library.ProxiesAll}" ui:ButtonIcon.Glyph="{StaticResource Icon.Layers}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.Verify}" Command="{Binding VerifyCommand}" ToolTip="{l:Loc Tooltips.Library.VerifyAll}" ui:ButtonIcon.Glyph="{StaticResource Icon.Verify}" Margin="0,0,8,8" />
<Button Content="{l:Loc Library.Action.ExportList}" Command="{Binding ExportListCommand}" ToolTip="{l:Loc Tooltips.Library.ExportList}" ui:ButtonIcon.Glyph="{StaticResource Icon.Export}" Margin="0,0,8,8" />
</WrapPanel>
<Button Style="{StaticResource Button.Subtle}" Content="{l:Loc Library.Action.ClearSelection}" Command="{Binding ClearSelectionCommand}" ToolTip="{l:Loc Tooltips.Library.ClearSelection}" HorizontalAlignment="Left" Margin="0,8,0,0" />
</StackPanel>
</Grid>
</Border>
<!-- Mass actions bar on the selection (BRIEF §12.2): each button disabled with its reason when it cannot run on it. -->
<Border Grid.Row="3" Grid.ColumnSpan="2" Style="{StaticResource Border.Panel}" Padding="14,8,6,0" Margin="20,0,20,12" MinHeight="48"
Visibility="{Binding HasSelection, Converter={StaticResource BoolToVisibility}}">
<WrapPanel VerticalAlignment="Center">
<TextBlock Text="{Binding SelectionTitle}" FontWeight="SemiBold" VerticalAlignment="Center" Margin="0,0,8,8" Typography.NumeralAlignment="Tabular" />
<TextBlock Text="{Binding SelectionSummary}" Foreground="{DynamicResource Brush.TextMuted}" VerticalAlignment="Center" Margin="0,0,12,8"
Typography.NumeralAlignment="Tabular" />
<Border Width="1" Height="22" Background="{DynamicResource Brush.Stroke}" Margin="0,0,12,8" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{Binding AnalyseToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Proxies}" Command="{Binding ProxiesCommand}" ToolTip="{Binding ProxiesToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Verify}" Command="{Binding VerifyCommand}" ToolTip="{Binding VerifyToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Tag}" Command="{Binding TagCommand}" ToolTip="{Binding TagToolTip}" />
<Button Style="{StaticResource Button.Bar}" Click="OnOpenMenu" IsEnabled="{Binding CanRate}" ToolTip="{Binding RateToolTip}" AutomationProperties.Name="{l:Loc Library.Action.Rate}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{l:Loc Library.Action.Rate}" />
<ui:Icon Glyph="{StaticResource Icon.ChevronDown}" Margin="6,0,0,0" />
</StackPanel>
<Button.ContextMenu>
<ContextMenu ItemsSource="{Binding RatingChoices}" ItemContainerStyle="{StaticResource MenuItem.Rating}" />
</Button.ContextMenu>
</Button>
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Move}" Command="{Binding MoveCommand}" ToolTip="{Binding MoveToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Upload}" Command="{Binding UploadCommand}" ToolTip="{Binding UploadToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.Download}" Command="{Binding DownloadCommand}" ToolTip="{Binding DownloadToolTip}" />
<Button Style="{StaticResource Button.Bar}" Content="{l:Loc Library.Action.ExportList}" Command="{Binding ExportListCommand}" ToolTip="{Binding ExportListToolTip}" />
<Button Style="{StaticResource Button.Destructive}" Height="30" Margin="0,0,8,8" Content="{l:Loc Library.Action.Delete}" Command="{Binding DeleteCommand}"
ToolTip="{Binding DeleteToolTip}" />
<Button Style="{StaticResource Button.Subtle}" Height="30" Margin="0,0,8,8" Content="{l:Loc Library.Action.ClearSelection}" Command="{Binding ClearSelectionCommand}"
ToolTip="{l:Loc Tooltips.Library.ClearSelection}" />
</WrapPanel>
</Border>
</Grid>
<!-- In-window dialogs (tags, move, view name) over a scrim; the keyboard stays inside the dialog. -->
<Grid Visibility="{Binding IsDialogOpen, Converter={StaticResource BoolToVisibility}}" KeyboardNavigation.TabNavigation="Cycle"
KeyboardNavigation.ControlTabNavigation="Cycle" KeyboardNavigation.DirectionalNavigation="Contained">
<Border Background="{DynamicResource Brush.Scrim}" />
<ContentPresenter x:Name="DialogHost" Content="{Binding Dialog}" Margin="20" />
</Grid>
</Grid>
</UserControl>
+52 -2
View File
@@ -1,15 +1,65 @@
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Threading;
using Titano.App.Library;
using Titano.Ui.Visuals;
namespace Titano.App.Sections;
public partial class LibraryView : UserControl
{
public LibraryView() => InitializeComponent();
public LibraryView()
{
InitializeComponent();
DataContextChanged += OnDataContextChanged;
}
private LibraryViewModel? Model => DataContext as LibraryViewModel;
/// <summary>Loads the next page when the grid or the list scrolls within two screens of its end.</summary>
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (DataContext is not LibraryViewModel vm || e.ExtentHeight <= 0) return;
if (Model is not { } vm || e.ExtentHeight <= 0) return;
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - 2 * Math.Max(e.ViewportHeight, 200)) _ = vm.LoadMoreAsync();
}
/// <summary>A month of the timeline: the Library narrows to its year and the grid scrolls to it.</summary>
private void OnSlotActivated(object sender, ChartItemEventArgs e) => Model?.ShowMonth(e.Row, e.Column);
/// <summary>"Saved views" and "Rate ▾" open their menu under themselves.</summary>
private void OnOpenMenu(object sender, RoutedEventArgs e)
{
if (sender is not Button { ContextMenu: { } menu } button) return;
menu.DataContext = DataContext;
menu.PlacementTarget = button;
menu.Placement = PlacementMode.Bottom;
menu.IsOpen = true;
}
private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.OldValue is LibraryViewModel old)
{
old.ScrollRequested -= OnScrollRequested;
old.PropertyChanged -= OnModelChanged;
}
if (e.NewValue is LibraryViewModel model)
{
model.ScrollRequested += OnScrollRequested;
model.PropertyChanged += OnModelChanged;
}
}
private void OnScrollRequested(SequenceItem item) =>
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, () => CardGrid.ScrollIntoView(item));
/// <summary>A dialog that opens takes the keyboard: its first field or button.</summary>
private void OnModelChanged(object? sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != nameof(LibraryViewModel.Dialog) || Model?.Dialog is null || !IsVisible) return;
Dispatcher.BeginInvoke(DispatcherPriority.Input, () => DialogHost.MoveFocus(new TraversalRequest(FocusNavigationDirection.First)));
}
}
File diff suppressed because it is too large. Load diff