private static Category UnpackColorCategory(byte[] data)
        {
            var category = new Category();

            using (var ms = new MemoryStream(data))
            using (var reader = new BinaryReader(ms))
            {
                category.Header = ms.ReadStruct<CategoryHeader>();

                for (var i = 0; i < category.Header.ColorCount; i++)
                {
                    var colorRecord = UnpackColorRecord(reader);
                    category.ColorRecords.Add(colorRecord);
                }
                //var alignCheck = reader.ReadInt32();
                //Debug.Assert( alignCheck == category.Header.CategoryDataSize, "The header (and color reads) alignment is not correct." );
            }
            return category;
        }
        public static void InjectColor(Color? fgColor, Color? bgColor, Theme theme, Category category, ColorRecord colorRec)
        {
            var regPath = Path.Combine(ThemeReader.RegPath, theme.Guid.ToString("B"), category.Name);
            var reg = Registry.CurrentUser.OpenSubKey(regPath, true);
            var colorData = reg.GetValue("Data") as byte[];

            using (var ms = new MemoryStream(colorData))
            using (var bw = new BinaryWriter(ms))
            {
                if (bgColor != null)
                {
                    ms.Seek(colorRec.BackgroundPos, SeekOrigin.Begin);
                    WriteColor(bgColor.Value, bw);
                }
                if (fgColor != null)
                {
                    ms.Seek(colorRec.ForegroundPos, SeekOrigin.Begin);
                    WriteColor(fgColor.Value, bw);
                }

                bw.Flush();
                bw.Close();
                var setData = ms.ToArray();

                reg.SetValue("Data", setData, RegistryValueKind.Binary);
            }
        }