Exemplo n.º 1
0
        public void Load(System.IO.Stream stream)
        {
            CanSave = false;
            Text    = FileName;

            header = new Header();
            header.Read(new FileReader(stream));

            TreeNode clr1Node = new TreeNode("Colors");
            TreeNode ati2Node = new TreeNode("Attributes");
            TreeNode tgg2Node = new TreeNode("Tag Groups");
            TreeNode syl3Node = new TreeNode("Styles");
            TreeNode cti1Node = new TreeNode("Project Contents");

            for (int i = 0; i < header.entries.Count; i++)
            {
                var node = new TreeNode(header.entries[i].Signature);

                if (header.entries[i] is CTI1)
                {
                    CTI1 cti1 = header.entries[i] as CTI1;

                    for (int t = 0; t < cti1.TextEntries.Count; t++)
                    {
                        cti1Node.Nodes.Add(cti1.TextEntries[t]);
                    }
                }
                else
                {
                    Nodes.Add(node);
                }
            }

            if (clr1Node.Nodes.Count > 0)
            {
                Nodes.Add(clr1Node);
            }
            if (ati2Node.Nodes.Count > 0)
            {
                Nodes.Add(ati2Node);
            }
            if (tgg2Node.Nodes.Count > 0)
            {
                Nodes.Add(tgg2Node);
            }
            if (syl3Node.Nodes.Count > 0)
            {
                Nodes.Add(syl3Node);
            }
            if (cti1Node.Nodes.Count > 0)
            {
                Nodes.Add(cti1Node);
            }
        }
Exemplo n.º 2
0
            public void Read(FileReader reader)
            {
                reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
                reader.ReadSignature(8, "MsgPrjBn");
                ByteOrderMark = reader.ReadUInt16();
                reader.CheckByteOrderMark(ByteOrderMark);
                reader.ReadUInt16(); //Padding
                byte encoding = reader.ReadByte();

                Version = reader.ReadByte();
                ushort SectionCount = reader.ReadUInt16();

                reader.ReadUInt16(); //Padding
                uint FileSize = reader.ReadUInt32();

                reader.ReadBytes(10);  //Reserved

                StringEncoding = (encoding == 0x01 ? Encoding.BigEndianUnicode : Encoding.UTF8);



                for (int i = 0; i < SectionCount; i++)
                {
                    long pos = reader.Position;

                    string Signature   = reader.ReadString(4, Encoding.ASCII);
                    uint   SectionSize = reader.ReadUInt32();
                    reader.ReadUInt32(); //padding
                    reader.ReadUInt32(); //padding

                    MSBPEntry entry = new MSBPEntry();

                    switch (Signature)
                    {
                    case "SLB1":
                        entry = new SLB1();
                        entry.Read(reader, this);
                        entries.Add(entry);
                        break;

                    case "CTI1":
                        entry = new CTI1();
                        entry.Read(reader, this);
                        entries.Add(entry);
                        break;

                    default:
                        entries.Add(entry);
                        break;
                    }

                    entry.Signature = Signature;
                    entry.Data      = reader.getSection((int)pos, (int)SectionSize + 0x10);

                    reader.SeekBegin(pos + SectionSize + 0x10);

                    while (reader.BaseStream.Position % 16 != 0 && reader.BaseStream.Position != reader.BaseStream.Length)
                    {
                        reader.ReadByte();
                    }
                }
            }