private static FontOverride GetFontOverride(XElement node, string fontName, string fontSize, string fontMC) { XAttribute xattribute = node.Attribute((XName)fontName); if (xattribute == null) { return((FontOverride)null); } string str = (string)null; switch (xattribute.Value) { case "Main Font": str = "MainFontFace"; break; case "Regular Font": str = "RegularFontFace"; break; case "Light Font": str = "LightFontFace"; break; } FontOverride fontOverride = new FontOverride() { Name = fontMC, FontClass = str }; int result; fontOverride.Size = int.TryParse(MediaCenterUtil.AttributeValue(node, (XName)fontSize), out result) ? result : 20; return(fontOverride); }
private static void AddFontOverride(FontsThemeItem fonts, XElement node, string fontName, string fontSize, string fontMC) { FontOverride fontOverride = MediaCenterFXTheme.GetFontOverride(node, fontName, fontSize, fontMC); if (fontOverride == null) { return; } fonts.FontOverrides.Add(fontOverride); }
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; }
public IEnumerable<FontOverride> GetFontOverrides(MediaCenterLibraryCache cache, MediaCenterTheme theme) { XDocument xdocument = XDocument.Load(MediaCenterUtil.GetXml(cache["Microsoft.MediaCenter.Shell.dll"].GetResource("FONTS.MCML", (object)this.DocumentResourceType))); string str1 = string.Format("global://{0}:", (object)"me"); List<FontOverride> list = new List<FontOverride>(); XNamespace xnamespace = (XNamespace)"http://schemas.microsoft.com/2006/mcml"; foreach (XElement element in xdocument.Root.Elements(xnamespace + "Font")) { FontOverride fontOverride = new FontOverride(); fontOverride.Name = MediaCenterUtil.AttributeValue(element, (XName)"Name"); string font = MediaCenterUtil.AttributeValue(element, (XName)"FontName"); if (font.StartsWith(str1)) fontOverride.FontClass = font.Substring(str1.Length); else fontOverride.FontFace = FontUtilities.GetFontFaceInfo(font, theme); if (!string.IsNullOrEmpty(fontOverride.FontClass) || fontOverride.FontFace != null) { int result; if (int.TryParse(MediaCenterUtil.AttributeValue(element, (XName)"FontSize"), out result)) fontOverride.Size = result; string str2 = MediaCenterUtil.AttributeValue(element, (XName)"FontStyle"); if (str2 != null) { fontOverride.IsBold = str2.Contains("Bold"); fontOverride.IsItalic = str2.Contains("Italic"); } list.Add(fontOverride); } } return (IEnumerable<FontOverride>)list; }
private static FontOverride GetFontOverride(XElement node, string fontName, string fontSize, string fontMC) { XAttribute xattribute = node.Attribute((XName)fontName); if (xattribute == null) return (FontOverride)null; string str = (string)null; switch (xattribute.Value) { case "Main Font": str = "MainFontFace"; break; case "Regular Font": str = "RegularFontFace"; break; case "Light Font": str = "LightFontFace"; break; } FontOverride fontOverride = new FontOverride() { Name = fontMC, FontClass = str }; int result; fontOverride.Size = int.TryParse(MediaCenterUtil.AttributeValue(node, (XName)fontSize), out result) ? result : 20; return fontOverride; }