Bullet lists Example for Blazor

Nevron NOV Diagram for Blazor ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All Blazor Diagram examples are also available as a stand-alone Visual Studio solution in C#, which you can download from the links below.

Bullet lists Example for Blazor Description

Demonstrates how to add bullets lists in text content.


Bullet Lists Example

C# Bullet lists Example Code for Nevron Diagram for Blazor
Language: C#

using Nevron.Nov;
using Nevron.Nov.Diagram;
using Nevron.Nov.Diagram.Shapes;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Text;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NBulletListsExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		public NWidget CreateExampleContent()
		{
			// Create a simple drawing
			NDrawingViewWithRibbon drawingViewWithRibbon = new NDrawingViewWithRibbon();
			m_DrawingView = drawingViewWithRibbon.View;

			m_DrawingView.Document.HistoryService.Pause();
			try
			{
				InitDiagram(m_DrawingView.Document);
			}
			finally
			{
				m_DrawingView.Document.HistoryService.Resume();
			}

			return drawingViewWithRibbon;
		}
		public NWidget CreateExampleControls()
		{
			return null;
		}
		public string GetExampleDescription()
        {
            return @"

Demonstrates how to add bullets lists in text content.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Text Block", "https://www.nevron.com/docs/openvision/diagram-text-block.html"), ("Rich Text Bullet Lists", "https://www.nevron.com/docs/openvision/rich-text-bullet-lists.html"), ("Rich Text Paragraphs", "https://www.nevron.com/docs/openvision/rich-text-paragraphs.html"), }; } private void InitDiagram(NDrawingDocument drawingDocument) { NDrawing drawing = drawingDocument.Content; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NShape shape1 = new NBasicShapeFactory().CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 600, 1000); NTextBlock textBlock = new NTextBlock(); shape1.TextBlock = textBlock; textBlock.Padding = new NMargins(20); textBlock.Content.Blocks.Clear(); textBlock.Content.HorizontalAlignment = ENAlign.Left; AddFormattedTextToContent(textBlock.Content); drawing.ActivePage.Items.Add(shape1); } #endregion #region Implementation #endregion #region Event Handlers #endregion #region Fields private NDrawingView m_DrawingView; #endregion #region Static Methods /// /// Adds rich formatted text to the specified text block content /// /// private static 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(); 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); } } } } 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; } /// /// Gets a paragraph with title formatting /// /// /// 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; } /// /// Creates a left tag border with the specified border /// /// /// private static NBorder CreateLeftTagBorder(NColor color) { NBorder border = new NBorder(); border.LeftSide = new NBorderSide(); border.LeftSide.Fill = new NColorFill(color); return border; } #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Bullet lists Example for Blazor Solution