Exemplo n.º 1
0
        /// <summary>
        /// Returns a theme with its definition from the resources file.
        /// </summary>
        /// <param name="name">The name of the built-in theme to find.</param>
        /// <param name="theme">Returns the requested theme, if any.</param>
        /// <param name="fallBackThemeName">The name of the theme to use if <paramref name="name"/>is not found in the resources file.</param>
        /// <param name="culture">The culture to use for resource lookup.</param>
        /// <returns></returns>
        public static bool FromResource(BuiltInThemeName name, out Theme theme, string fallBackThemeName, System.Globalization.CultureInfo culture = null)
        {
            theme = null;
            var resname = name.ToString();
            var content = Resources.ResourceManager.GetString("Bootstrap" + resname, culture);

            if (string.IsNullOrWhiteSpace(content) && !string.IsNullOrWhiteSpace(fallBackThemeName))
            {
                content = Resources.ResourceManager.GetString(fallBackThemeName, culture);
            }

            if (!string.IsNullOrWhiteSpace(content))
            {
                theme = new Theme
                {
                    Id          = content.GetHashCode().ToString("x"),
                    Name        = resname,
                    Content     = content,
                    Description = $"Minified {TitleCaseWords(resname)} Bootstrap CSS theme loaded from the application resources file."
                }
            }
            ;

            return(theme != null);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns a theme with its definition from the resources file.
 /// </summary>
 /// <param name="name">The name of the built-in theme to find.</param>
 /// <param name="theme">Returns the requested theme, if any.</param>
 /// <param name="culture">The culture to use for resource lookup.</param>
 /// <returns></returns>
 public static bool FromResource(BuiltInThemeName name, out Theme theme, System.Globalization.CultureInfo culture = null)
 {
     return(FromResource(name, out theme, null, culture));
 }