コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        internal static NParagraph GetTitleParagraphNoBorder(string text, int level)
        {
            double      fontSize  = 10;
            ENFontStyle fontStyle = ENFontStyle.Regular;

            switch (level)
            {
            case 1:
                fontSize  = 16;
                fontStyle = ENFontStyle.Bold;
                break;

            case 2:
                fontSize  = 10;
                fontStyle = ENFontStyle.Bold;
                break;
            }

            NParagraph paragraph = new NParagraph();

            paragraph.HorizontalAlignment = ENAlign.Left;
            paragraph.FontSize            = fontSize;
            paragraph.FontStyle           = fontStyle;

            NTextInline textInline = new NTextInline(text);

            textInline.FontStyle = fontStyle;
            textInline.FontSize  = fontSize;

            paragraph.Inlines.Add(textInline);

            return(paragraph);
        }
コード例 #2
0
            public override NDocumentBlock CreateDocument()
            {
                NDocumentBlock document = base.CreateDocument();

                NSection section = document.Sections[0];

                section.Blocks.Add(new NParagraph("This is the first paragraph."));
                section.Blocks.Add(new NParagraph("This is the second paragraph.\nThis is part of the second paragraph, too."));

                NGroupBlock div = new NGroupBlock();

                section.Blocks.Add(div);
                div.Fill = new NColorFill(NColor.Red);
                NParagraph p = new NParagraph("This is a paragraph in a div. It should have red underlined text.");

                div.Blocks.Add(p);
                p.FontStyle = ENFontStyle.Underline;

                p = new NParagraph("This is another paragraph in the div. It contains a ");
                div.Blocks.Add(p);
                NTextInline inline = new NTextInline("bold italic blue inline");

                p.Inlines.Add(inline);
                inline.Fill      = new NColorFill(NColor.Blue);
                inline.FontStyle = ENFontStyle.Bold | ENFontStyle.Italic;

                p.Inlines.Add(new NTextInline("."));

                return(document);
            }
コード例 #3
0
        protected override void PopulateRichText()
        {
            NDocumentBlock documentBlock = m_RichText.Content;
            NSection       section       = new NSection();

            documentBlock.Sections.Add(section);

            NParagraph paragraph = new NParagraph();

            section.Blocks.Add(paragraph);

            // Create the first inline
            NTextInline inline1 = new NTextInline("This is the first inline. ");

            paragraph.Inlines.Add(inline1);

            // Create and apply an inline style
            NInlineStyle style1 = new NInlineStyle("MyRedStyle");

            style1.Rule           = new NInlineRule(NColor.Red);
            style1.Rule.FontStyle = ENFontStyle.Bold;
            style1.Apply(inline1);

            // Create the second inline
            NTextInline inline2 = new NTextInline("This is the second inline.");

            paragraph.Inlines.Add(inline2);

            // Create and apply an inline style
            NInlineStyle style2 = new NInlineStyle("MyBlueStyle");

            style2.Rule           = new NInlineRule(NColor.Blue);
            style2.Rule.FontStyle = ENFontStyle.Italic;
            style2.Apply(inline2);
        }
コード例 #4
0
        /// <summary>
        /// Gets a paragraph with an explicit page break
        /// </summary>
        /// <param name="alignment"></param>
        /// <returns></returns>
        private static NParagraph GetParagraphWithPageBreak()
        {
            string     text      = string.Empty;
            NParagraph paragraph = new NParagraph();

            for (int i = 0; i < 5; i++)
            {
                if (text.Length > 0)
                {
                    text += " ";
                }

                text += "This is a paragraph with explicit page break.";
            }

            paragraph.Inlines.Add(new NTextInline(text));

            NTextInline inline = new NTextInline("Page break appears here!");

            inline.FontStyle |= ENFontStyle.Bold;
            paragraph.Inlines.Add(inline);

            paragraph.Inlines.Add(new NPageBreakInline());
            paragraph.Inlines.Add(new NTextInline(text));

            return(paragraph);
        }
