Ejemplo n.º 1
0
        public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache)
        {
            ColorsThemeItem colorsThemeItem = (ColorsThemeItem)themeItem;

            if (colorsThemeItem.DefaultColors.Count <= 0)
            {
                return;
            }
            IResourceLibrary resourceLibrary1 = readCache[this.ResourceLibraryName];
            IResourceLibrary resourceLibrary2 = writeCache[this.ResourceLibraryName];
            McmlDocument     mcml             = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType));

            foreach (ColorItem colorItem in (Collection <ColorItem>)colorsThemeItem.DefaultColors)
            {
                string          str      = colorItem.ToString();
                PropertyElement property = mcml.Properties().GetProperty(colorItem.Name);
                if (property == null)
                {
                    XElement xelement = new XElement(mcml.DefaultNamespace + "Color", new object[2]
                    {
                        (object)new XAttribute((XName)"Name", (object)colorItem.Name),
                        (object)new XAttribute((XName)"Color", (object)str)
                    });
                    mcml.Xml.Root.Add((object)xelement);
                }
                else
                {
                    property.Value = str;
                }
            }
            MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType), mcml);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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]);
 }