示例#1
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);
            }
示例#2
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            // paragraphs with different horizontal alignment
            section.Blocks.Add(GetDescriptionBlock("Paragraphs can contain tab stops", "This example shows how to programmatically add tab stops to paragraphs", 2));

            NParagraph paragraph = new NParagraph();

            paragraph.Inlines.Add(new NTabInline());
            paragraph.Inlines.Add(new NTextInline("Left."));
            paragraph.Inlines.Add(new NTabInline());
            paragraph.Inlines.Add(new NTextInline("Right."));
            paragraph.Inlines.Add(new NTabInline());
            paragraph.Inlines.Add(new NTextInline("Center."));
            paragraph.Inlines.Add(new NTabInline());
            paragraph.Inlines.Add(new NTextInline("Decimal 345.33"));

            NTabStopCollection tabStops = new NTabStopCollection();

            tabStops.Add(new Nevron.Nov.Text.NTabStop(100, ENTabStopAlignment.Left, ENTabStopLeaderStyle.Dots));
            tabStops.Add(new Nevron.Nov.Text.NTabStop(200, ENTabStopAlignment.Right, ENTabStopLeaderStyle.EqualSigns));
            tabStops.Add(new Nevron.Nov.Text.NTabStop(300, ENTabStopAlignment.Center, ENTabStopLeaderStyle.Hyphens));
            tabStops.Add(new Nevron.Nov.Text.NTabStop(500, ENTabStopAlignment.Decimal, ENTabStopLeaderStyle.Underline));

            paragraph.TabStops           = tabStops;
            paragraph.WidowOrphanControl = false;

            section.Blocks.Add(paragraph);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Block Size", "Every block in the document can have a specified Preferred, Minimum and Maximum size.", 1));

            section.Blocks.Add(GetDescriptionBlock("Preferred Width and Height", "The following paragraph has specified Preferred Width and Height.", 2));

            NParagraph paragraph1 = new NParagraph("Paragraph with Preferred Width 50% and Preferred Height of 200dips.");

            paragraph1.BackgroundFill  = new NColorFill(NColor.LightGray);
            paragraph1.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Percentage, 50);
            paragraph1.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 200);

            section.Blocks.Add(paragraph1);

            section.Blocks.Add(GetDescriptionBlock("Minimum and Maximum Width and Height", "The following paragraph has specified Minimum and Maximum Width.", 2));

            NParagraph paragraph2 = new NParagraph("Paragraph with Preferred Width 50% and Preferred Height of 200dips and Minimum Width of 200 dips and Maximum Width 300 dips.");

            paragraph2.BackgroundFill  = new NColorFill(NColor.LightGray);
            paragraph2.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Percentage, 50);
            paragraph2.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 200);
            paragraph2.MinWidth        = new NMultiLength(ENMultiLengthUnit.Dip, 200);
            paragraph2.MaxWidth        = new NMultiLength(ENMultiLengthUnit.Dip, 300);

            section.Blocks.Add(paragraph2);
        }
示例#6
0
        /// <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);
                    }
                }
            }
        }
示例#7
0
        private NTable CreateTable()
        {
            NTable table = new NTable();

            int rowCount = 3;
            int colCount = 3;

            // first create the columns
            for (int i = 0; i < colCount; i++)
            {
                table.Columns.Add(new NTableColumn());
            }

            // then add rows with cells count matching the number of columns
            for (int row = 0; row < rowCount; row++)
            {
                NTableRow tableRow = new NTableRow();
                table.Rows.Add(tableRow);

                for (int col = 0; col < colCount; col++)
                {
                    NTableCell tableCell = new NTableCell();
                    tableRow.Cells.Add(tableCell);
                    tableCell.Margins = new NMargins(4);

                    tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);
                    tableCell.BorderThickness = new NMargins(1);

                    NParagraph paragraph = new NParagraph("This is table cell [" + row.ToString() + ", " + col.ToString() + "]");
                    tableCell.Blocks.Add(paragraph);
                }
            }

            return(table);
        }
