namespace ytLive.Models; /// A colour the border picker offers: its hex value and the plain-English /// name shown next to it (TASK 60). /// The hex value, e.g. #e94560. /// The name the creator reads, e.g. Crimson. public readonly record struct NamedColor(string Hex, string Name) { /// "Crimson (#e94560)" — the tooltip the border drop-down shows. public override string ToString() => string.IsNullOrEmpty(Name) ? Hex : $"{Name} ({Hex})"; } /// The colours the webcam's border-colour drop-down offers — the SINGLE /// source of truth for the list and for the names. /// /// TASK 60 (the creator, 2026-10-21): *"in the drop down box, the #hex values are /// good, but add a corresponding color name/label next to the value."* The list used to /// be a hard-coded array in the click handler, which is why a name could not be added /// to it without touching the UI code. /// public static class BorderColorPalette { /// The offered colours, in menu order. public static IReadOnlyList All { get; } = new NamedColor[] { new("#FFFFFF", "White"), new("#000000", "Black"), new("#FF0000", "Red"), new("#00FF00", "Lime"), new("#0000FF", "Blue"), new("#FFFF00", "Yellow"), new("#FF00FF", "Magenta"), new("#00FFFF", "Cyan"), new("#FF8800", "Orange"), new("#8800FF", "Violet"), new("#e94560", "Crimson"), new("#22c55e", "Emerald"), new("#3b82f6", "Azure"), new("#f59e0b", "Amber"), }; /// The colour's name, or an **empty string** when the palette has no name /// for that hex (a custom hex the creator typed) — the caller decides what to show /// then, and the border field shows the hex alone. public static string NameOf(string hex) => EntryFor(hex).Name; /// The palette entry for a hex value — the palette's OWN entry (so a /// drop-down bound to it matches by value), or a nameless entry for a custom hex /// the creator typed, so the drop-down always has a selection (TASK 63). public static NamedColor EntryFor(string hex) { if (string.IsNullOrWhiteSpace(hex)) return new NamedColor(string.Empty, string.Empty); var trimmed = hex.Trim(); foreach (var colour in All) if (string.Equals(colour.Hex, trimmed, StringComparison.OrdinalIgnoreCase)) return colour; return new NamedColor(trimmed, string.Empty); } /// The colours a border drop-down offers for a given hex — the palette, plus /// the custom colour the creator typed when it is not one of the palette's, so the /// drop-down always has a selection (TASK 63). public static IReadOnlyList OptionsFor(string hex) { var entry = EntryFor(hex); var options = new List(All); if (!string.IsNullOrEmpty(entry.Hex) && !All.Contains(entry)) options.Add(entry); return options; } }