public override NDocumentBlock CreateDocument() { NDocumentBlock document = base.CreateDocument(); NSection section = document.Sections[0]; NParagraph p = new NParagraph("This is a red paragraph on the left."); p.HorizontalAnchor = ENHorizontalAnchor.Ancestor; p.HorizontalBlockAlignment = ENHorizontalBlockAlignment.Left; p.VerticalAnchor = ENVerticalAnchor.Ancestor; p.XOffset = 20; p.YOffset = 200; p.PreferredWidth = NMultiLength.NewPercentage(25); p.BackgroundFill = new NColorFill(NColor.Red); section.Blocks.Add(p); p = new NParagraph("This is a green paragraph on the top."); p.HorizontalAnchor = ENHorizontalAnchor.Ancestor; p.VerticalAnchor = ENVerticalAnchor.Ancestor; p.VerticalBlockAlignment = ENVerticalBlockAlignment.Top; p.XOffset = 120; p.YOffset = 100; p.PreferredWidth = NMultiLength.NewPercentage(50); p.BackgroundFill = new NColorFill(NColor.Green); section.Blocks.Add(p); p = new NParagraph("This is a blue paragraph on the right."); p.HorizontalAnchor = ENHorizontalAnchor.Ancestor; p.HorizontalBlockAlignment = ENHorizontalBlockAlignment.Right; p.VerticalAnchor = ENVerticalAnchor.Ancestor; p.XOffset = 20; p.YOffset = 200; p.PreferredWidth = NMultiLength.NewPercentage(25); p.BackgroundFill = new NColorFill(NColor.Blue); p.Fill = new NColorFill(NColor.White); section.Blocks.Add(p); return(document); }
/// <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); }
protected override NWidget CreateExampleContent() { // Create a table layout panel m_Table = new NTableFlowPanel(); m_Table.HorizontalPlacement = ENHorizontalPlacement.Left; m_Table.VerticalPlacement = ENVerticalPlacement.Top; m_Table.Padding = new NMargins(30); m_Table.HorizontalSpacing = 30; m_Table.VerticalSpacing = 30; m_Table.MaxOrdinal = 4; string[] names = new string[] { "Align", "Fit and Align", "Fixed", "Stretch", "Stretch X, Align Y", "Stretch Y, Align X", "Tile" }; NTextureMapping[] mappings = new NTextureMapping[] { new NAlignTextureMapping(ENHorizontalAlignment.Left, ENVerticalAlignment.Top), new NFitAndAlignTextureMapping(ENHorizontalAlignment.Center, ENVerticalAlignment.Center), new NFixedTextureMapping(NMultiLength.NewPercentage(10), ENHorizontalAlignment.Left, NMultiLength.NewPercentage(10), ENVerticalAlignment.Top), new NStretchTextureMapping(), new NStretchXAlignYTextureMapping(ENVerticalAlignment.Bottom, ENTileMode.None), new NStretchYAlignXTextureMapping(ENHorizontalAlignment.Right, ENTileMode.None), new NTileTextureMapping() }; // Add widgets with the proper filling and names to the panel for (int i = 0; i < mappings.Length; i++) { NStackPanel stack = new NStackPanel(); m_Table.Add(stack); stack.Direction = ENHVDirection.TopToBottom; stack.FillMode = ENStackFillMode.First; stack.FitMode = ENStackFitMode.First; // Create a widget with the proper filling NCanvas canvas = new NCanvas(); canvas.PreferredSize = new NSize(defaultCanvasWidth, defaultCanvasHeight); NImageFill fill = new NImageFill(NResources.Image_Artistic_Plane_png); fill.TextureMapping = mappings[i]; canvas.Tag = fill; stack.Add(canvas); canvas.PrePaint += new Function <NCanvasPaintEventArgs>(OnCanvasPrePaint); // Create a label with the corresponding name NLabel label = new NLabel(names[i]); stack.Add(label); label.HorizontalPlacement = ENHorizontalPlacement.Center; } // The table must be scrollable NScrollContent scroll = new NScrollContent(); scroll.Content = m_Table; return(scroll); }