public virtual Control ToHtmlControl() { Literal control = null; if (this.Dimension != Dimension.None) { this.CssClass = ":" + this.Dimension.ToString(); } if (string.IsNullOrWhiteSpace(this.ImageUrl)) { if (!string.IsNullOrWhiteSpace(this.Icon)) { var css = Utility.ResolveCssClass(":" + this.Icon, () => this.CssClass); control = new Literal("i", "icon" + (string.IsNullOrWhiteSpace(css) ? "" : " " + css)); } } else { control = new Literal("img", "image"); control.SetAttributeValue("src", this.ImageUrl); if (!string.IsNullOrWhiteSpace(this.Placeholder)) { control.SetAttributeValue("alt", this.Placeholder); } if (!Unit.IsEmpty(this.Width)) { control.SetAttributeValue("width", this.Width.ToString()); } if (!Unit.IsEmpty(this.Height)) { control.SetAttributeValue("height", this.Height.ToString()); } if (!string.IsNullOrWhiteSpace(this.CssClass)) { control.CssClass = this.CssClass; } } if (control == null) { return(new Literal()); } if (string.IsNullOrWhiteSpace(this.NavigateUrl)) { return(control); } var container = new Literal("a", "image"); container.SetAttributeValue("href", this.NavigateUrl); container.Controls.Add(control); return(container); }
protected virtual void CreateHeaderContent(Control container) { var header = new Literal("h3", "ui header"); container.Controls.Add(header); if (this.Image != null) { var control = this.Image.ToHtmlControl(); header.Controls.Add(control); } var content = new Literal("div", "content"); header.Controls.Add(content); if (!string.IsNullOrWhiteSpace(this.Title)) { var control = new Literal("a", "widget-header-title") { Text = this.Title, TextEncoded = this.TextEncoded, }; if (!string.IsNullOrWhiteSpace(this.NavigateUrl)) { control.SetAttributeValue("href", this.ResolveUrl(this.NavigateUrl)); } content.Controls.Add(control); } if (!string.IsNullOrWhiteSpace(this.Description)) { var control = new Literal("p", "widget-header-description sub header") { Text = this.Description, TextEncoded = this.TextEncoded, }; content.Controls.Add(control); } }
public virtual Control ToHtmlControl() { Literal control = null; if(this.Dimension != Dimension.None) this.CssClass = ":" + this.Dimension.ToString(); if(string.IsNullOrWhiteSpace(this.ImageUrl)) { if(!string.IsNullOrWhiteSpace(this.Icon)) { var css = Utility.ResolveCssClass(":" + this.Icon, () => this.CssClass); control = new Literal("i", "icon" + (string.IsNullOrWhiteSpace(css) ? "" : " " + css)); } } else { control = new Literal("img", "image"); control.SetAttributeValue("src", this.ImageUrl); if(!string.IsNullOrWhiteSpace(this.Placeholder)) control.SetAttributeValue("alt", this.Placeholder); if(!Unit.IsEmpty(this.Width)) control.SetAttributeValue("width", this.Width.ToString()); if(!Unit.IsEmpty(this.Height)) control.SetAttributeValue("height", this.Height.ToString()); if(!string.IsNullOrWhiteSpace(this.CssClass)) control.CssClass = this.CssClass; } if(control == null) return new Literal(); if(string.IsNullOrWhiteSpace(this.NavigateUrl)) return control; var container = new Literal("a", "image"); container.SetAttributeValue("href", this.NavigateUrl); container.Controls.Add(control); return container; }
public static ICollection <Control> GenerateParts(ICollection <ViewPart> parts, Func <ViewPart, Control> containerThunk) { if (containerThunk == null) { throw new ArgumentNullException(); } if (parts == null || parts.Count < 1) { return(null); } var containers = new List <Control>(); Control container = null; foreach (var part in parts) { if (containers.Count == 0 || (string.IsNullOrWhiteSpace(part.Text) && string.IsNullOrWhiteSpace(part.Icon))) { container = containerThunk(part); if (container != null) { containers.Add(container); } } Literal wrapper = null; var css = Utility.ResolveCssClass(part.Alignment == HorizontalAlignment.Right ? ":right floated" : string.Empty, () => part.CssClass); if (string.IsNullOrWhiteSpace(part.NavigateUrl)) { wrapper = new Literal("span", css); } else { wrapper = new Literal("a", css); wrapper.SetAttributeValue("href", part.NavigateUrl); } if (!string.IsNullOrWhiteSpace(part.Style)) { wrapper.SetAttributeValue("style", part.Style); } if (part.Properties.Count > 0) { foreach (var property in part.Properties) { wrapper.SetAttributeValue(property.Name, property.Value); } } container.Controls.Add(wrapper); if (part.IconAlignment == HorizontalAlignment.Left) { if (!string.IsNullOrWhiteSpace(part.Icon)) { (wrapper ?? container).Controls.Add(new Literal("i", part.Icon + " icon")); } (wrapper ?? container).Controls.Add(new Literal() { Text = part.Text, }); } else { (wrapper ?? container).Controls.Add(new Literal() { Text = part.Text, }); if (!string.IsNullOrWhiteSpace(part.Icon)) { (wrapper ?? container).Controls.Add(new Literal("i", part.Icon + " icon")); } } } return(containers); }
public static ICollection<Control> GenerateParts(ICollection<ViewPart> parts, Func<ViewPart, Control> containerThunk) { if(containerThunk == null) throw new ArgumentNullException(); if(parts == null || parts.Count < 1) return null; var containers = new List<Control>(); Control container = null; foreach(var part in parts) { if(containers.Count == 0 || (string.IsNullOrWhiteSpace(part.Text) && string.IsNullOrWhiteSpace(part.Icon))) { container = containerThunk(part); if(container != null) containers.Add(container); } Literal wrapper = null; var css = Utility.ResolveCssClass(part.Alignment == HorizontalAlignment.Right ? ":right floated" : string.Empty, () => part.CssClass); if(string.IsNullOrWhiteSpace(part.NavigateUrl)) wrapper = new Literal("span", css); else { wrapper = new Literal("a", css); wrapper.SetAttributeValue("href", part.NavigateUrl); } if(!string.IsNullOrWhiteSpace(part.Style)) wrapper.SetAttributeValue("style", part.Style); if(part.Properties.Count > 0) { foreach(var property in part.Properties) { wrapper.SetAttributeValue(property.Name, property.Value); } } container.Controls.Add(wrapper); if(part.IconAlignment == HorizontalAlignment.Left) { if(!string.IsNullOrWhiteSpace(part.Icon)) (wrapper ?? container).Controls.Add(new Literal("i", part.Icon + " icon")); (wrapper ?? container).Controls.Add(new Literal() { Text = part.Text, }); } else { (wrapper ?? container).Controls.Add(new Literal() { Text = part.Text, }); if(!string.IsNullOrWhiteSpace(part.Icon)) (wrapper ?? container).Controls.Add(new Literal("i", part.Icon + " icon")); } } return containers; }