コード例 #5
0
        internal static NTextInline CreateNormalText(string text)
        {
            NTextInline inline = new NTextInline(text);

            inline.FontSize = 9;

            return(inline);
        }
コード例 #6
0
        internal static NTextInline CreateHeaderText(string text)
        {
            NTextInline inline = new NTextInline(text);

            inline.FontSize  = 14;
            inline.FontStyle = ENFontStyle.Bold;

            return(inline);
        }
コード例 #7
0
        /// <summary>
        /// Creates a section title paragraph
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private NParagraph CreateSecondaryTitleParagraph(string text)
        {
            NParagraph paragraph = new NParagraph();

            NTextInline textInline = new NTextInline();

            textInline.FontSize = 12;
            textInline.Fill     = new NColorFill(NColor.FromRGB(89, 76, 46));
            paragraph.Inlines.Add(textInline);

            return(paragraph);
        }
コード例 #8
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Block Appearance", "Every block in the document follows the HTML block formatting model which allows you to specify filling and border. The following paragraph has gradient background filling and solid border.", 1));

            NParagraph paragraph = new NParagraph();

            NTextInline textInline = new NTextInline("Paragraph with solid border and gradient filling applied on the background.");

            textInline.Fill     = new NColorFill(NColor.Aquamarine);
            textInline.FontSize = 24;
            paragraph.Inlines.Add(textInline);

            paragraph.BackgroundFill  = new NStockGradientFill(ENGradientStyle.FromCorner, ENGradientVariant.Variant1, NColor.Gainsboro, NColor.SlateGray);
            paragraph.Border          = NBorder.CreateFilledBorder(NColor.DarkBlue);
            paragraph.BorderThickness = new NMargins(3);

            paragraph.PreferredWidth = new NMultiLength(ENMultiLengthUnit.Dip, 500);

            section.Blocks.Add(paragraph);
        }
