示例#1
0
        public static ConvolutionFilter FromXml(XElement xFilter)
        {
            var xMatrix   = xFilter.RequiredElement("matrix");
            var xReserved = xFilter.Attribute("reserved");

            var filter = new ConvolutionFilter {
                Divisor = xFilter.RequiredDoubleAttribute("divisor"),
                Bias    = xFilter.RequiredDoubleAttribute("bias")
            };

            var xRows  = xMatrix.Elements().ToList();
            var height = xRows.Count;
            var width  = xMatrix.Elements().First().Elements().Count();

            filter.Matrix = new double[height, width];
            for (var y = 0; y < filter.MatrixY; y++)
            {
                var xRow  = xRows[y];
                var xCols = xRow.Elements().ToList();
                for (var x = 0; x < filter.MatrixX; x++)
                {
                    var xCol = xCols[x];
                    filter.Matrix[y, x] = CommonFormatter.ParseDouble(xCol.Value);
                }
            }

            filter.DefaultColor = XColorRGBA.FromXml(xFilter.RequiredElement("color").Element("Color"));
            if (xReserved != null)
            {
                filter.Reserved = byte.Parse(xReserved.Value);
            }
            filter.Clamp         = xFilter.RequiredBoolAttribute("clamp");
            filter.PreserveAlpha = xFilter.RequiredBoolAttribute("preserveAlpha");
            return(filter);
        }
示例#2
0
        public static SolidFillStyleRGBA FromXmlRGBA(XElement xFillStyle)
        {
            var xColor = xFillStyle.RequiredElement("color").Element("Color");

            return(new SolidFillStyleRGBA {
                Color = XColorRGBA.FromXml(xColor)
            });
        }
示例#3
0
        public static TextRecordRGBA FromXmlRGBA(XElement element)
        {
            var result = new TextRecordRGBA();

            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 = XColorRGBA.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);
        }
示例#4
0
        public static LineStyleRGBA FromXml(XElement xLineStyle)
        {
            var xColor = xLineStyle.RequiredElement("color").Element("Color");

            return(new LineStyleRGBA {
                Width = xLineStyle.RequiredUShortAttribute("width"),
                Color = XColorRGBA.FromXml(xColor)
            });
        }
示例#5
0
        public static GradientRecordRGBA FromXml(XElement xRecord)
        {
            var record = new GradientRecordRGBA {
                Ratio = xRecord.RequiredByteAttribute("position"),
                Color = XColorRGBA.FromXml(xRecord.RequiredElement("color").Element("Color"))
            };

            return(record);
        }
        protected override bool AcceptTagElement(DefineEditTextTag tag, XElement element)
        {
            switch (element.Name.LocalName)
            {
            case SIZE_ELEM:
                tag.Bounds = XRect.FromXml(element.Element("Rectangle"));
                break;

            case COLOR_ELEM:
                tag.TextColor = XColorRGBA.FromXml(element.Element("Color"));
                break;

            default:
                return(false);
            }
            return(true);
        }
示例#7
0
        public static GlowFilter FromXml(XElement xFilter)
        {
            var xCompositeSource = xFilter.Attribute("compositeSource");

            var xColor = xFilter.RequiredElement("color").Element("Color");

            return(new GlowFilter {
                BlurX = xFilter.RequiredDoubleAttribute("blurX"),
                BlurY = xFilter.RequiredDoubleAttribute("blurY"),
                InnerGlow = xFilter.RequiredBoolAttribute("innerGlow"),
                Knockout = xFilter.RequiredBoolAttribute("knockout"),
                Passes = xFilter.RequiredUIntAttribute("passes"),
                Strength = xFilter.RequiredDoubleAttribute("strength"),
                CompositeSource = xCompositeSource == null || CommonFormatter.ParseBool(xCompositeSource.Value),
                Color = XColorRGBA.FromXml(xColor)
            });
        }
示例#8
0
        public static LineStyleEx FromXml(XElement xLineStyle)
        {
            var xStartCapStyle = xLineStyle.Attribute("startCapStyle");
            var xJointStyle    = xLineStyle.Attribute("jointStyle");
            var xEndCapStyle   = xLineStyle.Attribute("endCapStyle");

            var xReserved = xLineStyle.Attribute("reserved");

            var res = new LineStyleEx {
                Width         = xLineStyle.RequiredUShortAttribute("width"),
                StartCapStyle = (CapStyle)byte.Parse(xStartCapStyle.Value),
                JoinStyle     = (JoinStyle)byte.Parse(xJointStyle.Value),
                HasFill       = xLineStyle.RequiredBoolAttribute("hasFill"),
                NoHScale      = xLineStyle.RequiredBoolAttribute("noHScale"),
                NoVScale      = xLineStyle.RequiredBoolAttribute("noVScale"),
                PixelHinting  = xLineStyle.RequiredBoolAttribute("pixelHinting"),
                NoClose       = xLineStyle.RequiredBoolAttribute("noClose"),
                EndCapStyle   = (CapStyle)byte.Parse(xEndCapStyle.Value)
            };

            if (xReserved != null)
            {
                res.Reserved = byte.Parse(xReserved.Value);
            }

            if (res.JoinStyle == JoinStyle.Miter)
            {
                res.MilterLimitFactor = xLineStyle.RequiredDoubleAttribute("miterFactor");
            }

            var xFillStyle = xLineStyle.Element("fillStyle");
            var xFillColor = xLineStyle.Element("fillColor");

            if (xFillStyle != null)
            {
                res.FillStyle = XFillStyle.FromXmlRGBA(xFillStyle.Elements().First());
            }
            if (xFillColor != null)
            {
                res.Color = XColorRGBA.FromXml(xFillColor.Elements().First());
            }
            return(res);
        }
示例#9
0
        public static BevelFilter FromXml(XElement xFilter)
        {
            var xCompositeSource = xFilter.Attribute("compositeSource");

            var xShadowColor    = xFilter.RequiredElement("shadowColor").Element("Color");
            var xHighlightColor = xFilter.RequiredElement("highlightColor").Element("Color");

            return(new BevelFilter {
                Angle = xFilter.RequiredDoubleAttribute("angle"),
                BlurX = xFilter.RequiredDoubleAttribute("blurX"),
                BlurY = xFilter.RequiredDoubleAttribute("blurY"),
                Distance = xFilter.RequiredDoubleAttribute("distance"),
                InnerShadow = xFilter.RequiredBoolAttribute("innerShadow"),
                Knockout = xFilter.RequiredBoolAttribute("knockout"),
                Passes = xFilter.RequiredUIntAttribute("passes"),
                Strength = xFilter.RequiredDoubleAttribute("strength"),
                CompositeSource = xCompositeSource == null || CommonFormatter.ParseBool(xCompositeSource.Value),
                OnTop = xFilter.RequiredBoolAttribute("onTop"),
                ShadowColor = XColorRGBA.FromXml(xShadowColor),
                HighlightColor = XColorRGBA.FromXml(xHighlightColor)
            });
        }