Example #1
0
        public static XElement ToXml(SolidFillStyleRGB fillStyle)
        {
            var res = new XElement(SOLID);

            res.Add(new XElement("color", XColorRGB.ToXml(fillStyle.Color)));
            return(res);
        }
Example #2
0
 public static XElement ToXml(GradientRecordRGB record)
 {
     return(new XElement("GradientItem",
                         new XAttribute("position", record.Ratio),
                         new XElement("color", XColorRGB.ToXml(record.Color))
                         ));
 }
Example #3
0
        public static SolidFillStyleRGB FromXmlRGB(XElement xFillStyle)
        {
            var xColor = xFillStyle.RequiredElement("color").Element("Color");

            return(new SolidFillStyleRGB {
                Color = XColorRGB.FromXml(xColor)
            });
        }
Example #4
0
        public static TextRecordRGB FromXmlRGB(XElement element)
        {
            var result = new TextRecordRGB();

            foreach (var attribute in element.Attributes())
            {
                switch (attribute.Name.LocalName)
                {
                case "objectID":
                    result.FontID = ushort.Parse(attribute.Value);
                    break;

                case "isSetup":
                    result.Type = CommonFormatter.ParseBool(attribute.Value);
                    break;

                case "reserved":
                    result.Reserved = byte.Parse(attribute.Value);
                    break;

                case "x":
                    result.XOffset = short.Parse(attribute.Value);
                    break;

                case "y":
                    result.YOffset = short.Parse(attribute.Value);
                    break;

                case "fontHeight":
                    result.TextHeight = ushort.Parse(attribute.Value);
                    break;

                default:
                    throw new NotSupportedException();
                }
            }
            foreach (var elem in element.Elements())
            {
                switch (elem.Name.LocalName)
                {
                case "color":
                    var color = XColorRGB.FromXml(elem.Element("Color"));
                    result.TextColor = color;
                    break;

                case "glyphs":
                    foreach (var glyphElem in elem.Elements())
                    {
                        result.Glyphs.Add(ParseGlyphEntry(glyphElem));
                    }
                    break;

                default:
                    throw new NotSupportedException();
                }
            }
            return(result);
        }
Example #5
0
        public static GradientRecordRGB FromXml(XElement xRecord)
        {
            var record = new GradientRecordRGB {
                Ratio = xRecord.RequiredByteAttribute("position"),
                Color = XColorRGB.FromXml(xRecord.RequiredElement("color").Element("Color"))
            };

            return(record);
        }
Example #6
0
        public static LineStyleRGB FromXml(XElement xLineStyle)
        {
            var xColor = xLineStyle.RequiredElement("color").Element("Color");

            return(new LineStyleRGB {
                Width = xLineStyle.RequiredUShortAttribute("width"),
                Color = XColorRGB.FromXml(xColor)
            });
        }
Example #7
0
        protected override bool AcceptTagElement(SetBackgroundColorTag tag, XElement element)
        {
            switch (element.Name.LocalName)
            {
            case COLOR_ELEM:
                tag.Color = XColorRGB.FromXml(element.Element("Color"));
                break;

            default:
                return(false);
            }
            return(true);
        }
Example #8
0
        public static XElement ToXmlRGB(TextRecordRGB entry)
        {
            var res = new XElement(XName.Get("TextRecord6"));

            res.Add(new XAttribute("isSetup", CommonFormatter.Format(entry.Type)));
            if (entry.FontID.HasValue)
            {
                res.Add(new XAttribute("objectID", entry.FontID.Value));
            }
            if (entry.Reserved != 0)
            {
                res.Add(new XAttribute("reserved", entry.Reserved));
            }
            if (entry.XOffset.HasValue)
            {
                res.Add(new XAttribute("x", entry.XOffset.Value));
            }
            if (entry.YOffset.HasValue)
            {
                res.Add(new XAttribute("y", entry.YOffset.Value));
            }
            if (entry.FontID.HasValue)
            {
                if (!entry.TextHeight.HasValue)
                {
                    throw new InvalidOperationException("Text Height must be specified");
                }
                res.Add(new XAttribute("fontHeight", entry.TextHeight.Value));
            }
            if (entry.TextColor.HasValue)
            {
                var color = entry.TextColor.Value;
                res.Add(new XElement("color", XColorRGB.ToXml(color)));
            }
            res.Add(new XElement(XName.Get("glyphs"), entry.Glyphs.Select(FormatGlyphEntry)));
            return(res);
        }
Example #9
0
 protected override void FormatTagElement(SetBackgroundColorTag tag, XElement xTag)
 {
     xTag.Add(new XElement("color", XColorRGB.ToXml(tag.Color)));
 }
Example #10
0
 public static XElement ToXml(LineStyleRGB lineStyle)
 {
     return(new XElement("LineStyle",
                         new XAttribute("width", lineStyle.Width),
                         new XElement("color", XColorRGB.ToXml(lineStyle.Color))));
 }