/// <summary> /// Gets a querystring that represent this set of settings in the format ?w=20&h=30 /// </summary> public string ToQueryString() { var qs = new QueryStringBuilder(); if (Anchor != DEFAULT_ANCHOR_LOCATION) { qs.Add(QS_ANCHOR, Anchor.ToString()); } if (Width > 0) { qs.Add(QS_WIDTH, Width.ToString()); } if (Height > 0) { qs.Add(QS_HEIGHT, Height.ToString()); } if (Mode != ImageFitMode.Default) { qs.Add(QS_MODE, Mode.ToString().ToLower()); } if (Scale != ImageScaleMode.DownscaleOnly) { qs.Add(QS_SCALE, Scale.ToString().ToLower()); } if (!string.IsNullOrWhiteSpace(BackgroundColor)) { qs.Add(QS_BACKGROUND_COLOR, BackgroundColor.ToLower()); } return(qs.OrderAndRender()); }
/// <summary> /// Get the css style fragement /// </summary> /// <returns>The css style attribute</returns> public string GetHtmlStyle() { string style = "style=\""; if (BackgroundColor != null) { if (BackgroundColor.ToLower() != "transparent") { style += "background-color: " + BackgroundColor + "; "; } else { style += "background-color: #FFFFFF; "; } } else { style += "background-color: #FFFFFF; "; } if (!style.EndsWith("; ")) { style = ""; } else { style += "\""; } return(style); }
private Rectangle CreateBackground() { if (!string.IsNullOrWhiteSpace(BackgroundColor) || BackgroundColor?.ToLower() == "transparent") { return(new Rectangle(Height, Width, 0, 0, new ElementStyle() { Fill = BackgroundColor, StrokeColor = "none" })); } return(null); }
private void OnDeserialized(StreamingContext context) { // Called when the deserialization process is complete. BackgroundColor = BackgroundColor.ToLower(); ForgroundColor = ForgroundColor.ToLower(); }