AddChild() публичный Метод

public AddChild ( SvgElement child ) : void
child SvgElement
Результат void
Пример #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;
                }
            }
        }
Пример #2
0
        static void CreateSvgDefs(SvgElement parentNode, HtmlElement elem)
        {
            //inside single definition
            SvgDefinitionList svgDefList = new SvgDefinitionList(elem);

            parentNode.AddChild(svgDefList);
            CreateSvgBoxContent(svgDefList, elem);
        }
Пример #3
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;
                }
            }
        }
Пример #4
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);
        }
Пример #5
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;
                }
            }
        }
Пример #6
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;
                }
            }
        }
Пример #7
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;
         }
     }
 }
Пример #8
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;
                }
            }
        }
Пример #9
0
 static void CreateSvgPolyline(SvgElement parentNode, HtmlElement elem)
 {
     SvgPolylineSpec spec = new SvgPolylineSpec();
     SvgPolyline shape = new SvgPolyline(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.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;
         }
     }
 }
Пример #10
0
 static void CreateSvgDefs(SvgElement parentNode, HtmlElement elem)
 {
     //inside single definition
     SvgDefinitionList svgDefList = new SvgDefinitionList(elem);
     parentNode.AddChild(svgDefList);
     CreateSvgBoxContent(svgDefList, elem);
 }
Пример #11
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);
        }