コード例 #9
0
        /// <summary>
        /// Adds rich formatted text to the specified text block content
        /// </summary>
        /// <param name="content"></param>
        private void AddFormattedTextToContent(NTextBlockContent content)
        {
            // paragraphs with different horizontal alignment

            NParagraph paragraph;

            for (int i = 0; i < 4; i++)
            {
                paragraph = new NParagraph();

                switch (i)
                {
                case 0:
                    paragraph.HorizontalAlignment = ENAlign.Left;
                    paragraph.Inlines.Add(new NTextInline(GetAlignedParagraphText("left")));
                    break;

                case 1:
                    paragraph.HorizontalAlignment = ENAlign.Center;
                    paragraph.Inlines.Add(new NTextInline(GetAlignedParagraphText("center")));
                    break;

                case 2:
                    paragraph.HorizontalAlignment = ENAlign.Right;
                    paragraph.Inlines.Add(new NTextInline(GetAlignedParagraphText("right")));
                    break;

                case 3:
                    paragraph.HorizontalAlignment = ENAlign.Justify;
                    paragraph.Inlines.Add(new NTextInline(GetAlignedParagraphText("justify")));
                    break;
                }

                content.Blocks.Add(paragraph);
            }

            {
                // borders
                paragraph = new NParagraph();
                paragraph.BorderThickness = new NMargins(2, 2, 2, 2);
                paragraph.Border          = NBorder.CreateFilledBorder(NColor.Red);
                paragraph.PreferredWidth  = NMultiLength.NewPercentage(50);
                paragraph.Margins         = new NMargins(5, 5, 5, 5);
                paragraph.Padding         = new NMargins(5, 5, 5, 5);
                paragraph.PreferredWidth  = NMultiLength.NewFixed(300);
                paragraph.PreferredHeight = NMultiLength.NewFixed(100);
                NTextInline textInline1 = new NTextInline("Paragraphs can have border, margins and padding as well as preffered size");
                paragraph.Inlines.Add(textInline1);

                content.Blocks.Add(paragraph);
            }

            // First line indent and hanging indent
            content.Blocks.Add(GetTitleParagraph("Paragraph with First Line Indent and Hanging Indent", 2));

            NParagraph paragraphWithIndents = new NParagraph(GetRepeatingText("First line indent -10dip, hanging indent 15dip.", 5));

            paragraphWithIndents.HorizontalAlignment = ENAlign.Left;
            paragraphWithIndents.FirstLineIndent     = -10;
            paragraphWithIndents.HangingIndent       = 15;
            content.Blocks.Add(paragraphWithIndents);

            // First line indent and hanging indent
            content.Blocks.Add(GetTitleParagraph("Line Spacing", 2));

            NParagraph paragraphWithMultipleLineSpacing = new NParagraph(GetRepeatingText("Line space is two times bigger than normal", 10));

            paragraphWithMultipleLineSpacing.HorizontalAlignment = ENAlign.Left;
            paragraphWithMultipleLineSpacing.LineHeightMode      = ENLineHeightMode.Multiple;
            paragraphWithMultipleLineSpacing.LineHeightFactor    = 2.0;
            content.Blocks.Add(paragraphWithMultipleLineSpacing);

            NParagraph paragraphWithAtLeastLineSpacing = new NParagraph(GetRepeatingText("Line space is at least 20 dips.", 10));

            paragraphWithAtLeastLineSpacing.HorizontalAlignment = ENAlign.Left;
            paragraphWithAtLeastLineSpacing.LineHeightMode      = ENLineHeightMode.AtLeast;
            paragraphWithAtLeastLineSpacing.LineHeight          = 20.0;
            content.Blocks.Add(paragraphWithAtLeastLineSpacing);

            NParagraph paragraphWithExactLineSpacing = new NParagraph(GetRepeatingText("Line space is exactly 20 dips.", 10));

            paragraphWithExactLineSpacing.HorizontalAlignment = ENAlign.Left;
            paragraphWithExactLineSpacing.LineHeightMode      = ENLineHeightMode.Exactly;
            paragraphWithExactLineSpacing.LineHeight          = 20.0;
            content.Blocks.Add(paragraphWithExactLineSpacing);

            // BIDI formatting
            content.Blocks.Add(GetTitleParagraph("Paragraphs with BIDI text", 2));

            paragraph = new NParagraph();
            paragraph.HorizontalAlignment = ENAlign.Left;
            NTextInline latinText1 = new NTextInline("This is some text in English. Followed by Arabic:");
            NTextInline arabicText = new NTextInline("أساسًا، تتعامل الحواسيب فقط مع الأرقام، وتقوم بتخزين الأحرف والمحارف الأخرى بعد أن تُعطي رقما معينا لكل واحد منها. وقبل اختراع ");
            NTextInline latinText2 = new NTextInline("This is some text in English.");


            paragraph.Inlines.Add(latinText1);
            paragraph.Inlines.Add(arabicText);
            paragraph.Inlines.Add(latinText2);

            content.Blocks.Add(paragraph);
        }
