Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
51 lines
2.7 KiB
C#
51 lines
2.7 KiB
C#
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 that move, named one by one in the confirmation; the rest are counted.</summary>
|
|
public const int ListedLines = 6;
|
|
|
|
/// <summary>Sequences that cannot move, named one by one; the rest are counted. With <see cref="ListedLines"/> it keeps the confirmation within a 768 px screen.</summary>
|
|
public const int BlockedLines = 3;
|
|
|
|
/// <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, BlockedLines));
|
|
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;
|
|
}
|
|
}
|