public async Task <HtmlNode> Create(HtmlNode table, NicheShackContext context) { // Insert a row for spacing if (Top > 0) { HtmlNode blankRow = table.AppendChild(HtmlNode.CreateNode("<tr>")); HtmlNode blankColumn = blankRow.AppendChild(HtmlNode.CreateNode("<td>")); blankColumn.SetAttributeValue("height", Top.ToString()); } // Create the row HtmlNode row = table.AppendChild(HtmlNode.CreateNode("<tr>")); // Set the styles if (Background != null) { await Background.SetStyle(row, context); } if (Border != null) { Border.SetStyle(row); } if (Corners != null) { Corners.SetStyle(row); } if (Shadow != null) { Shadow.SetStyle(row); } if (Padding != null) { Padding.SetStyle(row); } string valign; switch (VerticalAlignment) { case "center": valign = "middle"; break; case "flex-end": valign = "bottom"; break; default: valign = "top"; break; } row.SetAttributeValue("valign", valign); return(row); }
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"); // Image HtmlNode img = HtmlNode.CreateNode("<img>"); if (Width > 0) { img.SetAttributeValue("style", "width: " + Width + "px;"); } // Set the styles if (Border != null) { Border.SetStyle(img); } if (Corners != null) { Corners.SetStyle(img); } if (Shadow != null) { Shadow.SetStyle(img); } await Image.SetStyle(img, context); if (Link != null && Link.Url != null) { // Anchor HtmlNode anchorNode = HtmlNode.CreateNode("<a>"); Link.SetStyle(anchorNode); anchorNode.AppendChild(img); td.AppendChild(anchorNode); return(anchorNode); } else { td.AppendChild(img); return(img); } }
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); }