示例#8
0
            public override NDocumentBlock CreateDocument()
            {
                NDocumentBlock document = base.CreateDocument();

                NSection   section = document.Sections[0];
                NParagraph p       = new NParagraph("Black solid border");

                section.Blocks.Add(p);
                p.Border          = NBorder.CreateFilledBorder(NColor.Black);
                p.BorderThickness = new NMargins(1);

                p = new NParagraph("Black dashed border");
                section.Blocks.Add(p);
                p.Border = new NBorder();
                p.Border.MiddleStroke = new NStroke(5, NColor.Black, ENDashStyle.Dash);
                p.BorderThickness     = new NMargins(5);

                p = new NParagraph("Green/DarkGreen two-color border");
                section.Blocks.Add(p);
                p.Border          = NBorder.CreateTwoColorBorder(NColor.Green, NColor.DarkGreen);
                p.BorderThickness = new NMargins(10);

                p = new NParagraph("A border with left, right and bottom sides and wide but not set top side");
                section.Blocks.Add(p);
                p.Border                       = new NBorder();
                p.Border.LeftSide              = new NThreeColorsBorderSide(NColor.Black, NColor.Gray, NColor.LightGray);
                p.Border.RightSide             = new NBorderSide();
                p.Border.RightSide.OuterStroke = new NStroke(10, NColor.Blue, ENDashStyle.Dot);
                p.Border.BottomSide            = new NBorderSide(NColor.Red);
                p.BorderThickness              = new NMargins(9, 50, 5, 5);

                return(document);
            }
示例#9
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);
        }
        /// <summary>
        /// Creates a content paragraph
        /// </summary>
        /// <returns></returns>
        private NParagraph CreateContentParagraph(string text)
        {
            NParagraph paragraph = new NParagraph(text);

            paragraph.HorizontalAlignment = ENAlign.Justify;

            return(paragraph);
        }
示例#11
0
        /// <summary>
        /// Creates teh description paragraph
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        NParagraph CreateDescriptionParagraph(string title)
        {
            NParagraph paragraph = new NParagraph(title);

            paragraph.BackgroundFill = new NColorFill(NColor.WhiteSmoke);

            return(paragraph);
        }
示例#12
0
        /// <summary>
        /// Creates the title paragraph
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        NParagraph CreateTitleParagraph(string title)
        {
            NParagraph paragraph = new NParagraph(title);

            paragraph.FontSize = 18;
            paragraph.Fill     = new NColorFill(NColor.RoyalBlue);

            return(paragraph);
        }
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Table Master Cells Example", "This example shows how to programmatically create and add master cells.", 1));

            // first create the table
            NTable table = new NTable(5, 5);

            table.AllowSpacingBetweenCells = false;

            for (int row = 0; row < table.Rows.Count; row++)
            {
                for (int col = 0; col < table.Columns.Count; col++)
                {
                    NParagraph paragraph = new NParagraph("Normal Cell");

                    NTableCell tableCell = table.Rows[row].Cells[col];
                    tableCell.BorderThickness = new Nov.Graphics.NMargins(1);
                    tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);

                    // by default cells contain a single paragraph
                    tableCell.Blocks.Clear();
                    tableCell.Blocks.Add(paragraph);
                }
            }

            // set cell [0, 2] to be column master
            NTableCell colMasterCell = table.Rows[0].Cells[2];

            colMasterCell.ColSpan        = 2;
            colMasterCell.BackgroundFill = new NColorFill(ENNamedColor.LightSkyBlue);
            colMasterCell.Blocks.Clear();
            colMasterCell.Blocks.Add(new NParagraph("Column Master Cell"));

            // set cell [1, 0] to be row master
            NTableCell rowMasterCell = table.Rows[1].Cells[0];

            rowMasterCell.RowSpan        = 2;
            rowMasterCell.BackgroundFill = new NColorFill(ENNamedColor.LightSteelBlue);
            rowMasterCell.Blocks.Clear();
            rowMasterCell.Blocks.Add(new NParagraph("Row Master Cell"));

            // set cell [2, 2] to be column and row master
            NTableCell rowColMasterCell = table.Rows[2].Cells[2];

            rowColMasterCell.ColSpan        = 2;
            rowColMasterCell.RowSpan        = 2;
            rowColMasterCell.BackgroundFill = new NColorFill(ENNamedColor.MediumTurquoise);
            rowColMasterCell.Blocks.Clear();
            rowColMasterCell.Blocks.Add(new NParagraph("Row\\Col Master Cell"));

            section.Blocks.Add(table);
        }
        protected override void PopulateRichText()
        {
            // Get references to the heading styles
            NDocumentBlock documentBlock = m_RichText.Content;
            NRichTextStyle heading1Style = documentBlock.Styles.FindStyleByTypeAndId(ENRichTextStyleType.Paragraph, "Heading1");
            NRichTextStyle heading2Style = documentBlock.Styles.FindStyleByTypeAndId(ENRichTextStyleType.Paragraph, "Heading2");

            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            // Add a table of contents block
            NTableOfContentsBlock tableOfContents = new NTableOfContentsBlock();

            section.Blocks.Add(tableOfContents);

            // Create chapter 1
            NParagraph paragraph = new NParagraph("Chapter 1");

            section.Blocks.Add(paragraph);
            heading1Style.Apply(paragraph);

            paragraph = new NParagraph("Topic 1.1");
            section.Blocks.Add(paragraph);
            heading2Style.Apply(paragraph);

            AddParagraphs(section, "This is a sample paragraph from the first topic of chapter one.", 20);

            paragraph = new NParagraph("Topic 1.2");
            section.Blocks.Add(paragraph);
            heading2Style.Apply(paragraph);

            AddParagraphs(section, "This is a sample paragraph from the second topic of chapter one.", 20);

            // Create chapter 2
            paragraph = new NParagraph("Chapter 2");
            section.Blocks.Add(paragraph);
            heading1Style.Apply(paragraph);

            paragraph = new NParagraph("Topic 2.1");
            section.Blocks.Add(paragraph);
            heading2Style.Apply(paragraph);

            AddParagraphs(section, "This is a sample paragraph from the first topic of chapter two.", 20);

            paragraph = new NParagraph("Topic 2.2");
            section.Blocks.Add(paragraph);
            heading2Style.Apply(paragraph);

            AddParagraphs(section, "This is a sample paragraph from the second topic of chapter two.", 20);

            // Update the table of contents
            m_RichText.Document.Evaluate();
            tableOfContents.Update();
        }
