Esempio n. 1
0
        static void CreateSvgEllipse(SvgElement parentNode, HtmlElement elem)
        {
            SvgEllipseSpec spec  = new SvgEllipseSpec();
            SvgEllipse     shape = new SvgEllipse(spec, elem);

            parentNode.AddChild(shape);

            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;

                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_Cx:
                {
                    spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                } break;

                case WebDom.WellknownName.Svg_Cy:
                {
                    spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                } break;

                case WellknownName.Svg_Rx:
                {
                    spec.RadiusX = UserMapUtil.ParseGenericLength(attr.Value);
                } break;

                case WellknownName.Svg_Ry:
                {
                    spec.RadiusY = UserMapUtil.ParseGenericLength(attr.Value);
                } break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                } break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                } break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                } break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                } break;

                default:
                {
                    //other attrs
                } break;
                }
            }
        }
Esempio n. 2
0
        void CreateSvgPolygon(SvgElement parentNode, HtmlElement elem)
        {
            SvgPolygonSpec spec  = new SvgPolygonSpec();
            SvgPolygon     shape = new SvgPolygon(spec, elem);

            parentNode.AddChild(shape);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_Points:
                {
                    //parse points
                    spec.Points = ParsePointList(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.FillColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                }
                break;

                default:
                {
                    //other attrs
                }
                break;
                }
            }
        }
Esempio n. 3
0
        static void CreateSvgGroupElement(SvgElement parentNode, HtmlElement elem)
        {
            SvgVisualSpec   spec            = new SvgVisualSpec();
            SvgGroupElement svgGroupElement = new SvgGroupElement(spec, elem);

            parentNode.AddChild(svgGroupElement);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                default:
                {
                    //other attrs
                }
                break;
                }
            }

            CreateSvgBoxContent(svgGroupElement, elem);
        }
