Ejemplo n.º 1
0
        public static Color GetColor(this Configuration cfg, string key, Color defaultColor)
        {
            string colorString = cfg.GetValue<string>(key);

            if (colorString != null)
            {
                ColorConverter converter = new ColorConverter();

                if (converter.CanConvertFrom(typeof(string)))
                {
                    try
                    {
                        Color color = (Color)converter.ConvertFrom(null, null, colorString);
                        return color;
                    }
                    catch (Exception)
                    {
                        stdio.ErrorFormat("color setting {0} = {1} not supported", key, colorString);
                    }
                }
            }

            return defaultColor;
        }