示例#15
0
        /// <summary>
        /// Creates a paragraph that contains a widget
        /// </summary>
        /// <param name="widget"></param>
        /// <returns></returns>
        NParagraph CreateWidgetParagraph(NWidget widget)
        {
            NParagraph paragraph = new NParagraph();

            NWidgetInline inline = new NWidgetInline();

            inline.Content = widget;
            paragraph.Inlines.Add(inline);

            return(paragraph);
        }
        protected override void PopulateRichText()
        {
            NDocumentBlock documentBlock = m_RichText.Content;

            documentBlock.Layout = ENTextLayout.Print;

            NSection section = new NSection();

            documentBlock.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Barcode Widget Inlines",
                                                   "Nevron Open Vision lets you easily insert barcodes in text documents as widget inlines.", 1));

            // Create a table
            NTable table = new NTable(2, 2);

            section.Blocks.Add(table);

            // Create a linear barcode
            NLinearBarcode linearBarcode = new NLinearBarcode(ENLinearBarcodeSymbology.EAN13, "0123456789012");
            NWidgetInline  widgetInline  = new NWidgetInline(linearBarcode);

            // Create a paragraph to host the linear barcode widget inline
            NTableCell cell = table.Rows[0].Cells[0];

            cell.HorizontalAlignment = ENAlign.Center;
            NParagraph paragraph = (NParagraph)cell.Blocks[0];

            paragraph.Inlines.Add(widgetInline);

            // Create a paragraph to the right with some text
            cell      = table.Rows[0].Cells[1];
            paragraph = (NParagraph)cell.Blocks[0];
            paragraph.Inlines.Add(new NTextInline("The linear barcode to the left uses the EAN13 symbology."));

            // Create a QR code widget inline
            NMatrixBarcode qrCode = new NMatrixBarcode(ENMatrixBarcodeSymbology.QrCode, "https://www.nevron.com");

            widgetInline = new NWidgetInline(qrCode);

            // Create a paragraph to host the QR code widget inline
            cell = table.Rows[1].Cells[0];
            cell.HorizontalAlignment = ENAlign.Center;
            paragraph = (NParagraph)cell.Blocks[0];
            paragraph.Inlines.Add(widgetInline);

            // Create a paragraph to the right with some text
            cell      = table.Rows[1].Cells[1];
            paragraph = (NParagraph)cell.Blocks[0];
            paragraph.Inlines.Add(new NTextInline("The QR code to the left contains a link to "));
            paragraph.Inlines.Add(new NHyperlinkInline("https://www.nevron.com", "https://www.nevron.com"));
            paragraph.Inlines.Add(new NTextInline("."));
        }
