using System.Globalization; using Titano.App.Infrastructure; using Titano.Core.Localization; using Titano.Data.Archiving; namespace Titano.App.Archiving; /// The words of a delete dry run (): the destructive confirmation and the lines of what cannot move. public static class DeletePlans { /// Sequences that move, named one by one in the confirmation; the rest are counted. public const int ListedLines = 6; /// Sequences that cannot move, named one by one; the rest are counted. With it keeps the confirmation within a 768 px screen. public const int BlockedLines = 3; /// The destructive confirmation of a plan; null when nothing in it can move. 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), }; } /// "Not moved: Comet over the ridge ยท a job is working on it", at most lines. public static IReadOnlyList 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; } }