コード例 #10
0
        /// <summary>
        /// Adds rich formatted text to the specified text block content
        /// </summary>
        /// <param name="content"></param>
        private void AddFormattedTextToContent(NTextBlockContent content)
        {
            {
                // font style control
                NParagraph paragraph = new NParagraph();

                NTextInline textInline1 = new NTextInline("This paragraph contains text inlines with altered ");
                paragraph.Inlines.Add(textInline1);

                NTextInline textInline2 = new NTextInline("Font Name, ");
                textInline2.FontName = "Tahoma";
                paragraph.Inlines.Add(textInline2);

                NTextInline textInline3 = new NTextInline("Font Size, ");
                textInline3.FontSize = 14;
                paragraph.Inlines.Add(textInline3);

                NTextInline textInline4 = new NTextInline("Font Style (Bold), ");
                textInline4.FontStyle |= ENFontStyle.Bold;
                paragraph.Inlines.Add(textInline4);

                NTextInline textInline5 = new NTextInline("Font Style (Italic), ");
                textInline5.FontStyle |= ENFontStyle.Italic;
                paragraph.Inlines.Add(textInline5);

                NTextInline textInline6 = new NTextInline("Font Style (Underline), ");
                textInline6.FontStyle |= ENFontStyle.Underline;
                paragraph.Inlines.Add(textInline6);

                NTextInline textInline7 = new NTextInline("Font Style (StrikeTrough) ");
                textInline7.FontStyle |= ENFontStyle.Strikethrough;
                paragraph.Inlines.Add(textInline7);

                NTextInline textInline8 = new NTextInline("and Font Style All.");
                textInline8.FontStyle = ENFontStyle.Bold | ENFontStyle.Italic | ENFontStyle.Underline | ENFontStyle.Strikethrough;
                paragraph.Inlines.Add(textInline8);

                content.Blocks.Add(paragraph);
            }

            {
                // appearance control
                NParagraph paragraph = new NParagraph();

                NTextInline textInline1 = new NTextInline("Each text inline element can contain text with differeant fill and background. ");
                paragraph.Inlines.Add(textInline1);

                NTextInline textInline2 = new NTextInline("Fill (Red), Background Fill Inherit. ");
                textInline2.Fill = new NColorFill(ENNamedColor.Red);
                paragraph.Inlines.Add(textInline2);

                NTextInline textInline3 = new NTextInline("Fill inherit, Background Fill (Green).");
                textInline3.BackgroundFill = new NColorFill(ENNamedColor.Green);
                paragraph.Inlines.Add(textInline3);

                content.Blocks.Add(paragraph);
            }

            {
                // line breaks
                // appearance control
                NParagraph paragraph = new NParagraph();

                NTextInline textInline1 = new NTextInline("Line breaks allow you to break...");
                paragraph.Inlines.Add(textInline1);

                NLineBreakInline lineBreak = new NLineBreakInline();
                paragraph.Inlines.Add(lineBreak);

                NTextInline textInline2 = new NTextInline("the current line in the paragraph.");
                paragraph.Inlines.Add(textInline2);

                content.Blocks.Add(paragraph);
            }

            {
                // tabs
                NParagraph paragraph = new NParagraph();

                NTabInline tabInline = new NTabInline();
                paragraph.Inlines.Add(tabInline);

                NTextInline textInline1 = new NTextInline("(Tabs) are not supported by HTML, however they are essential when importing text documents.");
                paragraph.Inlines.Add(textInline1);

                content.Blocks.Add(paragraph);
            }
        }
コード例 #11
0
        /// <summary>
        ///
        /// </summary>
        protected override void PopulateRichText()
        {
            NSection mainSection = new NSection();

            mainSection.Blocks.Add(GetDescriptionBlock("Section Columns", "This example shows how to create sections with multiple columns and different break types", 1));
            m_RichText.Content.Sections.Add(mainSection);
            m_RichText.Content.Layout = ENTextLayout.Print;

            for (int sectionIndex = 0; sectionIndex < 6; sectionIndex++)
            {
                NSection section = new NSection();

                section.Margins = NMargins.Zero;
                section.Padding = NMargins.Zero;

                string sectionText = string.Empty;
                NColor color       = NColor.White;

                switch (sectionIndex)
                {
                case 0:
                    sectionText         = "Red Section (single column, continuous break)";
                    section.ColumnCount = 1;
                    color = NColor.Red;
                    break;

                case 1:
                    sectionText         = "Green Section (two columns, continuous break)";
                    section.ColumnCount = 2;
                    color = NColor.Green;
                    break;

                case 2:
                    sectionText         = "Blue Section (three columns, continuous break)";
                    section.ColumnCount = 3;
                    color = NColor.Blue;
                    break;

                case 3:
                    sectionText         = "Tomato Section (three column, even page break)";
                    section.ColumnCount = 3;
                    section.BreakType   = ENSectionBreakType.EvenPage;
                    color = NColor.Tomato;
                    break;

                case 4:
                    sectionText         = "DarkSlateBlue Section (three columns, column break)";
                    section.ColumnCount = 3;
                    section.BreakType   = ENSectionBreakType.ColumnBreak;
                    color = NColor.DarkSlateBlue;
                    break;

                case 5:
                    sectionText         = "RoyalBlue Section (three columns, next page break)";
                    section.ColumnCount = 3;
                    section.BreakType   = ENSectionBreakType.NextPage;
                    color = NColor.RoyalBlue;
                    break;
                }

                m_RichText.Content.Sections.Add(section);

                section.DifferentFirstHeaderAndFooter       = false;
                section.DifferentLeftRightHeadersAndFooters = false;

                section.Header = CreateHeaderFooter(sectionText);
                section.Footer = CreateHeaderFooter(sectionText);

                // paragraphs with some simple text
                for (int i = 0; i < 10; i++)
                {
                    NParagraph paragraph = new NParagraph();

                    NTextInline textInline = new NTextInline(GetRepeatingText(sectionText + ".", 5));
                    textInline.Fill = new NColorFill(color);
                    paragraph.Inlines.Add(textInline);

                    section.Blocks.Add(paragraph);
                }
            }
        }
