コード例 #1
0
ファイル: TitlePageFileV3.cs プロジェクト: npuBug/epublibrary
        public override void GenerateBody()
        {
            base.GenerateBody();
            BodyElement.CustomAttributes.Add(new CustomAttribute(EPubNamespaces.OpsNamespace + "type", TitleTypeAttributeValue));

            var titlePage = new Div(Compatibility);
            titlePage.GlobalAttributes.Class.Value = "titlepage";
            if (!string.IsNullOrEmpty(BookTitle))
            {
                // try to use FB2 book's title
                var p = new H2(Compatibility);
                p.Add(new SimpleHTML5Text(Compatibility) { Text = BookTitle });
                string itemClass = string.Format("title{0}", 1);
                p.GlobalAttributes.Class.Value = itemClass;
                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 = "title_series";
                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 = "title_authors";
                titlePage.Add(authorsHeading);
            }


            BodyElement.Add(titlePage);
        }
コード例 #2
0
        public override void GenerateBody()
        {
            base.GenerateBody();

            var titlePage = new Div(Compatibility);
            titlePage.GlobalAttributes.Class.Value = ElementStylesV3.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(ElementStylesV3.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 = ElementStylesV3.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 = ElementStylesV3.TitleAuthors;
                titlePage.Add(authorsHeading);
            }

            BodyElement.Add(titlePage);
        }
コード例 #3
0
        /// <summary>
        /// Creates block element based on paragraph type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private static HTMLItem CreateBlock(ParagraphConvTargetEnumV3 type)
        {
            HTMLItem paragraph;
            switch (type)
            {
                case ParagraphConvTargetEnumV3.H1:
                    paragraph = new H1(HTMLElementType.HTML5);
                    break;
                case ParagraphConvTargetEnumV3.H2:
                    paragraph = new H2(HTMLElementType.HTML5);
                    break;
                case ParagraphConvTargetEnumV3.H3:
                    paragraph = new H3(HTMLElementType.HTML5);
                    break;
                case ParagraphConvTargetEnumV3.H4:
                    paragraph = new H4(HTMLElementType.HTML5);
                    break;
                case ParagraphConvTargetEnumV3.H5:
                    paragraph = new H5(HTMLElementType.HTML5);
                    break;
                case ParagraphConvTargetEnumV3.H6:
                    paragraph = new H6(HTMLElementType.HTML5);
                    break;
                default: // Paragraph or anything else
                    paragraph = new Paragraph(HTMLElementType.HTML5);
                    break;

            }
            return paragraph;
        }