protected bool DoConvertBackgroundRepeat(StyleBase onStyle, object value, out PatternRepeat result) { if (null == value) { result = PatternRepeat.RepeatBoth; return(false); } else if (CSSBackgroundRepeatParser.TryGetRepeatEnum(value.ToString(), out result)) { return(true); } else { result = PatternRepeat.RepeatBoth; return(false); } }
protected override bool DoSetStyleValue(Style onStyle, CSSStyleItemReader reader) { int count = 0; int failed = 0; PatternRepeat repeat; while (reader.ReadNextValue()) { count++; if (IsExpression(reader.CurrentTextValue)) { if (count == 1) { if (!this.AttachExpressionBindingHandler(onStyle, StyleKeys.BgColorKey, reader.CurrentTextValue, DoConvertBackgroundColor)) { failed++; } } else if (count == 2) { if (!this.AttachExpressionBindingHandler(onStyle, StyleKeys.BgImgSrcKey, reader.CurrentTextValue, DoConvertBackgroundImage)) { failed++; } } else if (count == 3) { if (!this.AttachExpressionBindingHandler(onStyle, StyleKeys.BgRepeatKey, reader.CurrentTextValue, DoConvertBackgroundRepeat)) { failed++; } } } else if (IsColor(reader.CurrentTextValue)) { PDFColor color; double? opacity; if (ParseCSSColor(reader.CurrentTextValue, out color, out opacity)) { onStyle.Background.Color = color; onStyle.Background.FillStyle = Drawing.FillType.Solid; if (opacity.HasValue) { onStyle.Background.Opacity = opacity.Value; } } else { failed++; } } else if (IsUrl(reader.CurrentTextValue)) { string url; if (ParseCSSUrl(reader.CurrentTextValue, out url)) { onStyle.Background.ImageSource = url; onStyle.Background.FillStyle = Drawing.FillType.Image; } else { failed++; } } else if (CSSBackgroundRepeatParser.TryGetRepeatEnum(reader.CurrentTextValue, out repeat)) { onStyle.Background.PatternRepeat = repeat; } else { failed++; } //TODO: Parse sizes and positions } return(count > 0 && failed == 0); }