Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }