Ejemplo n.º 1
0
        public static void UpdateFontElement(this FontOverride fontOverride, FontElement fontElement, MediaCenterTheme theme)
        {
            if (fontOverride == null)
            {
                return;
            }
            if (fontElement == null)
            {
                throw new ThemeApplicationException("Font element not found.");
            }
            FontFace typeface = (FontFace)null;

            if (fontOverride.FontFace != null)
            {
                typeface = fontOverride.FontFace;
            }
            else if (fontOverride.FontClass != null)
            {
                FontClass fontClass = Enumerable.FirstOrDefault <FontClass>((IEnumerable <FontClass>)theme.FontsItem.FontClasses, (Func <FontClass, bool>)(o => o.Name == fontOverride.FontClass));
                if (fontClass != null)
                {
                    typeface = fontClass.FontFace;
                }
                else
                {
                    Trace.TraceWarning("Could not find font class " + fontOverride.FontClass + ".");
                }
            }
            if (typeface == null)
            {
                return;
            }
            string typefaceName = FontUtilities.GetTypefaceName(theme, typeface);

            fontElement.Value = typefaceName;
            if (fontOverride.Size > 0)
            {
                fontElement.Size = fontOverride.Size.ToString();
            }
            string str = (string)null;

            if (fontOverride.IsBold)
            {
                str = "Bold";
            }
            if (fontOverride.IsItalic)
            {
                if (str != null)
                {
                    str = str + ", ";
                }
                str = str + "Italic";
            }
            fontElement.Style = str;
        }
Ejemplo n.º 2
0
 internal static string GetTypefaceName(MediaCenterTheme theme, FontFace typeface)
 {
     return(FontUtilities.GetTypefaceName(FontUtilities.GetTypeface(theme, typeface)));
 }