Support hex colors which start with 0x

This commit is contained in:
Jaex 2017-05-17 11:51:50 +03:00
parent 04b925a8bd
commit 702bc0b066

View file

@ -155,6 +155,10 @@ public static Color HexToColor(string hex, ColorFormat format = ColorFormat.RGB)
{
hex = hex.Remove(0, 1);
}
else if (hex.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
{
hex = hex.Remove(0, 2);
}
if (((format == ColorFormat.RGBA || format == ColorFormat.ARGB) && hex.Length != 8) ||
(format == ColorFormat.RGB && hex.Length != 6))