예제 #1
0
        private SvgElement CreateRect(XElement xelement)
        {
            var svgElement = new SvgRect();

            foreach (var xAttribute in xelement.Attributes())
            {
                var attributeName  = xAttribute.Name.LocalName;
                var attributeValue = xAttribute.Value;

                switch (attributeName)
                {
                case "class": svgElement.Style = GetStyle(attributeValue); break;

                case "x": svgElement.X = float.Parse(attributeValue); break;

                case "y": svgElement.Y = float.Parse(attributeValue); break;

                case "width": svgElement.Width = float.Parse(attributeValue); break;

                case "height": svgElement.Height = float.Parse(attributeValue); break;

                case "transform": svgElement.Transform = SvgTransform.Parse(attributeValue); break;
                }
            }

            return(svgElement);
        }
예제 #2
0
        private SvgElement CreateEllipse(XElement xelement)
        {
            var svgElement = new SvgEllipse();

            foreach (var xAttribute in xelement.Attributes())
            {
                var attributeName  = xAttribute.Name.LocalName;
                var attributeValue = xAttribute.Value;

                switch (attributeName)
                {
                case "class": svgElement.Style = GetStyle(attributeValue); break;

                case "cx": svgElement.X = float.Parse(attributeValue); break;

                case "cy": svgElement.Y = float.Parse(attributeValue); break;

                case "rx": svgElement.RadiusX = float.Parse(attributeValue); break;

                case "ry": svgElement.RadiusY = float.Parse(attributeValue); break;

                case "transform": svgElement.Transform = SvgTransform.Parse(attributeValue); break;
                }
            }

            return(svgElement);
        }
예제 #3
0
        public static SvgTransform Parse(string valueString)
        {
            var transform = new SvgTransform();

            var startIndex = valueString.IndexOf("(") + 1;
            var endIndex   = valueString.IndexOf(")") - startIndex;
            var matrix     = valueString.Substring(startIndex, endIndex).Split(' ').Select(float.Parse).ToArray();

            transform.A = matrix[0];
            transform.B = matrix[1];
            transform.C = matrix[2];
            transform.D = matrix[3];
            transform.E = matrix[4];
            transform.F = matrix[5];

            return(transform);
        }