/// <summary> /// Creates a function from the given source. /// </summary> /// <param name="source">The token iterator.</param> /// <returns>The created function.</returns> CSSFunction CreateFunction(IEnumerator <CssToken> source) { var name = ((CssKeywordToken)source.Current).Data; var args = new CSSValueList(); //TODO while (source.MoveNext()) { if (source.Current.Type == CssTokenType.RoundBracketClose) { break; } } return(CSSFunction.Create(name, args)); }
public Block(Style parentStyle, String code, Block parent) { Aleros.CSS.Selector selector = new Aleros.CSS.Selector("@internal", code); this.Padding = new Padding("0"); this.Margin = new Margin("1"); foreach (Aleros.CSS.Rule rule in selector.rules) { if (rule.rule == "-alternative-background-color") { this.AlternateBackColor = ColorTranslator.FromHtml(rule.value); } else { this.AlternateBackColor = parent.BackColor; } if (rule.rule == "background" || rule.rule == "background-color") { try { CSSFunction func = new CSSFunction(rule.value); String imageName = func.Arguments[0]; int x = int.Parse(func.Arguments[1]); int y = int.Parse(func.Arguments[2]); int width = int.Parse(func.Arguments[3]); int height = int.Parse(func.Arguments[4]); if (func.Name == "-spider-slice-bitmap") { this.BackgroundImage = sliceBitmap((Bitmap)parentStyle.Images[imageName], new Rectangle(x, y, width, height)); } } catch (Exception e) { this.BackColor = ColorTranslator.FromHtml(rule.value); } } else { this.BackColor = parent.BackColor; } if (rule.rule == "font-color") { this.ForeColor = ColorTranslator.FromHtml(rule.value); } else { this.ForeColor = parent.ForeColor; } if (rule.rule == "padding") { this.Padding = new Padding(rule.value); } else { this.Padding = parent.Padding; } if (rule.rule == "margin") { this.Margin = new Margin(rule.value); } else { this.Margin = parent.Margin; } } }
public CSSValue Done() { Include(); return(CSSFunction.Create(name, arguments)); }