Пример #1
0
        private static void Output_Items_Data(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int firstInt = reader.ReadInt32();

                if (firstInt == data.Length)
                {
                    int rootCount = reader.ReadInt32();
                    int totalChildren = 0;

                    for (int i = 0; i < rootCount; i++)
                    {
                        WriteLine("{0}[{1}]", indentation, i);
                        OutputProperty("SmallImageIndex", reader.ReadInt32(), indentation + "  ");
                        OutputProperty("StateImageIndex", reader.ReadInt32(), indentation + "  ");
                        OutputProperty("LargeImageIndex", reader.ReadInt32(), indentation + "  ");
                        int childCount = reader.ReadInt32();
                        OutputProperty("Indent", reader.ReadInt32(), indentation + "  ");
                        OutputProperty("Caption", reader.ReadString(), indentation + "  ");
                        totalChildren += childCount;

                        for (int j = 0; j < childCount; j++)
                        {
                            WriteLine("{0}[{1}]", indentation + "    ", j);
                            OutputProperty("Caption", reader.ReadString(), indentation + "      ");
                        }
                    }

                    WriteLine("{0}SubItemProperties", indentation);

                    for (int i = 0; i < totalChildren; i++)
                    {
                        WriteLine("{0}[{1}]", indentation + "  ", i);
                        OutputProperty("SmallImageIndex", reader.ReadInt16(), indentation + "    ");
                    }
                }
                else
                {
                    for (int i = 0; i < firstInt; i++)
                    {
                        WriteLine("{0}[{1}]", indentation, i);
                        OutputTreeNode(reader, 0, indentation + "  ");
                    }
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }