Exemplo n.º 1
0
        /// <summary>
        /// Gets a color setting from the settings instance.
        /// </summary>
        /// <param name="values">
        /// The settings reference.
        /// </param>
        /// <param name="name">
        /// The name of the setting to retrieve.
        /// </param>
        /// <param name="defaultValue">
        /// The default color value to use if a error occurs or no setting with the specified <see cref="name"/> was found.
        /// </param>
        /// <returns>
        /// Returns the color for the specified setting.
        /// </returns>
        public static Color32 GetColorSetting(this IValues <string> values, string name, Color32 defaultValue)
        {
            // set default value
            var color = defaultValue;

            // check if setting exists
            if (values.HasValue(name))
            {
                // attempt to get setting string
                var value = values.GetSetting(name, string.Format("{0} {1} {2} {3}", color.a, color.r, color.g, color.b));

                // parse the color string
                ParseColorString(name, value, ref color);
            }

            // return the color
            return(color);
        }