Esempio n. 4
0
        static void CreateSvgImage(SvgElement parentNode, HtmlElement elem)
        {
            SvgImageSpec spec     = new SvgImageSpec();
            SvgImage     svgImage = new SvgImage(spec, elem);

            parentNode.AddChild(svgImage);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_X:
                {
                    spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Y:
                {
                    spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Width:
                {
                    spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Height:
                {
                    spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                }
                break;

                case WellknownName.Href:
                {
                    //image src***
                    spec.ImageSrc = attr.Value;
                }
                break;

                default:
                {
                }
                break;
                }
            }
        }
Esempio n. 5
0
        static void CreateSvgPath(SvgElement parentNode, HtmlElement elem)
        {
            SvgPathSpec spec    = new SvgPathSpec();
            SvgPath     svgPath = new SvgPath(spec, elem);

            parentNode.AddChild(svgPath);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_X:
                {
                    spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Y:
                {
                    spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Width:
                {
                    spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Height:
                {
                    spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                }
                break;

                default:
                {
                    //other attrs
                    switch (attr.Name)
                    {
                    case "d":
                    {
                        //parse vertex commands
                        Svg.Pathing.SvgPathDataParser parser = new Svg.Pathing.SvgPathDataParser();
                        svgPath.Segments = parser.Parse(attr.Value.ToCharArray());
                    }
                    break;
                    }
                }
                break;
                }
            }
        }
Esempio n. 6
0
        static void CreateSvgLinearGradient(SvgElement parentNode, HtmlElement elem)
        {
            //linear gradient definition

            SvgLinearGradient linearGradient = new SvgLinearGradient(elem);

            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WellknownName.Svg_X1:
                {
                    linearGradient.X1 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_X2:
                {
                    linearGradient.X2 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_Y1:
                {
                    linearGradient.Y1 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_Y2:
                {
                    linearGradient.Y2 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;
                }
            }
            //------------------------------------------------------------
            int j = elem.ChildrenCount;
            List <StopColorPoint> stopColorPoints = new List <StopColorPoint>(j);

            for (int i = 0; i < j; ++i)
            {
                HtmlElement node = elem.GetChildNode(i) as HtmlElement;
                if (node == null)
                {
                    continue;
                }
                switch (node.WellknownElementName)
                {
                case WellKnownDomNodeName.svg_stop:
                {
                    //stop point
                    StopColorPoint stopPoint = new StopColorPoint();
                    foreach (WebDom.DomAttribute attr in node.GetAttributeIterForward())
                    {
                        WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                        switch (wellknownName)
                        {
                        case WellknownName.Svg_StopColor:
                        {
                            stopPoint.StopColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;

                        case WellknownName.Svg_Offset:
                        {
                            stopPoint.Offset = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                        }
                    }
                    stopColorPoints.Add(stopPoint);
                }
                break;
                }
            }
        }
Esempio n. 7
0
 internal static LayoutFarm.Css.CssLength ParseGenericLength(string value)
 {
     return(UserMapUtil.ParseGenericLength(value));
 }
Esempio n. 8
0
            void ParseStyle(SvgVisualSpec spec, string cssStyle)
            {
                if (!String.IsNullOrEmpty(cssStyle))
                {
#if DEBUG
                    s_dbugIdCount++;
#endif
                    //***
                    CssRuleSet cssRuleSet = _ownerParser._cssParser.ParseCssPropertyDeclarationList(cssStyle.ToCharArray());

                    foreach (CssPropertyDeclaration propDecl in cssRuleSet.GetAssignmentIter())
                    {
                        switch (propDecl.UnknownRawName)
                        {
                        default:
                            break;

                        case "fill":
                        {
                            int valueCount = propDecl.ValueCount;
                            //1
                            string value = propDecl.GetPropertyValue(0).ToString();
                            if (value != "none")
                            {
                                spec.FillColor = ConvToActualColor(CssValueParser2.GetActualColor(value));
                            }
                        }
                        break;

                        case "fill-opacity":
                        {
                            //TODO:
                            //adjust fill opacity
                        }
                        break;

                        case "stroke-width":
                        {
                            int valueCount = propDecl.ValueCount;
                            //1
                            string value = propDecl.GetPropertyValue(0).ToString();

                            spec.StrokeWidth = UserMapUtil.ParseGenericLength(value);
                        }
                        break;

                        case "stroke":
                        {
                            //TODO:
                            //if (attr.Value != "none")
                            //{
                            //    spec.StrokeColor = ConvToActualColor(CssValueParser2.GetActualColor(attr.Value));
                            //}
                        }
                        break;

                        case "stroke-linecap":
                            //set line-cap and line join again
                            //TODO:
                            break;

                        case "stroke-linejoin":
                            //TODO:
                            break;

                        case "stroke-miterlimit":
                            //TODO:
                            break;

                        case "stroke-opacity":
                            //TODO:
                            break;

                        case "transform":
                        {
                            ////parse trans
                            //ParseTransform(attr.Value, spec);
                        }
                        break;
                        }
                    }
                }
            }
Esempio n. 9
0
            public virtual bool AddAttribute(string name, string value)
            {
                switch (name)
                {
                default:
                    return(false);

                case "class":
                    spec.Id = value;
                    break;

                case "id":
                    spec.Id = value;
                    return(true);

                case "style":
                    ParseStyle(spec, value);
                    break;

                case "fill":
                {
                    if (value != "none")
                    {
                        spec.FillColor = ConvToActualColor(CssValueParser2.GetActualColor(value));
                    }
                }
                break;

                case "fill-opacity":
                {
                    //adjust fill opacity
                }
                break;

                case "stroke-width":
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(value);
                }
                break;

                case "stroke":
                {
                    if (value != "none")
                    {
                        spec.StrokeColor = ConvToActualColor(CssValueParser2.GetActualColor(value));
                    }
                }
                break;

                case "stroke-linecap":
                    //set line-cap and line join again

                    break;

                case "stroke-linejoin":

                    break;

                case "stroke-miterlimit":

                    break;

                case "stroke-opacity":

                    break;

                case "transform":
                {
                    //parse trans
                    ParseTransform(value, spec);
                }
                break;
                }
                return(true);
            }