コード例 #1
0
        public void SaveTravel(string filePath, Travel travel)
        {
            var table = new TableTag().Caption(travel.Name);

            table.Attr("table border", 1)
            .Attr("cellpadding", 20)
            .Attr("bgcolor", "fafeff")
            .Attr("bordercolor", "white");
            foreach (var travelEvent in travel.Events)
            {
                table.AddBodyRow(b =>
                {
                    b.Cell(travelEvent.Type);
                    b.Cell(travelEvent.GetLocationsStrings()[0]);
                    b.Cell(travelEvent.GetLocationsStrings()[1]);
                    b.Cell(travelEvent.GetDatesStrings()[0]);
                    b.Cell(travelEvent.GetDatesStrings()[0]);
                    b.Cell(travelEvent.Cost.ToStringValue());
                });
            }
            using (var writer = new StreamWriter(filePath, false, Encoding.UTF8))
            {
                writer.Write(table.ToHtmlString());
            }
        }
コード例 #2
0
        public static string WrapInNestedCenteringTable(string htmlString)
        {
            // ReSharper disable StringLiteralTypo
            var emailCenterTable = new TableTag();

            emailCenterTable.Attr("width", "100%");
            emailCenterTable.Attr("border", "0");
            emailCenterTable.Attr("cellspacing", "0");
            emailCenterTable.Attr("cellpadding", "0");
            var emailCenterRow = emailCenterTable.AddBodyRow();

            var emailCenterLeftCell = emailCenterRow.Cell();

            emailCenterLeftCell.Attr("max-width", "1%");
            emailCenterLeftCell.Attr("align", "center");
            emailCenterLeftCell.Attr("valign", "top");
            emailCenterLeftCell.Text(" ").Encoded(false);

            var emailCenterContentCell = emailCenterRow.Cell();

            emailCenterContentCell.Attr("width", "100%");
            emailCenterContentCell.Attr("align", "center");
            emailCenterContentCell.Attr("valign", "top");

            var emailCenterRightCell = emailCenterRow.Cell();

            emailCenterRightCell.Attr("max-width", "1%");
            emailCenterRightCell.Attr("align", "center");
            emailCenterRightCell.Attr("valign", "top");
            emailCenterRightCell.Text(" ").Encoded(false);
            // ReSharper restore StringLiteralTypo

            var outerTable = new TableTag();

            emailCenterContentCell.Children.Add(outerTable);
            outerTable.Style("width", "100%");
            outerTable.Style("max-width", "900px");

            outerTable.TBody.Text(htmlString).Encoded(false);

            return(emailCenterTable.ToString());
        }
コード例 #3
0
        public static HtmlTag WriteBehaviorChainTable(IEnumerable <BehaviorChain> chains, params IColumn[] columns)
        {
            var table = new TableTag();

            table.Attr("cellspacing", "0");
            table.Attr("cellpadding", "0");
            table.AddHeaderRow(row =>
            {
                columns.Each(c => row.Header(c.Header()));
            });

            chains.Each(chain =>
            {
                table.AddBodyRow(row =>
                {
                    columns.Each(col =>
                    {
                        col.WriteBody(chain, row, row.Cell());
                    });
                });
            });

            return(table);
        }
コード例 #4
0
        private HtmlTag EmailPhotoTableTag(PhotoContent dbEntry)
        {
            var emailCenterTable = new TableTag();

            emailCenterTable.Attr("width", "94%");
            emailCenterTable.Attr("margin", "20");
            emailCenterTable.Attr("border", "0");
            emailCenterTable.Attr("cellspacing", "0");
            emailCenterTable.Attr("cellpadding", "0");

            var topMarginRow = emailCenterTable.AddBodyRow();

            topMarginRow.Attr("height", "10");
            var topMarginCell = topMarginRow.Cell();

            topMarginCell.Text("&nbsp;").Encoded(false);

            var emailImageRow = emailCenterTable.AddBodyRow();

            var emailImageCenterLeftCell = emailImageRow.Cell();

            emailImageCenterLeftCell.Attr("max-width", "1%");
            emailImageCenterLeftCell.Attr("align", "center");
            emailImageCenterLeftCell.Attr("valign", "top");
            emailImageCenterLeftCell.Text("&nbsp;").Encoded(false);

            var emailCenterContentCell = emailImageRow.Cell();

            emailCenterContentCell.Attr("width", "100%");
            emailCenterContentCell.Attr("align", "center");
            emailCenterContentCell.Attr("valign", "top");

            emailCenterContentCell.Children.Add(Tags.PictureEmailImgTag(Pictures, true));

            var emailCenterRightCell = emailImageRow.Cell();

            emailCenterRightCell.Attr("max-width", "1%");
            emailCenterRightCell.Attr("align", "center");
            emailCenterRightCell.Attr("valign", "top");
            emailCenterRightCell.Text("&nbsp;").Encoded(false);

            var captionImageRow = emailCenterTable.AddBodyRow();

            var captionImageCenterLeftCell = captionImageRow.Cell();

            captionImageCenterLeftCell.Attr("max-width", "1%");
            captionImageCenterLeftCell.Attr("align", "center");
            captionImageCenterLeftCell.Attr("valign", "top");
            captionImageCenterLeftCell.Text("&nbsp;").Encoded(false);

            var captionCenterContentCell = captionImageRow.Cell();

            captionCenterContentCell.Attr("width", "100%");
            captionCenterContentCell.Attr("align", "center");
            captionCenterContentCell.Attr("valign", "top");

            captionCenterContentCell.Text(Tags.PhotoCaptionText(dbEntry));

            var captionCenterRightCell = captionImageRow.Cell();

            captionCenterRightCell.Attr("max-width", "1%");
            captionCenterRightCell.Attr("align", "center");
            captionCenterRightCell.Attr("valign", "top");
            captionCenterRightCell.Text("&nbsp;").Encoded(false);

            var bottomMarginRow = emailCenterTable.AddBodyRow();

            bottomMarginRow.Attr("height", "10");
            var bottomMarginCell = bottomMarginRow.Cell();

            bottomMarginCell.Text("&nbsp;").Encoded(false);

            return(emailCenterTable);
        }