public override void SetProperty(string property, ref Utf8JsonReader reader, JsonSerializerOptions options) { base.SetProperty(property, ref reader, options); switch (property) { case "border": Border = (Border)JsonSerializer.Deserialize(ref reader, typeof(Border), options); break; case "shadow": Shadow = (Shadow)JsonSerializer.Deserialize(ref reader, typeof(Shadow), options); break; } }
public async override Task <HtmlNode> Create(HtmlNode column, NicheShackContext context) { // Call the base HtmlNode widget = await base.Create(column, context); // Td HtmlNode td = widget.SelectSingleNode("tr/td"); td.SetAttributeValue("height", Height.ToString()); td.SetAttributeValue("style", "height: " + Height + "px;"); // Set the styles if (Background != null) { await Background.SetStyle(td, context); } if (Border != null) { Border.SetStyle(td); } if (Corners != null) { Corners.SetStyle(td); } if (Shadow != null) { Shadow.SetStyle(td); } if (Padding != null) { Padding.SetStyle(td); } HtmlNode container = Table.Create(td); return(container); }
public async Task <HtmlNode> Create(HtmlNode row, NicheShackContext context) { // Create the column HtmlNode column = row.AppendChild(HtmlNode.CreateNode("<td>")); column.SetAttributeValue("style", "display: inline-block;width: 100%;max-width: " + Width + "px;"); // Set the styles if (Background != null) { await Background.SetStyle(column, context); } if (Border != null) { Border.SetStyle(column); } if (Corners != null) { Corners.SetStyle(column); } if (Shadow != null) { Shadow.SetStyle(column); } if (Padding != null) { Padding.SetStyle(column); } column.AppendChild(new HtmlDocument().CreateComment(Table.MicrosoftIf + "<table width=\"" + Width + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td>" + Table.MicrosoftEndIf)); return(column); }
public async override Task <HtmlNode> Create(HtmlNode column, NicheShackContext context) { float height = Height > 0 ? Height : 40; // Call the base HtmlNode widget = await base.Create(column, context); // Td HtmlNode td = widget.SelectSingleNode("tr/td"); // Set the styles if (Background != null) { await Background.SetStyle(td, context); } if (Border != null) { Border.SetStyle(td); } if (Corners != null) { Corners.SetStyle(td); } if (Shadow != null) { Shadow.SetStyle(td); } // Anchor HtmlNode anchorNode = HtmlNode.CreateNode("<a>"); string styles = "display: block;text-align: center;" + (Caption.TextDecoration == null ? "text-decoration: none;" : ""); var fontSize = int.Parse(Caption.FontSize); var padding = Math.Max(0, ((height - fontSize) / 2) - 1); var paddingTop = Padding != null && Padding.Top != null?int.Parse(Padding.Top.Substring(0, Padding.Top.Length - 2)) : 0; var paddingBottom = Padding != null && Padding.Bottom != null?int.Parse(Padding.Bottom.Substring(0, Padding.Bottom.Length - 2)) : 0; styles += "padding-top: " + (padding + paddingTop) + "px;"; styles += "padding-bottom: " + (padding + paddingBottom) + "px;"; if (Padding != null && Padding.Right != null) { styles += "padding-right: " + Padding.Right + "px;"; } if (Padding != null && Padding.Left != null) { styles += "padding-left: " + Padding.Left + "px;"; } anchorNode.SetAttributeValue("style", styles); // Caption Caption.SetStyle(anchorNode); // Link if (Link != null) { Link.SetStyle(anchorNode); } td.AppendChild(new HtmlDocument().CreateComment(Table.MicrosoftIf + "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" style=\"padding-top: " + (padding + paddingTop) + "px;padding-bottom: " + (padding + paddingBottom) + "px;text-align: center;\"><tr><td>" + Table.MicrosoftEndIf)); td.AppendChild(anchorNode); td.AppendChild(new HtmlDocument().CreateComment(Table.MicrosoftIf + "</td></tr></table>" + Table.MicrosoftEndIf)); return(anchorNode); }