Exemplo n.º 1
0
        static void SetPropertyValue(BoxSpec spec, WebDom.CssPropertyDeclaration decl)
        {
            //assign property  
            CssCodeValueExpression cssValue = decl.GetPropertyValue(0);
            switch (decl.WellknownPropertyName)
            {
                case WellknownCssPropertyName.Display:
                    spec.CssDisplay = UserMapUtil.GetDisplayType(cssValue);
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.BorderBottomWidth:
                    spec.BorderBottomWidth = cssValue.AsBorderLength();
                    break;
                case WellknownCssPropertyName.BorderLeftWidth:
                    spec.BorderLeftWidth = cssValue.AsBorderLength();
                    break;
                case WellknownCssPropertyName.BorderRightWidth:
                    spec.BorderRightWidth = cssValue.AsBorderLength();
                    break;
                case WellknownCssPropertyName.BorderTopWidth:
                    spec.BorderTopWidth = cssValue.AsBorderLength();
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.BorderBottomStyle:
                    spec.BorderBottomStyle = UserMapUtil.GetBorderStyle(cssValue);
                    break;
                case WellknownCssPropertyName.BorderLeftStyle:
                    spec.BorderLeftStyle = UserMapUtil.GetBorderStyle(cssValue);
                    break;
                case WellknownCssPropertyName.BorderRightStyle:
                    spec.BorderRightStyle = UserMapUtil.GetBorderStyle(cssValue);
                    break;
                case WellknownCssPropertyName.BorderTopStyle:
                    spec.BorderTopStyle = UserMapUtil.GetBorderStyle(cssValue);
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.BorderBottomColor:
                    spec.BorderBottomColor = AsColor(cssValue);
                    break;
                case WellknownCssPropertyName.BorderLeftColor:
                    spec.BorderLeftColor = AsColor(cssValue);
                    break;
                case WellknownCssPropertyName.BorderRightColor:
                    spec.BorderRightColor = AsColor(cssValue);
                    break;
                case WellknownCssPropertyName.BorderTopColor:
                    spec.BorderTopColor = AsColor(cssValue); ;
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.BorderSpacing:

                    SetBorderSpacing(spec, cssValue);
                    break;
                case WellknownCssPropertyName.BorderCollapse:
                    spec.BorderCollapse = UserMapUtil.GetBorderCollapse(cssValue);
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.BoxSizing:
                    spec.BoxSizing = UserMapUtil.GetBoxSizing(cssValue);
                    break;
                case WellknownCssPropertyName.BoxShadow:
                    SetBoxShadow(spec, decl);
                    break;
                case WellknownCssPropertyName.CornerRadius:

                    SetCornerRadius(spec, cssValue);
                    break;
                case WellknownCssPropertyName.CornerNWRadius:
                    spec.CornerNWRadius = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.CornerNERadius:
                    spec.CornerNERadius = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.CornerSERadius:
                    spec.CornerSERadius = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.CornerSWRadius:
                    spec.CornerSWRadius = cssValue.AsLength();
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.MarginBottom:
                    spec.MarginBottom = cssValue.AsTranslatedLength();
                    break;
                case WellknownCssPropertyName.MarginLeft:
                    spec.MarginLeft = cssValue.AsTranslatedLength();
                    break;
                case WellknownCssPropertyName.MarginRight:
                    spec.MarginRight = cssValue.AsTranslatedLength();
                    break;
                case WellknownCssPropertyName.MarginTop:
                    spec.MarginTop = cssValue.AsTranslatedLength();
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.PaddingBottom:
                    spec.PaddingBottom = cssValue.AsTranslatedLength();
                    break;
                case WellknownCssPropertyName.PaddingLeft:
                    spec.PaddingLeft = cssValue.AsTranslatedLength();
                    break;
                case WellknownCssPropertyName.PaddingRight:
                    spec.PaddingRight = cssValue.AsTranslatedLength();
                    break;
                case WellknownCssPropertyName.PaddingTop:
                    spec.PaddingTop = cssValue.AsTranslatedLength();
                    break;
                //------------------------------------------------
                case WellknownCssPropertyName.Left:
                    spec.Left = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.Top:
                    spec.Top = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.Width:
                    spec.Width = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.MaxWidth:
                    spec.MaxWidth = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.Height:
                    spec.Height = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.BackgroundColor:
                    spec.BackgroundColor = AsColor(cssValue);
                    break;
                case WellknownCssPropertyName.BackgroundImage:
                    spec.BackgroundImageBinder = new ClientImageBinder(cssValue.GetTranslatedStringValue());
                    break;
                case WellknownCssPropertyName.BackgroundPosition:
                    SetBackgroundPosition(spec, cssValue);
                    break;
                case WellknownCssPropertyName.BackgroundRepeat:
                    spec.BackgroundRepeat = UserMapUtil.GetBackgroundRepeat(cssValue);
                    break;
                case WellknownCssPropertyName.BackgroundGradient:
                    spec.BackgroundGradient = AsColor(cssValue);
                    break;
                case WellknownCssPropertyName.BackgroundGradientAngle:
                    spec.BackgroundGradientAngle = cssValue.AsNumber();
                    break;
                case WellknownCssPropertyName.Color:
                    spec.Color = AsColor(cssValue);
                    break;
                case WellknownCssPropertyName.Direction:
                    spec.CssDirection = UserMapUtil.GetCssDirection(cssValue);
                    break;
                case WellknownCssPropertyName.EmptyCells:
                    spec.EmptyCells = UserMapUtil.GetEmptyCell(cssValue);
                    break;
                case WellknownCssPropertyName.Float:
                    spec.Float = UserMapUtil.GetFloat(cssValue);
                    break;
                case WellknownCssPropertyName.Position:
                    spec.Position = UserMapUtil.GetCssPosition(cssValue);
                    break;
                case WellknownCssPropertyName.LineHeight:
                    spec.LineHeight = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.VerticalAlign:
                    spec.VerticalAlign = UserMapUtil.GetVerticalAlign(cssValue);
                    break;
                case WellknownCssPropertyName.TextIndent:
                    spec.TextIndent = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.TextAlign:

                    spec.CssTextAlign = UserMapUtil.GetTextAlign(cssValue);
                    break;
                case WellknownCssPropertyName.TextDecoration:
                    spec.TextDecoration = UserMapUtil.GetTextDecoration(cssValue);
                    break;
                case WellknownCssPropertyName.Whitespace:
                    spec.WhiteSpace = UserMapUtil.GetWhitespace(cssValue);
                    break;
                case WellknownCssPropertyName.WordBreak:
                    spec.WordBreak = UserMapUtil.GetWordBreak(cssValue);
                    break;
                case WellknownCssPropertyName.Visibility:
                    spec.Visibility = UserMapUtil.GetVisibility(cssValue);
                    break;
                case WellknownCssPropertyName.WordSpacing:
                    spec.WordSpacing = cssValue.AsLength();
                    break;
                case WellknownCssPropertyName.FontFamily:
                    spec.FontFamily = cssValue.GetTranslatedStringValue();
                    break;
                case WellknownCssPropertyName.FontSize:

                    SetFontSize(spec, cssValue);
                    break;
                case WellknownCssPropertyName.FontStyle:
                    spec.FontStyle = UserMapUtil.GetFontStyle(cssValue);
                    break;
                case WellknownCssPropertyName.FontVariant:
                    spec.FontVariant = UserMapUtil.GetFontVariant(cssValue);
                    break;
                case WellknownCssPropertyName.FontWeight:
                    spec.FontWeight = UserMapUtil.GetFontWeight(cssValue);
                    break;
                case WellknownCssPropertyName.ListStyle:
                    spec.ListStyle = cssValue.GetTranslatedStringValue();
                    break;
                case WellknownCssPropertyName.ListStylePosition:
                    spec.ListStylePosition = UserMapUtil.GetListStylePosition(cssValue);
                    break;
                case WellknownCssPropertyName.ListStyleImage:
                    spec.ListStyleImage = cssValue.GetTranslatedStringValue();
                    break;
                case WellknownCssPropertyName.ListStyleType:
                    spec.ListStyleType = UserMapUtil.GetListStyleType(cssValue);
                    break;
                case WellknownCssPropertyName.Overflow:
                    spec.Overflow = UserMapUtil.GetOverflow(cssValue);
                    break;
                //------------------------------------------------ 
                //for flex container
                case WellknownCssPropertyName.Flex:
                    {
                        //TODO: implement this
                    }
                    break;
                case WellknownCssPropertyName.FlexDirection:
                    {
                        //TODO: implement this
                    }
                    break;
                case WellknownCssPropertyName.FlexFlow:
                    {
                        //TODO: implement this
                    }
                    break;
                case WellknownCssPropertyName.FlexWrap:
                    {
                        //TODO: implement this
                    }
                    break;
                //------------------------------------------------ 
                //for flex item
                case WellknownCssPropertyName.FlexGrow:
                    spec.FlexGrow = (int)cssValue.AsNumber();
                    break;
                case WellknownCssPropertyName.FlexShrink:
                    spec.FlexShrink = (int)cssValue.AsNumber();
                    break;
                case WellknownCssPropertyName.FlexOrder:
                    spec.FlexOrder = (int)cssValue.AsNumber();
                    break;
                //------------------------------------------------   
                //experiment : for container
                case WellknownCssPropertyName.FlexExtensionNum:
                    spec.FlexExtensionNum = (int)cssValue.AsNumber();
                    break;
                //experiment : for space part
                case WellknownCssPropertyName.FlexExtensionPart:
                    spec.FlexExtensionPart = (int)cssValue.AsNumber();
                    break;
            }
        }
Exemplo n.º 2
0
 static void SetBoxShadow(BoxSpec box, WebDom.CssPropertyDeclaration decl)
 {
     switch (decl.ValueCount)
     {
         case 2:
             {
                 //
                 var v0 = decl.GetPropertyValue(0);
                 var v1 = decl.GetPropertyValue(1);
                 box.BoxShadowHOffset = v0.AsLength();
                 box.BoxShadowVOffset = v1.AsLength();
             }
             break;
         case 3:
             {
                 var v0 = decl.GetPropertyValue(0);
                 var v1 = decl.GetPropertyValue(1);
                 var v2 = decl.GetPropertyValue(2);
                 box.BoxShadowHOffset = v0.AsLength();
                 box.BoxShadowVOffset = v1.AsLength();
                 box.BoxShadowColor = AsColor(v2);
             }
             break;
     }
 }