Пример #1
0
 static void Dump(CategoryCollectionRecord catColl)
 {
     foreach (var cat in catColl.Categories)
     {
         Console.WriteLine("  Category: {0} ({1})", catColl.Name, cat.Category);
         var colors = new List <ColorRecord>(cat.ColorRecords);
         colors.Sort((a, b) => StringComparer.OrdinalIgnoreCase.Compare(a.Name, b.Name));
         foreach (var color in colors)
         {
             if (color.Foreground != null && color.Background != null)
             {
                 Console.WriteLine("    fg={0:X8} {4:X2} bg={1:X8} {5:X2} {2}.{3}", color.Foreground, color.Background, catColl.Name, color.Name, (byte)color.ForegroundType, (byte)color.BackgroundType);
             }
             else if (color.Foreground != null)
             {
                 Console.WriteLine("    fg={0:X8} {3:X2} bg=-------- -- {1}.{2}", color.Foreground, catColl.Name, color.Name, (byte)color.ForegroundType);
             }
             else if (color.Background != null)
             {
                 Console.WriteLine("    fg=-------- -- bg={0:X8} {3:X2} {1}.{2}", color.Background, catColl.Name, color.Name, (byte)color.BackgroundType);
             }
             else
             {
                 Console.WriteLine("    fg=-------- -- bg=-------- -- {0}.{1}", catColl.Name, color.Name);
             }
         }
     }
 }
        private static CategoryCollectionRecord UnpackColorCategory(byte[] data)
        {
            var catCollRec = new CategoryCollectionRecord();

            using (var ms = new MemoryStream(data))
                using (var reader = new BinaryReader(ms))
                {
                    int size    = reader.ReadInt32();
                    int version = reader.ReadInt32();
                    if (version != 11)
                    {
                        throw new ApplicationException(string.Format("Unknown VS theme category version: {0}", version));
                    }
                    int categoryRecordCount = reader.ReadInt32();

                    for (int i = 0; i < categoryRecordCount; i++)
                    {
                        catCollRec.Categories.Add(UnpackCategoryRecord(reader));
                    }
                }
            return(catCollRec);
        }