/// <summary> /// In HTML konvertieren /// </summary> /// <returns>Das Control als HTML</returns> public override IHtmlNode ToHtml() { var classes = new List <string>(); classes.Add(Class); switch (Color) { case TypesTextColor.Muted: classes.Add("text-muted"); break; case TypesTextColor.Primary: classes.Add("text-primary"); break; case TypesTextColor.Success: classes.Add("text-success"); break; case TypesTextColor.Info: classes.Add("text-info"); break; case TypesTextColor.Warning: classes.Add("text-warning"); break; case TypesTextColor.Danger: classes.Add("text-danger"); break; case TypesTextColor.Light: classes.Add("text-light"); break; case TypesTextColor.Dark: classes.Add("text-dark"); break; case TypesTextColor.White: classes.Add("text-white"); break; } switch (BackgroundColor) { case TypesBackgroundColor.Primary: classes.Add("bg-primary"); break; case TypesBackgroundColor.Secondary: classes.Add("bg-secondary"); break; case TypesBackgroundColor.Success: classes.Add("bg-success"); break; case TypesBackgroundColor.Info: classes.Add("bg-info"); break; case TypesBackgroundColor.Warning: classes.Add("bg-warning"); break; case TypesBackgroundColor.Danger: classes.Add("bg-danger"); break; case TypesBackgroundColor.Light: classes.Add("bg-light"); break; case TypesBackgroundColor.Dark: classes.Add("bg-dark"); break; case TypesBackgroundColor.White: classes.Add("bg-white"); break; case TypesBackgroundColor.Transparent: classes.Add("bg-transparent"); break; } var param = GetParams(); var html = new HtmlElementA(from x in Content select x.ToHtml()) { ID = ID, Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Style = Style, Role = Role, Alt = Alt, Href = Url + (param.Length > 0 ? "?" + param : string.Empty), Target = Target, OnClick = OnClick }; if (!string.IsNullOrWhiteSpace(Icon) && !string.IsNullOrWhiteSpace(Text)) { html.Elements.Add(new HtmlElementSpan() { Class = Icon }); html.Elements.Add(new HtmlNbsp()); html.Elements.Add(new HtmlNbsp()); html.Elements.Add(new HtmlNbsp()); } else if (!string.IsNullOrWhiteSpace(Icon) && string.IsNullOrWhiteSpace(Text)) { html.AddClass(Icon); } if (!string.IsNullOrWhiteSpace(Text)) { html.Elements.Add(new HtmlText(Text)); } if (Modal != null) { html.AddUserAttribute("data-toggle", "modal"); html.AddUserAttribute("data-target", "#" + Modal.ID); return(new HtmlList(html, Modal.ToHtml())); } if (!string.IsNullOrWhiteSpace(Tooltip)) { html.AddUserAttribute("data-toggle", "tooltip"); html.AddUserAttribute("title", Tooltip); } return(html); }
/// <summary> /// In HTML konvertieren /// </summary> /// <returns>Das Control als HTML</returns> public override IHtmlNode ToHtml() { var classes = new List <string>(); classes.Add(Class); classes.Add("btn"); switch (Color) { case TypesTextColor.Muted: classes.Add("text-muted"); break; case TypesTextColor.Primary: classes.Add("text-primary"); break; case TypesTextColor.Success: classes.Add("text-success"); break; case TypesTextColor.Info: classes.Add("text-info"); break; case TypesTextColor.Warning: classes.Add("text-warning"); break; case TypesTextColor.Danger: classes.Add("text-danger"); break; case TypesTextColor.Light: classes.Add("text-light"); break; case TypesTextColor.Dark: classes.Add("text-dark"); break; case TypesTextColor.White: classes.Add("text-white"); break; } if (Outline) { switch (Layout) { case TypesLayoutButton.Primary: classes.Add("btn-outline-primary"); break; case TypesLayoutButton.Success: classes.Add("btn-outline-success"); break; case TypesLayoutButton.Info: classes.Add("btn-outline-info"); break; case TypesLayoutButton.Warning: classes.Add("btn-outline-warning"); break; case TypesLayoutButton.Danger: classes.Add("btn-outline-danger"); break; case TypesLayoutButton.Dark: classes.Add("btn-outline-dark"); break; } } else { switch (Layout) { case TypesLayoutButton.Primary: classes.Add("btn-primary"); break; case TypesLayoutButton.Success: classes.Add("btn-success"); break; case TypesLayoutButton.Info: classes.Add("btn-info"); break; case TypesLayoutButton.Warning: classes.Add("btn-warning"); break; case TypesLayoutButton.Danger: classes.Add("btn-danger"); break; case TypesLayoutButton.Light: classes.Add("btn-light"); break; case TypesLayoutButton.Dark: classes.Add("btn-dark"); break; } } switch (Size) { case TypesSize.Large: classes.Add("btn-lg"); break; case TypesSize.Small: classes.Add("btn-sm"); break; } if (Block) { classes.Add("btn-block"); } switch (HorizontalAlignment) { case TypesHorizontalAlignment.Left: classes.Add("float-left"); break; case TypesHorizontalAlignment.Right: classes.Add("float-right"); break; } var html = new HtmlElementA() { Class = string.Join(" ", classes.Where(x => !string.IsNullOrWhiteSpace(x))), Role = Role, Href = Url }; if (!string.IsNullOrWhiteSpace(Icon) && !string.IsNullOrWhiteSpace(Text)) { html.Elements.Add(new HtmlElementSpan() { Class = Icon }); html.Elements.Add(new HtmlNbsp()); html.Elements.Add(new HtmlNbsp()); html.Elements.Add(new HtmlNbsp()); } else if (!string.IsNullOrWhiteSpace(Icon) && string.IsNullOrWhiteSpace(Text)) { html.AddClass(Icon); } if (!string.IsNullOrWhiteSpace(Text)) { html.Elements.Add(new HtmlText(Text)); } if (Content.Count > 0) { html.Elements.AddRange(Content.Select(x => x.ToHtml())); } if (Modal != null) { html.AddUserAttribute("data-toggle", "modal"); html.AddUserAttribute("data-target", "#" + Modal.ID); return(new HtmlList(html, Modal.ToHtml())); } return(html); }