상속: SvgElement
예제 #1
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;
                }
            }
        }
예제 #2
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;
                }
            }
        }