示例#17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected NParagraph CreateSampleParagraph1()
        {
            NParagraph paragraph = new NParagraph("This paragraph has margins, border thickness and padding of 10dips.");

            paragraph.Margins         = new NMargins(10);
            paragraph.BorderThickness = new NMargins(10);
            paragraph.Padding         = new NMargins(10);
            paragraph.Border          = NBorder.CreateFilledBorder(NColor.Red);
            paragraph.BackgroundFill  = new NStockGradientFill(NColor.White, NColor.LightYellow);

            return(paragraph);
        }
示例#18
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected NParagraph CreateFloatingParagraph(ENFloatMode floatMode)
        {
            NParagraph paragraph = new NParagraph(floatMode.ToString() + " flow paragraph.");

            paragraph.FloatMode       = floatMode;
            paragraph.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Dip, 100);
            paragraph.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 100);
            paragraph.BorderThickness = new NMargins(1);
            paragraph.Border          = NBorder.CreateFilledBorder(NColor.Black);

            return(paragraph);
        }
示例#19
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected NParagraph CreateSampleParagraph1(string text)
        {
            NParagraph paragraph = new NParagraph(GetRepeatingText(text, 10));

            paragraph.Margins         = new NMargins(10);
            paragraph.BorderThickness = new NMargins(10);
            paragraph.Padding         = new NMargins(10);
            paragraph.Border          = NBorder.CreateFilledBorder(NColor.Red);
            paragraph.BackgroundFill  = new NStockGradientFill(NColor.White, NColor.LightYellow);

            return(paragraph);
        }
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Table Cell Orientation Example", "This example shows how to programmatically modify the orientation of cells.", 1));

            // first create the table
            NTable table = new NTable(5, 5);

            table.AllowSpacingBetweenCells = false;

            for (int row = 0; row < table.Rows.Count; row++)
            {
                for (int col = 0; col < table.Columns.Count; col++)
                {
                    NParagraph paragraph = new NParagraph("Normal Cell");

                    NTableCell tableCell = table.Rows[row].Cells[col];
                    tableCell.BorderThickness = new Nov.Graphics.NMargins(1);
                    tableCell.Border          = NBorder.CreateFilledBorder(NColor.Black);

                    // by default cells contain a single paragraph
                    tableCell.Blocks.Clear();
                    tableCell.Blocks.Add(paragraph);
                }
            }

            // set cell [1, 0] to be row master
            NTableCell leftToRightCell = table.Rows[1].Cells[0];

            leftToRightCell.RowSpan        = int.MaxValue;
            leftToRightCell.BackgroundFill = new NColorFill(ENNamedColor.LightSteelBlue);
            leftToRightCell.Blocks.Clear();
            leftToRightCell.Blocks.Add(new NParagraph("Cell With Left to Right Orientation"));
            leftToRightCell.TextDirection       = ENTableCellTextDirection.LeftToRight;
            leftToRightCell.HorizontalAlignment = ENAlign.Center;
            leftToRightCell.VerticalAlignment   = ENVAlign.Center;

            // set cell [1, 0] to be row master
            NTableCell rightToLeftCell = table.Rows[1].Cells[table.Columns.Count - 1];

            rightToLeftCell.RowSpan        = int.MaxValue;
            rightToLeftCell.BackgroundFill = new NColorFill(ENNamedColor.LightGreen);
            rightToLeftCell.Blocks.Clear();
            rightToLeftCell.Blocks.Add(new NParagraph("Cell With Right to Left Orientation"));
            rightToLeftCell.TextDirection       = ENTableCellTextDirection.RightToLeft;
            rightToLeftCell.HorizontalAlignment = ENAlign.Center;
            rightToLeftCell.VerticalAlignment   = ENVAlign.Center;

            section.Blocks.Add(table);
        }
        /// <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);
        }
示例#22
0
        /// <summary>
        ///
        /// </summary>
        protected override void PopulateRichText()
        {
            m_RichText.Content.Layout     = ENTextLayout.Print;
            m_RichText.Content.ZoomFactor = 0.5;

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

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

                string sectionText = string.Empty;

                switch (sectionIndex)
                {
                case 0:
                    sectionText       = "Paper size A4.";
                    section.PageSize  = new NPageSize(ENPaperKind.A4);
                    section.BreakType = ENSectionBreakType.NextPage;
                    section.Blocks.Add(GetDescriptionBlock("Section Pages", "This example shows how to set different page properties, like page size, page orientation and page border", 1));
                    break;

                case 1:
                    sectionText       = "Paper size A5.";
                    section.PageSize  = new NPageSize(ENPaperKind.A5);
                    section.BreakType = ENSectionBreakType.NextPage;
                    break;

                case 2:
                    sectionText             = "Paper size A4, paper orientation portrait.";
                    section.PageOrientation = ENPageOrientation.Landscape;
                    section.PageSize        = new NPageSize(ENPaperKind.A4);
                    section.BreakType       = ENSectionBreakType.NextPage;
                    break;

                case 3:
                    sectionText                 = "Paper size A4, page border solid 10dip.";
                    section.PageBorder          = NBorder.CreateFilledBorder(NColor.Black);
                    section.PageBorderThickness = new NMargins(10);
                    section.PageSize            = new NPageSize(ENPaperKind.A4);
                    section.BreakType           = ENSectionBreakType.NextPage;
                    break;
                }

                m_RichText.Content.Sections.Add(section);

                // add some content
                NParagraph paragraph = new NParagraph(sectionText);
                section.Blocks.Add(paragraph);
            }
        }
示例#23
0
        /// <summary>
        /// Gets a paragraph with title formatting
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        internal static NParagraph GetTitleParagraph(string text, int level)
        {
            NColor color = NColor.Black;

            NParagraph paragraph = GetTitleParagraphNoBorder(text, level);

            paragraph.HorizontalAlignment = ENAlign.Left;

            paragraph.Border          = CreateLeftTagBorder(color);
            paragraph.BorderThickness = new NMargins(5.0, 0.0, 0.0, 0.0);

            return(paragraph);
        }
示例#24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="section"></param>
        /// <param name="bulletListType"></param>
        /// <param name="items"></param>
        /// <param name="itemText"></param>
        private void CreateSampleBulletList(NSection section, ENBulletListTemplateType bulletListType, int items, string itemText)
        {
            NBulletList bulletList = new NBulletList(bulletListType);

            m_RichText.Content.BulletLists.Add(bulletList);

            for (int i = 0; i < items; i++)
            {
                NParagraph par = new NParagraph(itemText + i.ToString());
                par.SetBulletList(bulletList, 0);
                section.Blocks.Add(par);
            }
        }
示例#25
0
        /// <summary>
        /// Creates the book image paragraph
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        NParagraph CreateImageParagraph(NImage image)
        {
            NParagraph paragraph = new NParagraph();

            NImageInline inline = new NImageInline();

            inline.Image           = (NImage)image.DeepClone();
            inline.PreferredWidth  = new NMultiLength(ENMultiLengthUnit.Dip, 200);
            inline.PreferredHeight = new NMultiLength(ENMultiLengthUnit.Dip, 280);
            paragraph.Inlines.Add(inline);

            return(paragraph);
        }
示例#26
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Bullet Lists", "Bullet lists allow you to apply automatic numbering on paragraphs or groups of blocks.", 1));

            section.Blocks.Add(GetDescriptionBlock("Simple bullet list", "Following is a bullet list with default formatting.", 2));

            CreateSampleBulletList(section, ENBulletListTemplateType.Bullet, 3, "Bullet List Item");

            // setting bullet list template type
            {
                section.Blocks.Add(GetDescriptionBlock("Bullet Lists with Different Template", "Following are bullet lists with different formatting", 2));

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

                for (int i = 0; i < values.Length - 1; i++)
                {
                    CreateSampleBulletList(section, values[i], 3, names[i] + " bullet list item ");
                }
            }

            // nested bullet lists
            {
                section.Blocks.Add(GetDescriptionBlock("Bullet List Levels", "Following is an example of bullet list levels", 2));

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

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

                    for (int j = 0; j < 2; j++)
                    {
                        NParagraph par2 = new NParagraph("Nested Bullet List Item" + i.ToString());
                        par2.SetBulletList(bulletList, 1);
                        par2.MarginLeft = 20;
                        section.Blocks.Add(par2);
                    }
                }
            }
        }
