Exemplo n.º 1
0
        /// <inheritdoc/>
        public override FillBase Clone()
        {
            TextureFill f = new TextureFill(imageData.Clone() as byte[], ImageWidth, ImageHeight, PreserveAspectRatio, WrapMode, ImageOffsetX, ImageOffsetY);

            //f.ImageIndex = ImageIndex;
            return(f);
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override bool Equals(object obj)
        {
            TextureFill f = obj as TextureFill;

            return(f != null && ImageData == f.ImageData &&
                   ImageWidth == f.ImageWidth &&
                   ImageHeight == f.ImageHeight &&
                   PreserveAspectRatio == f.PreserveAspectRatio &&
                   WrapMode == f.WrapMode &&
                   ImageOffsetX == f.ImageOffsetX &&
                   ImageOffsetY == f.ImageOffsetY);
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override void Serialize(FRWriter writer, string prefix, FillBase fill)
        {
            base.Serialize(writer, prefix, fill);
            TextureFill c = fill as TextureFill;

            if (c == null || c.ImageWidth != ImageWidth)
            {
                writer.WriteValue(prefix + ".ImageWidth", ImageWidth);
            }
            if (c == null || c.ImageHeight != ImageHeight)
            {
                writer.WriteValue(prefix + ".ImageHeight", ImageHeight);
            }
            if (c == null || c.PreserveAspectRatio != PreserveAspectRatio)
            {
                writer.WriteBool(prefix + ".PreserveAspectRatio", PreserveAspectRatio);
            }
            if (c == null || c.WrapMode != WrapMode)
            {
                writer.WriteValue(prefix + ".WrapMode", WrapMode);
            }
            if (c == null || c.ImageOffsetX != ImageOffsetX)
            {
                writer.WriteValue(prefix + ".ImageOffsetX", ImageOffsetX);
            }
            if (c == null || c.ImageOffsetY != ImageOffsetY)
            {
                writer.WriteValue(prefix + ".ImageOffsetY", ImageOffsetY);
            }

            // store image data
            if (writer.SerializeTo != SerializeTo.SourcePages)
            {
                if (writer.BlobStore != null)
                {
                    // check FImageIndex >= writer.BlobStore.Count is needed when we close the designer
                    // and run it again, the BlobStore is empty, but FImageIndex is pointing to
                    // previous BlobStore item and is not -1.
                    if (imageIndex == -1 || imageIndex >= writer.BlobStore.Count)
                    {
                        byte[] bytes = imageData;
                        if (bytes == null)
                        {
                            using (MemoryStream stream = new MemoryStream())
                            {
                                ImageHelper.Save(image, stream, ImageFormat.Png);
                                bytes = stream.ToArray();
                            }
                        }
                        if (bytes != null)
                        {
                            string imgHash = BitConverter.ToString(new Murmur3().ComputeHash(bytes));
                            if (imgHash != dummyImageHash)
                            {
                                imageIndex = writer.BlobStore.AddOrUpdate(bytes, imgHash.Replace("-", String.Empty));
                            }
                        }
                    }
                }
                else
                {
                    if (imageData != null)
                    {
                        string hash = BitConverter.ToString(new Murmur3().ComputeHash(imageData));
                        if (hash != dummyImageHash)
                        {
                            if (c == null || !writer.AreEqual(ImageData, c.ImageData))
                            {
                                writer.WriteStr(prefix + ".ImageData", Convert.ToBase64String(ImageData));
                            }
                        }
                    }
                }

                if (writer.BlobStore != null || writer.SerializeTo == SerializeTo.Undo)
                {
                    writer.WriteInt(prefix + ".ImageIndex", imageIndex);
                }
            }
        }