Exemplo n.º 1
0
        public override void GenerateBody()
        {
            base.GenerateBody();
            var titlePage = new Div(Compatibility);

            titlePage.GlobalAttributes.Class.Value = ElementStylesV2.TitlePage;
            if (!string.IsNullOrEmpty(BookTitle))
            {
                // try to use FB2 book's title
                var p = new H2(Compatibility);
                p.Add(new SimpleHTML5Text(Compatibility)
                {
                    Text = BookTitle
                });
                p.GlobalAttributes.Class.Value = string.Format(ElementStylesV2.TitleItemFormat, 1);
                titlePage.Add(p);
            }
            else
            {
                titlePage.Add(new SimpleHTML5Text(Compatibility)
                {
                    Text = "Unnamed"
                });
            }

            titlePage.Add(new EmptyLine(Compatibility));

            var sbSeries = new StringBuilder();

            foreach (var serie in _series)
            {
                if (!string.IsNullOrEmpty(sbSeries.ToString()))
                {
                    sbSeries.Append(" , ");
                }
                sbSeries.Append(serie);
            }
            if (sbSeries.ToString() != string.Empty)
            {
                var seriesItem = new SimpleHTML5Text(Compatibility)
                {
                    Text = string.Format("( {0} )", sbSeries)
                };
                var containingText = new EmphasisedText(Compatibility);
                containingText.Add(seriesItem);
                var seriesHeading = new H3(Compatibility);
                seriesHeading.GlobalAttributes.Class.Value = ElementStylesV2.TitleSeries;
                seriesHeading.Add(containingText);
                titlePage.Add(seriesHeading);
            }

            foreach (var author in _authors)
            {
                var authorsHeading = new H3(Compatibility);
                var authorLine     = new SimpleHTML5Text(Compatibility)
                {
                    Text = author
                };
                authorsHeading.Add(authorLine);
                authorsHeading.GlobalAttributes.Class.Value = ElementStylesV2.TitleAuthors;
                titlePage.Add(authorsHeading);
            }


            BodyElement.Add(titlePage);
        }