BColor - esempi
Componenti, HEX e nomi standard
using B.BDrawing;
BColor orange = new(255, 128, 0);
BColor shortHex = new("#F80");
BColor withAlpha = new("#80FF8000");
BColor standard = new("DodgerBlue");
string argb = withAlpha.HexColor; // #80FF8000
string rgb = withAlpha.HexColorWithoutAlpha; // #FF8000
Factory e conversioni
BColor color = BColor.FromArgb(128, 30, 144, 255);
System.Drawing.Color drawingColor = color.ToDrawingColor();
Microsoft.Maui.Graphics.Color mauiColor = color.ToMAUIColor();
L'ordine di FromArgb è a, r, g, b, mentre quello del costruttore a byte è r, g, b, a.
Validare un testo colore
BColor color = new("valore-non-valido");
if (!string.IsNullOrWhiteSpace(color.LogText.Text))
{
GestisciErrore(color.LogText.Text);
}
Un formato non valido non genera un'eccezione: produce un colore trasparente e registra il problema nel log dell'istanza.
