public static CssColor AsColor(WebDom.CssCodeValueExpression value)
 {
     if (value.EvaluatedAs != WebDom.CssValueEvaluatedAs.Color)
     {
         if (value is WebDom.CssCodeColor)
         {
             return(((WebDom.CssCodeColor)value).ActualColor);
         }
         else
         {
             CssColor actualColor = CssValueParser2.GetActualColor(value.GetTranslatedStringValue());
             value.SetColorValue(actualColor);
             return(actualColor);
         }
     }
     return(value.GetCacheColor());
 }
Exemple #2
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;
                        }
                    }
                }
            }
Exemple #3
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);
            }