Ejemplo n.º 1
0
        private static Color TranslateColor(string colorParam)
        {
            Color output;

            try
            {
                if (colorParam[0] == '#')
                {
                    switch (colorParam.Length)
                    {
                    case 4:
                    case 7:
                    case 9:
                        return(TranslateHexCode(colorParam));

                    default:
                        throw new FormatException("Color hexcode out of format");
                    }
                }

                HSBColor color         = HSBColor.FromName(colorParam);
                byte[]   colorChannels = color.ToARGB();
                output = colorChannels.ToMediaColor();
            }
            catch (Exception e)
            {
                throw new NotValidColorException(colorParam, e);
            }

            return(output);
        }