protected void SetFromCodexMap(BioCodexMap codexMap)
        {
            if (codexMap == null)
            {
                return;
            }

            CodexPages    = InitCollection(codexMap.Pages.OrderBy(pair => pair.Key));
            CodexSections = InitCollection(codexMap.Sections.OrderBy(pair => pair.Key));
        }
        public BioCodexMap ToCodexMap()
        {
            var codexMap = new BioCodexMap
            {
                Pages    = CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value),
                Sections = CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value)
            };

            return(codexMap);
        }
        public void SaveToPcc(PCCPackage pcc)
        {
            var index = pcc.FindClass("BioCodexMap");

            if (index == 0)
            {
                return;
            }

            var exportIndex = pcc.Exports.FindIndex(entry => entry.idxClass == index);

            if (exportIndex < 0)
            {
                return;
            }

            var codexMapData       = pcc.Exports[exportIndex].Data;
            var codexMapProperties = PropertyReader.getPropList(pcc, codexMapData);

            if (codexMapProperties.Count <= 0)
            {
                return;
            }

            var codexMapProperty   = codexMapProperties.Find(property => property.TypeVal == PropertyReader.Type.None);
            var codexMapDataOffset = codexMapProperty.offend;

            byte[] bytes;
            var    codexMap = new BioCodexMap(CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value),
                                              CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value));

            // CodexMap
            using (var stream = new MemoryStream())
            {
                ((BinaryBioCodexMap)codexMap).Save(stream);

                bytes = stream.ToArray();
            }

            Array.Resize(ref codexMapData, codexMapDataOffset + bytes.Length);
            bytes.CopyTo(codexMapData, codexMapDataOffset);

            var temp = pcc.Exports[exportIndex];

            Array.Resize(ref temp.Data, codexMapData.Length);
            codexMapData.CopyTo(temp.Data, 0);
            pcc.Exports[exportIndex] = temp;
        }
        public void SaveToPcc(IMEPackage pcc)
        {
            IExportEntry export;

            try
            {
                export = pcc.Exports.First(exp => exp.ClassName == "BioCodexMap");
            }
            catch
            {
                return;
            }

            var codexMapData       = export.Data;
            var codexMapProperties = PropertyReader.getPropList(export);

            if (codexMapProperties.Count <= 0)
            {
                return;
            }

            var codexMapProperty   = codexMapProperties.Find(property => property.TypeVal == PropertyType.None);
            var codexMapDataOffset = codexMapProperty.offend;

            byte[] bytes;
            var    codexMap = new BioCodexMap(CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value),
                                              CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value));

            // CodexMap
            using (var stream = new MemoryStream())
            {
                ((BinaryBioCodexMap)codexMap).Save(stream);

                bytes = stream.ToArray();
            }

            Array.Resize(ref codexMapData, codexMapDataOffset + bytes.Length);
            bytes.CopyTo(codexMapData, codexMapDataOffset);

            export.Data = codexMapData;
        }
 public CodexMapViewModel(BioCodexMap codexMap)
 {
     SetFromCodexMap(codexMap ?? new BioCodexMap());
 }