public static int KnownColorToArgb(KnownColor color) { KnownColorTable.EnsureColorTable(); if (color <= KnownColor.MenuHighlight) { return(KnownColorTable.colorTable[(int)color]); } return(0); }
public static Color ArgbToKnownColor(int targetARGB) { KnownColorTable.EnsureColorTable(); for (int i = 0; i < KnownColorTable.colorTable.Length; i++) { if (KnownColorTable.colorTable[i] == targetARGB) { Color result = Color.FromKnownColor((KnownColor)i); if (!result.IsSystemColor) { return(result); } } } return(Color.FromArgb(targetARGB)); }