using System; using System.Drawing; namespace SoFii { public readonly struct ColourCharInfo { public readonly char Char; public readonly Color Colour; public ColourCharInfo(char chr, Color col) { Char = chr; Colour = col; } public static ColourCharInfo FromStrings(string chr, string col) { if(chr is null) throw new ArgumentNullException(nameof(chr)); if(col is null) throw new ArgumentNullException(nameof(col)); if(chr.Length < 1) throw new ArgumentException("chr must contain at least 1 character", nameof(chr)); if(!int.TryParse(col, out int colourRaw)) throw new ArgumentException("col is not a valid integer", nameof(col)); return new ColourCharInfo(chr[0], Color.FromArgb(unchecked(colourRaw | (int)0xFF000000))); } public override string ToString() { return $"ColourCharInfo [Char={Char}, Colour={Colour}]"; } } }