コード例 #1
0
        private static void OutputComponent(DelphiBinaryReader reader, string indentation)
        {
            string type = reader.ReadString();
            string name = reader.ReadString();
            WriteLine("{0}object {1}: {2}", indentation, name, type);

            while (reader.PeekChar() != 0)
            {
                OutputProperty(reader, indentation + "  ");
            }

            Debug.Assert(reader.ReadByte() == 0);

            while (reader.PeekChar() != 0)
            {
                OutputComponent(reader, indentation + "  ");
            }

            Debug.Assert(reader.ReadByte() == 0);
            WriteLine("{0}end", indentation);
        }
コード例 #2
0
        protected override void OnBuild()
        {
            byte[] data;

            if (Component.TryGetPropertyValue("Picture.Data", out data))
            {
                Image image;

                using (DelphiBinaryReader binaryReader = new DelphiBinaryReader(data))
                {
                    string type = binaryReader.ReadString();
                    Debug.Assert(type == "TBitmap");
                    image = BorlandUtils.ParseGlyphData(binaryReader);
                    Debug.Assert(binaryReader.BaseStream.Position == binaryReader.BaseStream.Length);
                }

                string name = Component.Name;

                if (name.StartsWith("img"))
                {
                    name = name.Substring(3);
                }

                string extension;

                if (image is Metafile) //vector
                {
                    extension = "emf";
                }
                else if (image.GetFrameCount(FrameDimension.Time) > 1 || //animated
                         (image.PixelFormat & PixelFormat.Indexed) == PixelFormat.Indexed) //indexed
                {
                    extension = "gif";
                }
                else if ((image.PixelFormat & PixelFormat.Alpha) == PixelFormat.Alpha) //transparency
                {
                    extension = "png";
                }
                else
                {
                    extension = "jpg";
                }

                string fullName = string.Format("{0}_{1}x{2}.{3}", name, image.Width, image.Height, extension);
                Context.GlobalImageResourceManager.AddUpdateResource(fullName, image);
                ((QFImage) QfControl).Image = string.Format("[Localization!Global_Images:{0}]", fullName);
            }
        }
コード例 #3
0
        private static void Output_Series(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                int count = reader.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    int len = reader.ReadInt32();
                    string type = reader.ReadString(len);
                    WriteLine("{0}{1}", indentation, type);
                    OutputComponent(reader.ReadComponent(true), indentation + "  ");
                    OutputProperty("SQL", reader.ReadString(reader.ReadInt32()), indentation + "  ");
                    //TODO: figure out what these numbers mean
                    Debug.Assert(reader.ReadInt32() == 0);
                    Debug.Assert(reader.ReadInt32() == 0);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        private static void OutputTreeNode(DelphiBinaryReader reader, int level, string indentation)
        {
            //TODO: figure out what this number means
            Debug.Assert(reader.ReadInt32() == level + 26);
            OutputProperty("SmallImageIndex", reader.ReadInt32(), indentation);
            OutputProperty("SelectedImageIndex", reader.ReadInt32(), indentation);
            OutputProperty("StateImageIndex", reader.ReadInt32(), indentation);
            OutputProperty("LargeImageIndex", reader.ReadInt32(), indentation);
            OutputProperty("Indent", reader.ReadInt32(), indentation);
            int childCount = reader.ReadInt32();
            OutputProperty("Caption", reader.ReadString(), indentation);

            for (int i = 0; i < childCount; i++)
            {
                WriteLine("{0}[{1}]", indentation + "  ", i);
                OutputTreeNode(reader, level + 1, indentation + "    ");
            }
        }
コード例 #6
0
        private static void OutputProperty(DelphiBinaryReader reader, string indentation)
        {
            string key = reader.ReadString();

            switch (key)
            {
                case "PopupMenu":
                case "PopupMenuX":
                case "ImageList":
                case "ImagesList":
                case "LargeImagesList":
                case "SmallImagesList":
                case "StateImagesList":
                case "_ImageList":
                    WriteLine("{0}{1}", indentation, key);
                    OutputComponent(reader.ReadComponent(false), indentation + "  ");
                    break;
                default:
                    object value = reader.ReadValue();
                    OutputProperty(key, value, indentation);
                    break;
            }
        }
コード例 #7
0
        private static void OutputPictureData(byte[] data, string indentation)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                DelphiBinaryReader reader = new DelphiBinaryReader(stream);
                string type = reader.ReadString();

                if (type == "TBitmap")
                {
                    byte[] imageData = reader.ReadBinary();

                    if (imageData.Length > 0)
                    {
                        using (Stream imageStream = new MemoryStream(imageData))
                        {
                            Image image = Image.FromStream(imageStream);
                            WriteLine("{0}{1}", indentation, image.Size);
                        }
                    }
                }
                else if (type == "TIcon")
                {
                    byte[] imageData = reader.ReadBytes(data.Length - 6);

                    using (Stream imageStream = new MemoryStream(imageData))
                    {
                        Icon image = new Icon(imageStream);
                        WriteLine("{0}{1}", indentation, image.Size);
                    }
                }
                else if (type == "TMetafile")
                {
                    int len = reader.ReadInt32();
                    byte[] imageData = reader.ReadBytes(len - 4);

                    using (Stream imageStream = new MemoryStream(imageData))
                    {
                        Image image = Image.FromStream(imageStream);
                        WriteLine("{0}{1}", indentation, image.Size);
                    }
                }
                else
                {
                    Debug.Assert(false);
                }

                Debug.Assert(stream.Position == stream.Length);
            }
        }
コード例 #8
0
        private void ParseProperty(DelphiBinaryReader reader, IDictionary<string, object> properties)
        {
            string key = reader.ReadString();
            object value;

            switch (key)
            {
                case "PopupMenu":
                case "PopupMenuX":
                case "ImageList":
                case "ImagesList":
                case "LargeImagesList":
                case "SmallImagesList":
                case "StateImagesList":
                case "_ImageList":
                    DelphiComponent component = reader.ReadComponent(false);
                    _componentSimplifier.Simplify(component);
                    value = component;
                    break;
                default:
                    value = reader.ReadValue();
                    break;
            }

            properties.Add(key, value);
        }
コード例 #9
0
        private DelphiComponent ParseComponent(DelphiBinaryReader reader)
        {
            DelphiComponent component = new DelphiComponent();
            component.Type = reader.ReadString();
            component.Name = reader.ReadString();

            while (reader.PeekChar() != 0)
            {
                ParseProperty(reader, component.Properties);
            }

            byte b = reader.ReadByte();
            Debug.Assert(b == 0);

            while (reader.PeekChar() != 0)
            {
                component.Components.Add(ParseComponent(reader));
            }

            b = reader.ReadByte();
            Debug.Assert(b == 0);
            return component;
        }