Example #1
0
        public FontsItemModel(IThemeItem themeItem, ThemeModel theme, bool isDefault)
            : base(themeItem, theme, isDefault)
        {
            this.Name           = "Fonts";
            this.fontsThemeItem = (FontsThemeItem)themeItem;
            this.FontClasses    = new ObservableCollection <FontClassModel>();
            Dictionary <string, FontClassModel> dictionary1 = new Dictionary <string, FontClassModel>();

            foreach (FontClass fontClass in (Collection <FontClass>) this.fontsThemeItem.FontClasses)
            {
                dictionary1[fontClass.Name] = new FontClassModel(fontClass);
            }
            foreach (FontClass fontClass in FontsThemeItem.GetFontClasses(theme.ThemeManager.BackupCache))
            {
                FontClassModel fontClassModel;
                if (!dictionary1.TryGetValue(fontClass.Name, out fontClassModel))
                {
                    fontClassModel = new FontClassModel(fontClass);
                    dictionary1[fontClass.Name] = fontClassModel;
                }
                fontClassModel.DefaultValue = new FontFace(fontClass.FontFace);
            }
            foreach (FontClassModel fontClassModel in dictionary1.Values)
            {
                this.FontClasses.Add(fontClassModel);
                fontClassModel.PropertyChanged += new PropertyChangedEventHandler(this.FontClass_PropertyChanged);
            }
            this.FontOverrides = new ObservableCollection <FontOverrideModel>();
            Dictionary <string, FontOverrideModel> dictionary2 = new Dictionary <string, FontOverrideModel>();

            foreach (FontOverride fontOverride in (Collection <FontOverride>) this.fontsThemeItem.FontOverrides)
            {
                dictionary2[fontOverride.Name] = new FontOverrideModel(fontOverride, this);
            }
            foreach (FontOverride fontOverride in FontsThemeItem.GetFontOverrides(theme.ThemeManager.BackupCache, this.Theme.Theme))
            {
                FontOverrideModel fontOverrideModel;
                if (!dictionary2.TryGetValue(fontOverride.Name, out fontOverrideModel))
                {
                    fontOverrideModel = new FontOverrideModel(fontOverride, this);
                    dictionary2[fontOverride.Name] = fontOverrideModel;
                }
                fontOverrideModel.DefaultValue = fontOverrideModel.Clone(fontOverride);
            }
            foreach (FontOverrideModel fontOverrideModel in dictionary2.Values)
            {
                this.FontOverrides.Add(fontOverrideModel);
                fontOverrideModel.PropertyChanged += new PropertyChangedEventHandler(this.FontOverride_PropertyChanged);
            }
        }
Example #2
0
        private FontFamily GetFontFamily(string name)
        {
            if (this.fonts == null)
            {
                this.fonts = new Dictionary <string, FontFamily>();
                foreach (FontClass fontClass in FontsThemeItem.GetFontClasses(this.cache))
                {
                    this.fonts[fontClass.Name] = new FontFamily(fontClass.FontFace.FontFamily);
                }
            }

            if (this.fonts.ContainsKey(name))
            {
                return(this.fonts[name]);
            }
            else
            {
                return(CommonResourceManager.BackupFont);
            }
        }