A coordinate.
Inheritance: SvgLength
示例#1
0
        //==========================================================================
        public SvgRectElement(SvgDocument document, SvgBaseElement parent, XElement rectElement)
            : base(document, parent, rectElement)
        {
            XAttribute x_attribute = rectElement.Attribute("x");
              if(x_attribute != null)
            X = SvgCoordinate.Parse(x_attribute.Value);

              XAttribute y_attribute = rectElement.Attribute("y");
              if(y_attribute != null)
            Y = SvgCoordinate.Parse(y_attribute.Value);

              XAttribute width_attribute = rectElement.Attribute("width");
              if(width_attribute != null)
            Width = SvgLength.Parse(width_attribute.Value);

              XAttribute height_attribute = rectElement.Attribute("height");
              if(height_attribute != null)
            Height = SvgLength.Parse(height_attribute.Value);

              XAttribute rx_attribute = rectElement.Attribute("rx");
              if(rx_attribute != null)
            CornerRadiusX = SvgCoordinate.Parse(rx_attribute.Value);

              XAttribute ry_attribute = rectElement.Attribute("ry");
              if(ry_attribute != null)
            CornerRadiusY = SvgCoordinate.Parse(ry_attribute.Value);
        }
示例#2
0
        //==========================================================================
        public SvgCircleElement(SvgDocument document, SvgBaseElement parent, XElement circleElement)
            : base(document, parent, circleElement)
        {
            XAttribute cx_attribute = circleElement.Attribute("cx");
              if(cx_attribute != null)
            CenterX = SvgCoordinate.Parse(cx_attribute.Value);

              XAttribute cy_attribute = circleElement.Attribute("cy");
              if(cy_attribute != null)
            CenterY = SvgCoordinate.Parse(cy_attribute.Value);

              XAttribute r_attribute = circleElement.Attribute("r");
              if(r_attribute != null)
            Radius = SvgLength.Parse(r_attribute.Value);
        }
示例#3
0
        //==========================================================================
        public SvgLineElement(SvgDocument document, SvgBaseElement parent, XElement lineElement)
            : base(document, parent, lineElement)
        {
            XAttribute x1_attribute = lineElement.Attribute("x1");
              if(x1_attribute != null)
            X1 = SvgCoordinate.Parse(x1_attribute.Value);

              XAttribute y1_attribute = lineElement.Attribute("y1");
              if(y1_attribute != null)
            Y1 = SvgCoordinate.Parse(y1_attribute.Value);

              XAttribute x2_attribute = lineElement.Attribute("x2");
              if(x2_attribute != null)
            X2 = SvgCoordinate.Parse(x2_attribute.Value);

              XAttribute y2_attribute = lineElement.Attribute("y2");
              if(y2_attribute != null)
            Y2 = SvgCoordinate.Parse(y2_attribute.Value);
        }
示例#4
0
        //==========================================================================
        public SvgEllipseElement(SvgDocument document, SvgBaseElement parent, XElement ellipseElement)
            : base(document, parent, ellipseElement)
        {
            XAttribute cx_attribute = ellipseElement.Attribute("cx");
              if(cx_attribute != null)
            CenterX = SvgCoordinate.Parse(cx_attribute.Value);

              XAttribute cy_attribute = ellipseElement.Attribute("cy");
              if(cy_attribute != null)
            CenterY = SvgCoordinate.Parse(cy_attribute.Value);

              XAttribute rx_attribute = ellipseElement.Attribute("rx");
              if(rx_attribute != null)
            RadiusX = SvgCoordinate.Parse(rx_attribute.Value);

              XAttribute ry_attribute = ellipseElement.Attribute("ry");
              if(ry_attribute != null)
            RadiusY = SvgCoordinate.Parse(ry_attribute.Value);
        }
        //==========================================================================
        public SvgRadialGradientElement(SvgDocument document, SvgBaseElement parent, XElement radialGradientElement)
            : base(document, parent, radialGradientElement)
        {
            XAttribute cx_attribute = radialGradientElement.Attribute("cx");
              if(cx_attribute != null)
            CX = SvgCoordinate.Parse(cx_attribute.Value);

              XAttribute cy_attribute = radialGradientElement.Attribute("cy");
              if(cy_attribute != null)
            CY = SvgCoordinate.Parse(cy_attribute.Value);

              XAttribute r_attribute = radialGradientElement.Attribute("r");
              if(r_attribute != null)
            R = SvgCoordinate.Parse(r_attribute.Value);

              XAttribute fx_attribute = radialGradientElement.Attribute("fx");
              if(fx_attribute != null)
            FX = SvgCoordinate.Parse(fx_attribute.Value);

              XAttribute fy_attribute = radialGradientElement.Attribute("fy");
              if(fy_attribute != null)
            FY = SvgCoordinate.Parse(fy_attribute.Value);
        }
示例#6
0
        //==========================================================================
        public SvgImageElement(SvgDocument document, SvgBaseElement parent, XElement imageElement)
            : base(document, parent, imageElement)
        {
            XAttribute x_attribute = imageElement.Attribute("x");
              if(x_attribute != null)
            X = SvgCoordinate.Parse(x_attribute.Value);

              XAttribute y_attribute = imageElement.Attribute("y");
              if(y_attribute != null)
            Y = SvgCoordinate.Parse(y_attribute.Value);

              XAttribute width_attribute = imageElement.Attribute("width");
              if(width_attribute != null)
            Width = SvgLength.Parse(width_attribute.Value);

              XAttribute height_attribute = imageElement.Attribute("height");
              if(height_attribute != null)
            Height = SvgLength.Parse(height_attribute.Value);

              XAttribute href_attribute = imageElement.Attribute(XName.Get("href", "http://www.w3.org/1999/xlink"));
              if(href_attribute != null)
              {
            string reference = href_attribute.Value.TrimStart();
            if(reference.StartsWith("data:"))
            {
              reference = reference.Substring(5).TrimStart();
              int index = reference.IndexOf(";");
              if(index > -1)
              {
            string type = reference.Substring(0, index).Trim();
            reference = reference.Substring(index + 1);

            index = reference.IndexOf(",");
            string encoding = reference.Substring(0, index).Trim();
            reference = reference.Substring(index + 1).TrimStart();

            switch(encoding)
            {
              case "base64":
                Data = Convert.FromBase64String(reference);
                break;

              default:
                throw new NotSupportedException(String.Format("Unsupported encoding: {0}", encoding));
            }

            string[] type_tokens = type.Split('/');
            if(type_tokens.Length != 2)
              throw new NotSupportedException(String.Format("Unsupported type: {0}", type));

            type_tokens[0] = type_tokens[0].Trim();
            if(type_tokens[0] != "image")
              throw new NotSupportedException(String.Format("Unsupported type: {0}", type));

            switch(type_tokens[1].Trim())
            {
              case "jpeg":
                DataType = "jpeg";
                break;

              case "png":
                DataType = "png";
                break;

              default:
                throw new NotSupportedException(String.Format("Unsupported type: {0}", type));
            }
              }
            }
              }
        }