/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContext context) { var profile = new ControlAvatar() { User = User, Image = Image }; var timespan = string.Empty; var days = (DateTime.Now - Timestamp).Days; if (days == 1) { timespan = "vor ein Tag"; } else if (days < 1) { var hours = (DateTime.Now - Timestamp).Hours; if (hours == 1) { timespan = "vor einer Stunde"; } else if (hours < 1) { var minutes = (DateTime.Now - Timestamp).Minutes; if (minutes == 1) { timespan = "vor einer Minute"; } else if (minutes < 1) { timespan = "gerade ebend"; } else { timespan = "vor " + minutes + " Minuten"; } } else { timespan = "vor " + hours + " Stunden"; } } else { timespan = "vor " + days + " Tagen"; } var date = new ControlText() { Text = timespan, Title = "Am " + Timestamp.ToShortDateString() + " um " + Timestamp.ToShortTimeString() + " Uhr", Format = TypeFormatText.Span, TextColor = new PropertyColorText(TypeColorText.Muted) }; var header = new HtmlElementTextContentDiv(profile.Render(context), date.Render(context)) { Class = "header" }; var body = new HtmlElementTextContentDiv(new HtmlText(Post)) { Class = "post" }; var likeText = "Gefällt mir" + (Likes > 0 ? " (" + Likes + ")" : string.Empty); var like = new ControlButtonLink() { Icon = new PropertyIcon(TypeIcon.ThumbsUp), Text = likeText, Uri = context.Page.Uri, Size = TypeSizeButton.Small, BackgroundColor = new PropertyColorButton(TypeColorButton.Light), Outline = true, TextColor = new PropertyColorText(TypeColorText.Primary) }; var option = new HtmlElementTextContentDiv(Likes > 0 ? like.Render(context) : null) { Class = "options" }; var html = new HtmlElementTextContentDiv(header, body, option) { Class = Css.Concatenate("comment", GetClasses()), Style = GetStyles(), Role = Role }; return(html); }
/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContextFormular context) { if (Disabled) { Classes.Add("disabled"); } switch (ValidationResult) { case TypesInputValidity.Success: Classes.Add("input-success"); break; case TypesInputValidity.Warning: Classes.Add("input-warning"); break; case TypesInputValidity.Error: Classes.Add("input-error"); break; } var html = new HtmlElementTextContentDiv() { ID = $"moveselector_{ID}", Class = Css.Concatenate("moveselector", GetClasses()), // form-control Style = GetStyles(), Role = "moveselector" }; var selectedHeader = new ControlText("selectedHeader") { Text = context.I18N("webexpress", "form.moveselector.selected"), TextColor = new PropertyColorText(TypeColorText.Muted), Format = TypeFormatText.Paragraph }; var selectedList = new ControlList("selectedOptions") { Layout = TypeLayoutList.Flush }; var leftAllButton = new ControlButton("") { Text = "<<", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var leftButton = new ControlButton("") { Text = "<", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var rightButton = new ControlButton("") { Text = ">", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var rightAllButton = new ControlButton("") { Text = ">>", BackgroundColor = new PropertyColorButton(TypeColorButton.Primary), Block = TypeBlockButton.Block }; var availableHeader = new ControlText("availableHeader") { Text = context.I18N("webexpress", "form.moveselector.available"), TextColor = new PropertyColorText(TypeColorText.Muted), Format = TypeFormatText.Paragraph }; var availableList = new ControlList("availableOptions") { Layout = TypeLayoutList.Flush }; var sticky = new List <string>(new string[] { "position: sticky;" }); html.Elements.Add(new HtmlElementTextContentDiv ( selectedHeader.Render(context), selectedList.Render(context) ) { Class = "moveselector-list" }); html.Elements.Add(new HtmlElementTextContentDiv ( leftAllButton.Render(context), leftButton.Render(context), rightButton.Render(context), rightAllButton.Render(context) ) { Class = "moveselector-button" }); html.Elements.Add(new HtmlElementTextContentDiv ( availableHeader.Render(context), availableList.Render(context) ) { Class = "moveselector-list" }); return(html); }
/// <summary> /// In HTML konvertieren /// </summary> /// <param name="context">Der Kontext, indem das Steuerelement dargestellt wird</param> /// <returns>Das Control als HTML</returns> public override IHtmlNode Render(RenderContext context) { var profile = new ControlAvatar() { User = User, Image = Image }; var timespan = string.Empty; var days = (DateTime.Now - Timestamp).Days; if (days == 1) { timespan = "vor ein Tag"; } else if (days < 1) { var hours = (DateTime.Now - Timestamp).Hours; if (hours == 1) { timespan = "vor einer Stunde"; } else if (hours < 1) { var minutes = (DateTime.Now - Timestamp).Minutes; if (minutes == 1) { timespan = "vor einer Minute"; } else if (minutes < 1) { timespan = "gerade ebend"; } else { timespan = "vor " + minutes + " Minuten"; } } else { timespan = "vor " + hours + " Stunden"; } } else { timespan = "vor " + days + " Tagen"; } var date = new ControlText() { Text = timespan, Title = "Am " + Timestamp.ToShortDateString() + " um " + Timestamp.ToShortTimeString() + " Uhr", Format = TypeFormatText.Span, TextColor = new PropertyColorText(TypeColorText.Muted) }; var headerText = new HtmlElementTextContentP ( new ControlText() { Text = Action, TextColor = new PropertyColorText(TypeColorText.Info), Format = TypeFormatText.Span }.Render(context), date.Render(context) ); var setting = new ControlDropdown() { //Icon = new PropertyIcon(TypeIcon.Cog), BackgroundColor = new PropertyColorButton(TypeColorButton.Light), HorizontalAlignment = TypeHorizontalAlignment.Right, Size = TypeSizeButton.Small }; setting.Add(new ControlDropdownItemLink() { Text = "Löschen", Icon = new PropertyIcon(TypeIcon.TrashAlt), TextColor = new PropertyColorText(TypeColorText.Danger), Uri = context.Page.Uri }); var header = new HtmlElementTextContentDiv(setting.Render(context), profile.Render(context), headerText) { Class = "header" }; var body = new HtmlElementTextContentDiv(new HtmlText(Post)) { Class = Css.Concatenate("post", GetClasses()), Style = GetStyles(), Role = Role }; var likeText = "Gefällt mir" + (Likes > 0 ? " (" + Likes + ")" : string.Empty); var like = new ControlButtonLink() { Icon = new PropertyIcon(TypeIcon.ThumbsUp), Text = likeText, Uri = context.Page.Uri, Size = TypeSizeButton.Small, BackgroundColor = new PropertyColorButton(TypeColorButton.Light), Outline = true, TextColor = new PropertyColorText(TypeColorText.Primary) }; var option = new HtmlElementTextContentDiv(like.Render(context)) { Class = "options" }; var html = new HtmlList(header, body, option); html.Elements.AddRange(from x in Comments select x.Render(context)); var form = new ControlFormular() { Name = !string.IsNullOrWhiteSpace(Name) ? Name : "form", EnableCancelButton = false }; form.SubmitButton.Icon = new PropertyIcon(TypeIcon.PaperPlane); form.SubmitButton.Text = "Antworten"; form.SubmitButton.Outline = true; form.SubmitButton.Size = TypeSizeButton.Small; //form.SubmitButton.HorizontalAlignment = TypeHorizontalAlignment.Default; form.Add(new ControlFormularItemInputTextBox() { Format = TypesEditTextFormat.Multiline, Placeholder = "Kommentieren..." }); html.Elements.Add(form.Render(context)); return(html); }