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
64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
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;
|
||
}
|
||
}
|