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; }
internal static Typeface GetTypeface(MediaCenterTheme theme, FontFace info) { FontFamily fontFamily = theme.GetFontFamily(info.FontFamily); if (fontFamily == null) return (Typeface)null; else return new Typeface(fontFamily, FontStyles.Normal, info.FontWeight, FontStretches.Normal); }
public Color? GetColor(MediaCenterTheme theme) { if (this.Color.HasValue) return this.Color; ColorItem colorItem = Enumerable.FirstOrDefault<ColorItem>((IEnumerable<ColorItem>)theme.ColorsItem.DefaultColors, (Func<ColorItem, bool>)(o => o.Name == this.ColorName)); if (colorItem != null) return new Color?(colorItem.Color); else return new Color?(); }
public static void UpdateColorElement(this ColorReference colorReference, PropertyElement colorElement, MediaCenterTheme theme) { if (colorReference == null) return; if (colorElement == null) throw new ThemeApplicationException("Color element not found."); Color? color = colorReference.GetColor(theme); if (!color.HasValue) return; colorElement.Value = color.ToString(); }
public static FontFace GetFontFaceInfo(string font, MediaCenterTheme theme) { FontFace fontFace = new FontFace(); List<FontFamily> list = new List<FontFamily>(); if (theme != null) list.AddRange(theme.Fonts); InstallMediaCenterFonts(); list.AddRange(Fonts.SystemFontFamilies); foreach (FontFamily fontFamily in list) { string name = FontUtil.GetName(fontFamily); if (font.StartsWith(name)) { fontFace.FontFamily = name; FontWeightConverter fontWeightConverter = new FontWeightConverter(); string str = font.Substring(name.Length).Trim(); char[] chArray = new char[1] { ' ' }; foreach (string text in str.Split(chArray)) { if (!string.IsNullOrEmpty(text)) { try { fontFace.FontWeight = (FontWeight)fontWeightConverter.ConvertFromString(text); } catch (FormatException) { } } } break; } } if (fontFace.FontFamily == null) return (FontFace)null; else return fontFace; }
public ThemeModel(MediaCenterTheme theme, ThemeManager manager) : base((string)null, (ThemeTreeItem)null) { this.Theme = theme; this.ThemeManager = manager; this.BiographyItem = new BiographyModel(this); this.FontsItem = new FontsItemModel((IThemeItem)theme.FontsItem, this, false); this.ColorsItem = new ColorsItemModel((IThemeItem)theme.ColorsItem, this, false); this.ImagesCategory = new ImagesCategoryModel("Images", (ThemeTreeItem)this); this.Children.Add((ThemeTreeItem)this.BiographyItem); this.Children.Add((ThemeTreeItem)this.FontsItem); this.Children.Add((ThemeTreeItem)this.ColorsItem); this.Children.Add((ThemeTreeItem)this.ImagesCategory); this.BiographyItem.IsSelected = true; foreach (IThemeItem themeItem in (Collection<IThemeItem>)this.Theme.ThemeItems) this.AddThemeItem(themeItem, false); foreach (IThemeItem themeItem in this.DefaultThemeItems) this.AddThemeItem(themeItem, true); this.Sort(); }
public VmcStudioTheme(string file, MediaCenterTheme theme) : base(file, FileMode.CreateNew) { this.themeInfo = new VmcStudioTheme.ThemeInfo(); foreach (IThemeItem themeItem in (Collection<IThemeItem>)theme.ThemeItems) { if (themeItem is FontsThemeItem) this.themeInfo.Fonts = (FontsThemeItem)themeItem; if (themeItem is ColorsThemeItem) this.themeInfo.Colors = (ColorsThemeItem)themeItem; this.ThemeItems.Add(themeItem); } this.Name = theme.Name; this.Author = theme.Author; this.Comments = theme.Comments; this.Version = theme.Version; this.ThemeType = theme.ThemeType; this.MainScreenshot = theme.MainScreenshot; this.FontFiles = theme.FontFiles; this.ID = Guid.NewGuid().ToString(); this.themeInfo.Fonts.ClearDirty(); }
internal static string GetTypefaceName(MediaCenterTheme theme, FontFace typeface) { return FontUtilities.GetTypefaceName(FontUtilities.GetTypeface(theme, typeface)); }
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; }
public static IEnumerable<FontOverride> GetFontOverrides(MediaCenterLibraryCache cache, MediaCenterTheme theme) { return ThemeItemBase.CreateApplicator<FontsThemeItem, FontsThemeItem.IFontsThemeItemApplicator>().GetFontOverrides(cache, theme); }
public ApplyOperation(MediaCenterTheme theme, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache) { this.ReadCache = readCache; this.WriteCache = writeCache; this.Theme = theme; this.Description = string.Format("Applying theme {0}", (object)theme.Name); }