Exemplo n.º 1
0
        public ColorsItemModel(IThemeItem themeItem, ThemeModel theme, bool isDefault)
            : base(themeItem, theme, isDefault)
        {
            this.Name          = "Colors";
            this.DefaultColors = new ObservableCollection <ColorItemModel>();
            Dictionary <string, ColorItemModel> dictionary = new Dictionary <string, ColorItemModel>();

            this.colorsItem = (ColorsThemeItem)themeItem;
            foreach (ColorItem colorItem in (Collection <ColorItem>) this.colorsItem.DefaultColors)
            {
                ColorItemModel colorItemModel = new ColorItemModel(colorItem);
                dictionary[colorItem.Name] = colorItemModel;
            }
            foreach (ColorItem colorItem in Enumerable.Where <ColorItem>(ColorsThemeItem.GetColors(theme.ThemeManager.BackupCache), (Func <ColorItem, bool>)(c => Enumerable.FirstOrDefault <ColorItemModel>((IEnumerable <ColorItemModel>) this.DefaultColors, (Func <ColorItemModel, bool>)(o => o.Item.Name == c.Name)) == null)))
            {
                ColorItemModel colorItemModel1;
                if (!dictionary.TryGetValue(colorItem.Name, out colorItemModel1))
                {
                    ColorItemModel colorItemModel2 = new ColorItemModel(colorItem);
                    colorItemModel2.DefaultValue = new Color?(colorItem.Color);
                    colorItemModel1            = colorItemModel2;
                    dictionary[colorItem.Name] = colorItemModel1;
                }
                colorItemModel1.DefaultValue = new Color?(colorItem.Color);
            }
            foreach (ColorItemModel colorItemModel in dictionary.Values)
            {
                this.DefaultColors.Add(colorItemModel);
                colorItemModel.PropertyChanged += new PropertyChangedEventHandler(this.ColorItem_PropertyChanged);
            }
            theme.Theme.Saved += new EventHandler(this.Theme_Saved);
        }
Exemplo n.º 2
0
 private Color GetColor(string colorName)
 {
     if (this.colors == null)
     {
         this.colors = Enumerable.ToDictionary <ColorItem, string, Color>(ColorsThemeItem.GetColors(this.cache), (Func <ColorItem, string>)(o => o.Name), (Func <ColorItem, Color>)(o => o.Color));
     }
     return(this.colors[colorName]);
 }