Example #1
0
        internal void ReadXml(XElement node, MemoryFolder mFolder, XFile xFile)
        {
            this.RotateWithShape = node.GetAttributeValueOrDefaultOfBooleanType("rotWithShape", false);
            foreach (XElement element in node.Elements())
            {
                if (element.Name.LocalName == "blip")
                {
                    string str = element.GetAttributeValueOrDefaultOfStringType("embed", null);
                    if (!string.IsNullOrWhiteSpace(str) && (xFile != null))
                    {
                        Dictionary <string, XFile> dictionary = new Dictionary <string, XFile>();
                        if (xFile.RelationFiles != null)
                        {
                            foreach (KeyValuePair <string, XFile> pair in xFile.RelationFiles)
                            {
                                XFile fileByRelationID = xFile.GetFileByRelationID(pair.Key);
                                if (fileByRelationID.FileType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")
                                {
                                    dictionary.Add(pair.Key, fileByRelationID);
                                }
                            }
                        }
                        XFile file2 = null;
                        if (dictionary.TryGetValue(str, out file2))
                        {
                            byte[]    sourceArray = this.ReadStreamFully(mFolder.GetFile(file2.FileName));
                            string    str2        = Path.GetExtension(file2.FileName).ToUpperInvariant();
                            ImageType bitmap      = ImageType.Bitmap;
                            switch (str2)
                            {
                            case ".BMP":
                                bitmap = ImageType.Bitmap;
                                break;

                            case ".PNG":
                                bitmap = ImageType.PNG;
                                break;

                            case ".JPG":
                            case ".JPEG":
                                bitmap = ImageType.JPG;
                                break;

                            case ".GIF":
                                bitmap = ImageType.Gif;
                                break;
                            }
                            this.ExcelImage = new Dt.Xls.ExcelImage(null, bitmap, sourceArray);
                        }
                    }
                    foreach (XElement element2 in element.Elements())
                    {
                        if (element2.Name.LocalName == "alphaModFix")
                        {
                            this.Transparency = 1.0 - (element2.GetAttributeValueOrDefaultOfDoubleType("amt", 0.0) / 100000.0);
                        }
                    }
                    continue;
                }
                if (element.Name.LocalName == "tile")
                {
                    Dt.Xls.Chart.Tile tile = new Dt.Xls.Chart.Tile();
                    tile.ReadXml(element, mFolder, xFile);
                    this.Tile = tile;
                }
                else if (element.Name.LocalName == "stretch")
                {
                    foreach (XElement element3 in element.Elements())
                    {
                        if (element3.Name.LocalName == "fillRect")
                        {
                            this.StretchLeftOffset   = element3.GetAttributeValueOrDefaultOfDoubleType("l", 0.0) / 100000.0;
                            this.StretchRightOffset  = element3.GetAttributeValueOrDefaultOfDoubleType("r", 0.0) / 100000.0;
                            this.StretchTopOffset    = element3.GetAttributeValueOrDefaultOfDoubleType("t", 0.0) / 100000.0;
                            this.StretchBottomOffset = element3.GetAttributeValueOrDefaultOfDoubleType("b", 0.0) / 100000.0;
                        }
                    }
                }
            }
        }