Example #1
0
 public static void Load()
 {
     if (Theme.loaded)
     {
         return;
     }
     Theme.loaded     = true;
     ThemeFontset.all = ThemeFontset.Import();
     ThemePalette.all = ThemePalette.Import();
     ThemeSkinset.all = ThemeSkinset.Import();
     ThemeIconset.all = ThemeIconset.Import();
     Theme.all        = Theme.Import().OrderBy(x => x.name != "Default").ToList();
 }
 public ThemePalette Use(ThemePalette other)
 {
     this.name = other.name;
     this.path = other.path;
     this.colors.Clear();
     foreach (var group in other.colors)
     {
         foreach (var color in group.Value)
         {
             this.colors.AddNew(group.Key)[color.Key] = other.colors[group.Key][color.Key].Copy();
         }
     }
     return(this);
 }
Example #3
0
 public bool Matches(ThemePalette other)
 {
     foreach (var item in this.colors["*"])
     {
         var  name               = item.Key;
         bool mismatchedName     = !other.colors["*"].ContainsKey(name);
         bool mismatchedOriginal = mismatchedName || this.colors["*"][name].original != other.colors["*"][name].original;
         bool mismatchedOffset   = mismatchedName || this.colors["*"][name].offset != other.colors["*"][name].offset;
         bool mismatchedSource   = mismatchedName || this.colors["*"][name].sourceName != other.colors["*"][name].sourceName;
         if (mismatchedName || mismatchedOriginal || mismatchedSource || mismatchedOffset)
         {
             return(false);
         }
     }
     return(true);
 }
Example #4
0
 public void Deserialize(string data)
 {
     foreach (var line in data.GetLines())
     {
         if (line.Trim().IsEmpty())
         {
             continue;
         }
         var term  = line.Parse("", " ").Trim();
         var value = line.Parse(" ").Trim().Trim("=").Trim();
         if (term.Matches("CustomizablePalette", true))
         {
             this.customizablePalette = value.ToBool();
         }
         else if (term.Matches("CustomizableFontset", true))
         {
             this.customizableFontset = value.ToBool();
         }
         else if (term.Matches("CustomizableIconset", true))
         {
             this.customizableIconset = value.ToBool();
         }
         else if (term.Matches("Palette", true))
         {
             this.palette = ThemePalette.all.Find(x => x.name == value) ?? new ThemePalette();
         }
         else if (term.Matches("Fontset", true))
         {
             this.fontset = ThemeFontset.all.Find(x => x.name == value) ?? new ThemeFontset();
         }
         else if (term.Matches("Iconset", true))
         {
             this.iconset = ThemeIconset.all.Find(x => x.name == value) ?? new ThemeIconset();
         }
         else if (term.Matches("Skinset", true))
         {
             var variants = value.Split("+");
             this.defaultVariants = variants.Skip(1).ToArray();
             this.skinset         = ThemeSkinset.all.Find(x => x.name == variants[0]) ?? new ThemeSkinset();
         }
     }
 }
 public bool Matches(ThemePalette other)
 {
     foreach (var item in this.colors["*"])
     {
         var name = item.Key;
         if (!other.colors["*"].ContainsKey(name))
         {
             return(false);
         }
         var  colorA           = this.colors["*"][name];
         var  colorB           = other.colors["*"][name];
         var  isBlended        = colorA.blendMode != ColorBlend.Normal;
         var  isSystem         = colorA.source == RelativeColor.system;
         bool mismatchedValue  = !isSystem && !isBlended && (colorA.value != colorB.value);
         bool mismatchedBlend  = isBlended && (colorA.blendMode.ToInt() != colorB.blendMode.ToInt());
         bool mismatchedOffset = colorA.offset != colorB.offset;
         bool mismatchedSource = colorA.sourceName != colorB.sourceName;
         if (mismatchedBlend || mismatchedValue || mismatchedSource || mismatchedOffset)
         {
             return(false);
         }
     }
     return(true);
 }
Example #6
0
        public void Assign(ThemePalette palette, string sourceName)
        {
            var source = sourceName == "@System" ? RelativeColor.system : palette.colors["*"][sourceName];

            this.Assign(source);
        }