コード例 #12
0
        protected override void PopulateRichText()
        {
            m_RichText.Content.Layout = ENTextLayout.Print;

            for (int sectionIndex = 0; sectionIndex < 3; sectionIndex++)
            {
                NSection section = new NSection();

                NColor color       = NColor.Empty;
                string sectionText = string.Empty;

                switch (sectionIndex)
                {
                case 0:
                {
                    sectionText = "Red Section (uniform header and footer).";
                    color       = NColor.Red;

                    section.Blocks.Add(GetDescriptionBlock("Section Headers and Footers", "This example shows how to create sections with different header and footer settings.", 1));

                    section.DifferentFirstHeaderAndFooter       = false;
                    section.DifferentLeftRightHeadersAndFooters = false;

                    NHeaderFooter header = CreateHeaderFooter("Uniform Header.");
                    header.BackgroundFill = new NColorFill(color);
                    section.Header        = header;

                    NHeaderFooter footer = CreateHeaderFooter("Uniform Footer.");
                    footer.BackgroundFill = new NColorFill(color);
                    section.Footer        = footer;
                }
                break;

                case 1:
                {
                    sectionText = "Green Section (different first header and footer).";
                    color       = NColor.Green;

                    section.BreakType = ENSectionBreakType.NextPage;
                    section.DifferentFirstHeaderAndFooter       = true;
                    section.DifferentLeftRightHeadersAndFooters = false;

                    NHeaderFooter headerFirst = CreateHeaderFooter("First Page Header.");
                    headerFirst.BackgroundFill = new NColorFill(color);
                    section.HeaderFirst        = headerFirst;

                    NHeaderFooter footerFirst = CreateHeaderFooter("First Page Footer.");
                    footerFirst.BackgroundFill = new NColorFill(color);
                    section.FooterFirst        = footerFirst;
                }
                break;

                case 2:
                {
                    sectionText = "Blue Section (different left and right page header and footer).";
                    color       = NColor.Blue;

                    section.BreakType = ENSectionBreakType.NextPage;
                    section.DifferentFirstHeaderAndFooter       = false;
                    section.DifferentLeftRightHeadersAndFooters = true;

                    NHeaderFooter headerLeft = CreateHeaderFooter("Left Page Header.");
                    headerLeft.BackgroundFill = new NColorFill(color);
                    section.HeaderLeft        = headerLeft;

                    NHeaderFooter headerRight = CreateHeaderFooter("Right Page Header.");
                    headerRight.BackgroundFill = new NColorFill(color);
                    section.HeaderRight        = headerRight;

                    NHeaderFooter footerLeft = CreateHeaderFooter("Left Page Footer.");
                    footerLeft.BackgroundFill = new NColorFill(color);
                    section.FooterLeft        = footerLeft;

                    NHeaderFooter footerRight = CreateHeaderFooter("Right Page Footer.");
                    footerRight.BackgroundFill = new NColorFill(color);
                    section.FooterRight        = footerRight;
                }
                break;
                }

                m_RichText.Content.Sections.Add(section);

                // add some section contentparagraphs with some simple text
                for (int i = 0; i < 20; i++)
                {
                    NParagraph paragraph = new NParagraph();

                    NTextInline textInline = new NTextInline(GetRepeatingText(sectionText, 5));
                    textInline.Fill = new NColorFill(color);
                    paragraph.Inlines.Add(textInline);

                    section.Blocks.Add(paragraph);
                }
            }
        }
