/// <summary>
        /// Adds rich formatted text to the specified text block content
        /// </summary>
        /// <param name="content"></param>
        private void AddFormattedTextToContent(NTextBlockContent content)
        {
            content.Blocks.Add(GetTitleParagraph("Bullet lists allow you to apply automatic numbering on paragraphs or groups of blocks.", 1));

            // setting bullet list template type
            {
                content.Blocks.Add(GetTitleParagraph("Following are bullet lists with different formatting", 2));

                ENBulletListTemplateType[] values = NEnum.GetValues <ENBulletListTemplateType>();
                string[] names = NEnum.GetNames <ENBulletListTemplateType>();

                string itemText = "Bullet List Item";

                for (int i = 0; i < values.Length - 1; i++)
                {
                    NGroupBlock group = new NGroupBlock();
                    content.Blocks.Add(group);
                    group.MarginTop    = 10;
                    group.MarginBottom = 10;

                    NBulletList bulletList = new NBulletList(values[i]);
                    content.BulletLists.Add(bulletList);

                    for (int j = 0; j < 3; j++)
                    {
                        NParagraph    paragraph = new NParagraph(itemText + j.ToString());
                        NBulletInline bullet    = new NBulletInline();
                        bullet.List      = bulletList;
                        paragraph.Bullet = bullet;

                        group.Blocks.Add(paragraph);
                    }
                }
            }

            // nested bullet lists
            {
                content.Blocks.Add(GetTitleParagraph("Following is an example of bullets with different bullet level", 2));

                NBulletList bulletList = new NBulletList(ENBulletListTemplateType.Decimal);
                content.BulletLists.Add(bulletList);

                NGroupBlock group = new NGroupBlock();
                content.Blocks.Add(group);

                for (int i = 0; i < 3; i++)
                {
                    NParagraph par = new NParagraph("Bullet List Item" + i.ToString(), bulletList, 0);
                    group.Blocks.Add(par);

                    for (int j = 0; j < 2; j++)
                    {
                        NParagraph nestedPar = new NParagraph("Nested Bullet List Item" + i.ToString(), bulletList, 1);
                        nestedPar.MarginLeft = 10;

                        group.Blocks.Add(nestedPar);
                    }
                }
            }
        }
Exemple #2
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);
        }
        /// <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);
            }
        }
        /// <summary>
        /// Adds formatted text with image elements to the specified text block content
        /// </summary>
        /// <param name="content"></param>
        private void AddFormattedTextWithImagesToContent(NTextBlockContent content)
        {
            // adding a raster image with automatic size
            {
                NParagraph paragraph = new NParagraph();

                paragraph.Inlines.Add(new NTextInline("Raster image in its original size (125x100):"));
                paragraph.Inlines.Add(new NLineBreakInline());

                NImageInline imageInline = new NImageInline();
                imageInline.Image = NResources.Image_Artistic_FishBowl_jpg;
                paragraph.Inlines.Add(imageInline);

                content.Blocks.Add(paragraph);
            }


            // adding a raster image with specified preferred width and height
            {
                NParagraph paragraph = new NParagraph();

                paragraph.Inlines.Add(new NTextInline("Raster image with preferred width and height (80x60):"));
                paragraph.Inlines.Add(new NLineBreakInline());

                NImageInline imageInline = new NImageInline();

                imageInline.Image           = NResources.Image_Artistic_FishBowl_jpg;
                imageInline.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Dip, 80);
                imageInline.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 60);

                paragraph.Inlines.Add(imageInline);

                content.Blocks.Add(paragraph);
            }

            // adding a metafile image with preferred width and height
            {
                NParagraph paragraph = new NParagraph();

                paragraph.Inlines.Add(new NTextInline("Metafile image with preferred width and height (125x100):"));
                paragraph.Inlines.Add(new NLineBreakInline());

                NImageInline imageInline = new NImageInline();
                imageInline.Image           = NResources.Image_FishBowl_wmf;
                imageInline.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Dip, 125);
                imageInline.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 100);

                paragraph.Inlines.Add(imageInline);

                content.Blocks.Add(paragraph);
            }


            // adding a metafile image with preferred width and height
            {
                NParagraph paragraph = new NParagraph();

                paragraph.Inlines.Add(new NTextInline("Metafile image with preferred width and height (80x60):"));
                paragraph.Inlines.Add(new NLineBreakInline());

                NImageInline imageInline = new NImageInline();
                imageInline.Image           = NResources.Image_FishBowl_wmf;
                imageInline.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Dip, 80);
                imageInline.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 60);

                paragraph.Inlines.Add(imageInline);

                content.Blocks.Add(paragraph);
            }
        }