示例#27
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Hyperlink Inlines", "The example shows how to use hyperlinks inlines.", 1));

            // Hyperlink inline with a hyperlink to an URL
            {
                NHyperlinkInline hyperlinkInline = new NHyperlinkInline();
                hyperlinkInline.Hyperlink = new NUrlHyperlink("http://www.nevron.com", ENUrlHyperlinkTarget.SameWindowSameFrame);
                hyperlinkInline.Text      = "Jump to www.nevron.com";

                NParagraph paragraph = new NParagraph();
                paragraph.Inlines.Add(hyperlinkInline);
                section.Blocks.Add(paragraph);
            }

            // Image inline with a hyperlink to an URL
            {
                NImageInline imageInline = new NImageInline();
                imageInline.Image     = Nov.Diagram.NResources.Image_Other_MyDrawLogo_png;
                imageInline.Hyperlink = new NUrlHyperlink("http://www.mydraw.com", ENUrlHyperlinkTarget.SameWindowSameFrame);

                NParagraph paragraph = new NParagraph();
                paragraph.Inlines.Add(imageInline);
                section.Blocks.Add(paragraph);
            }

            for (int i = 0; i < 10; i++)
            {
                section.Blocks.Add(new NParagraph("Some paragraph"));
            }

            // Bookmark inline
            {
                NParagraph paragraph = new NParagraph();

                NBookmarkInline bookmark = new NBookmarkInline();
                bookmark.Name = "MyBookmark";
                bookmark.Text = "This is a bookmark";
                bookmark.Fill = new NColorFill(NColor.Red);
                paragraph.Inlines.Add(bookmark);

                section.Blocks.Add(paragraph);
            }
        }
示例#28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="title"></param>
        /// <param name="description"></param>
        /// <param name="level"></param>
        /// <returns></returns>
        internal static NGroupBlock GetNoteBlock(string text, int level)
        {
            NColor     color     = NColor.Red;
            NParagraph paragraph = GetTitleParagraphNoBorder("Note", level);

            NGroupBlock groupBlock = new NGroupBlock();

            groupBlock.ClearMode = ENClearMode.All;
            groupBlock.Blocks.Add(paragraph);
            groupBlock.Blocks.Add(GetDescriptionParagraph(text));

            groupBlock.Border          = CreateLeftTagBorder(color);
            groupBlock.BorderThickness = defaultBorderThickness;

            return(groupBlock);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private NHeaderFooter CreateHeaderFooter(string text)
        {
            NHeaderFooter headerFooter = new NHeaderFooter();

            NParagraph paragraph = new NParagraph();

            paragraph.Inlines.Add(new NTextInline(text));
            paragraph.Inlines.Add(new NTextInline("Page "));
            paragraph.Inlines.Add(new NFieldInline(ENNumericFieldName.PageNumber));
            paragraph.Inlines.Add(new NTextInline(" of "));
            paragraph.Inlines.Add(new NFieldInline(ENNumericFieldName.PageCount));

            headerFooter.Blocks.Add(paragraph);

            return(headerFooter);
        }
示例#30
0
        protected override void PopulateRichText()
        {
            NSection section = new NSection();

            m_RichText.Content.Sections.Add(section);

            section.Blocks.Add(GetDescriptionBlock("Paragraphs can contain explicit line breaks", "This example shows how to programmatically add line breaks to paragraphs", 2));

            NParagraph paragraph = new NParagraph();

            paragraph.Inlines.Add(new NTextInline("This text appears on the first line."));
            paragraph.Inlines.Add(new NLineBreakInline());
            paragraph.Inlines.Add(new NTextInline("This text appears on the second line (after the line break)."));

            section.Blocks.Add(paragraph);
        }