public void ApplyStyle(IModelLayoutStyle layoutStyle, WebControl webControl) { ApplyColors(layoutStyle, webControl); var fontStyle = GetValue <FontStyle>(layoutStyle, _fontStylePropertyName); if (fontStyle != FontStyle.Regular) { webControl.Style.Add(HtmlTextWriterStyle.FontStyle, fontStyle.ToString()); } ApplyCssClassAndInlineStyle(layoutStyle, webControl); }
void ApplyColors(IModelLayoutStyle layoutStyle, WebControl webControl) { var color = GetValue <Color>(layoutStyle, _backColorPropertyName); if (color != Color.Empty) { webControl.Style.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color)); } color = GetValue <Color>(layoutStyle, _fontColorPropertyName); if (color != Color.Empty) { webControl.Style.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color)); } }
void ApplyCssClassAndInlineStyle(IModelLayoutStyle layoutStyle, WebControl webControl) { var value = GetValue <string>(layoutStyle, _cssClassPropertyName); if (!string.IsNullOrEmpty(value)) { webControl.CssClass = value; } value = GetValue <string>(layoutStyle, _stylePropertyName); if (!string.IsNullOrEmpty(value)) { webControl.Style.Value += ";" + value; } }
T GetValue <T>(IModelLayoutStyle modelLayoutStyle, string name) { var value = modelLayoutStyle.GetValue <T>(name); return(!IsDefault(value) ? value : default);