コード例 #13
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Inline Formatting", "The example shows how to add inlines with different formatting to a paragraph.", 1));

            {
                // font style control
                NParagraph paragraph = new NParagraph();

                NTextInline textInline1 = new NTextInline("This paragraph contains text inlines with altered ");
                paragraph.Inlines.Add(textInline1);

                NTextInline textInline2 = new NTextInline("Font Name, ");
                textInline2.FontName = "Tahoma";
                paragraph.Inlines.Add(textInline2);

                NTextInline textInline3 = new NTextInline("Font Size, ");
                textInline3.FontSize = 14;
                paragraph.Inlines.Add(textInline3);

                NTextInline textInline4 = new NTextInline("Font Style (Bold), ");
                textInline4.FontStyle |= ENFontStyle.Bold;
                paragraph.Inlines.Add(textInline4);

                NTextInline textInline5 = new NTextInline("Font Style (Italic), ");
                textInline5.FontStyle |= ENFontStyle.Italic;
                paragraph.Inlines.Add(textInline5);

                NTextInline textInline6 = new NTextInline("Font Style (Underline), ");
                textInline6.FontStyle |= ENFontStyle.Underline;
                paragraph.Inlines.Add(textInline6);

                NTextInline textInline7 = new NTextInline("Font Style (StrikeTrough) ");
                textInline7.FontStyle |= ENFontStyle.Strikethrough;
                paragraph.Inlines.Add(textInline7);

                NTextInline textInline8 = new NTextInline("and Font Style All.");
                textInline8.FontStyle = ENFontStyle.Bold | ENFontStyle.Italic | ENFontStyle.Underline | ENFontStyle.Strikethrough;
                paragraph.Inlines.Add(textInline8);

                section.Blocks.Add(paragraph);
            }

            {
                // appearance control
                NParagraph paragraph = new NParagraph();

                NTextInline textInline1 = new NTextInline("Each text inline element can contain text with differeant fill and background. ");
                paragraph.Inlines.Add(textInline1);

                NTextInline textInline2 = new NTextInline("Fill (Red), Background Fill Inherit. ");
                textInline2.Fill = new NColorFill(ENNamedColor.Red);
                paragraph.Inlines.Add(textInline2);

                NTextInline textInline3 = new NTextInline("Fill inherit, Background Fill (Green).");
                textInline3.BackgroundFill = new NColorFill(ENNamedColor.Green);
                paragraph.Inlines.Add(textInline3);

                section.Blocks.Add(paragraph);
            }

            {
                // line breaks
                // appearance control
                NParagraph paragraph = new NParagraph();

                NTextInline textInline1 = new NTextInline("Line breaks allow you to break...");
                paragraph.Inlines.Add(textInline1);

                NLineBreakInline lineBreak = new NLineBreakInline();
                paragraph.Inlines.Add(lineBreak);

                NTextInline textInline2 = new NTextInline("the current line in the paragraph.");
                paragraph.Inlines.Add(textInline2);

                section.Blocks.Add(paragraph);
            }

            {
                // tabs
                NParagraph paragraph = new NParagraph();

                NTabInline tabInline = new NTabInline();
                paragraph.Inlines.Add(tabInline);

                NTextInline textInline1 = new NTextInline("(Tabs) are not supported by HTML, however they are essential when importing text documents.");
                paragraph.Inlines.Add(textInline1);

                section.Blocks.Add(paragraph);
            }
        }