Page Navigator Example for WPF

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

Page Navigator Example for WPF Description

This example demonstrates the Page Navigator. The Page Navigator is a widget positioned in the bottom-left corner of the drawing view. It allows users to switch between different drawing pages and manage their order via drag-and-drop functionality. Additionally, the Page Navigator supports adding new pages and provides per-page context menus for quick operations, including deleting, renaming, duplicating, and configuring grid, rulers, and page setup.

The Page Navigator is a part of each NDrawingView and is accessible from its PageNavigator property.

Use the controls on the right side to control the allowed operations that the user can perform upon the pages through the Page Navigator.


Page Navigator Example

C# Page Navigator Example Code for Nevron Diagram for WPF
Language: C#

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

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

		public Form1()
		{
			InitializeComponent();

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

			// 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()
        {
            NStackPanel stack = new NStackPanel();

            // Create the property editors
            NList editors = NDesigner.GetDesigner(m_DrawingView.PageNavigator).CreateMemberEditors(
                m_DrawingView.PageNavigator,
                NPageNavigator.AllowAddPageProperty,
                NPageNavigator.AllowDeletePageProperty,
                NPageNavigator.AllowEditPageProperty,
                NPageNavigator.AllowReorderPagesProperty,
                NPageNavigator.ShowForegroundPagesProperty,
                NPageNavigator.ShowBackgroundPagesProperty);

            for (int i = 0, count = editors.Count; i < count; i++)
            {
                stack.Add(editors[i]);
            }

            return new NUniSizeBoxGroup(stack);
        }
        public string GetExampleDescription()
        {
            return @"

This example demonstrates the Page Navigator. The Page Navigator is a widget positioned in the bottom-left corner of the drawing view. It allows users to switch between different drawing pages and manage their order via drag-and-drop functionality. Additionally, the Page Navigator supports adding new pages and provides per-page context menus for quick operations, including deleting, renaming, duplicating, and configuring grid, rulers, and page setup.

The Page Navigator is a part of each NDrawingView and is accessible from its PageNavigator property.

Use the controls on the right side to control the allowed operations that the user can perform upon the pages through the Page Navigator.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Page Navigator", "https://www.nevron.com/docs/openvision/diagram-page-navigator.html"), ("Pages", "https://www.nevron.com/docs/openvision/diagram-pages.html"), }; } private void InitDiagram(NDrawingDocument drawingDocument) { NDrawing drawing = drawingDocument.Content; drawing.Pages.Clear(); NColor[] colors = new NColor[] { new NColor(247, 139, 119), new NColor(254, 236, 233), new NColor(254, 244, 242), new NColor(250, 183, 88) }; // create a page for background NPage backgroundPage = new NPage(); backgroundPage.Title = "Background Page"; backgroundPage.PageType = ENPageType.Background; Random rnd = new Random(); // create bubbles in this page NBasicShapeFactory factory = new NBasicShapeFactory(); for (int i = 0; i < 30; i++) { // select random x, y, size and color double x = (double)rnd.Next((int)backgroundPage.Width); double y = (double)rnd.Next((int)backgroundPage.Height); double size = (double)rnd.Next(200); int colorIndex = (byte)rnd.Next(colors.Length); NShape shape = factory.CreateShape(ENBasicShape.Circle); backgroundPage.Items.Add(shape); shape.SetBounds(NRectangle.FromCenterAndSize(new NPoint(x,y), size, size)); shape.Geometry.Fill = new NColorFill(colors[colorIndex]); shape.Geometry.Stroke = null; } drawing.Pages.Add(backgroundPage); // create a foreground page NPage foregroundPage1 = new NPage(); foregroundPage1.Title = "Foreground Page 1"; foregroundPage1.BackgroundPage = backgroundPage; drawing.Pages.Insert(0, foregroundPage1); CreateTitle("Foreground Page 1", foregroundPage1); NPage foregroundPage2 = new NPage(); foregroundPage2.Title = "Foreground Page 2"; foregroundPage2.BackgroundPage = backgroundPage; drawing.Pages.Insert(1, foregroundPage2); CreateTitle("Foreground Page 2", foregroundPage2); } private void CreateTitle(string title, NPage page) { // create title NShape titleShape = new NShape(); titleShape.Width = page.Width; titleShape.Height = 75; titleShape.PinX = page.X + page.Width / 2; titleShape.PinY = page.Y + titleShape.Height / 2; titleShape.Text = title; titleShape.TextBlock.FontName = "Arial"; titleShape.TextBlock.FontSize = 40; titleShape.TextBlock.FontStyle = ENFontStyle.Bold; titleShape.TextBlock.Fill = new NColorFill(new NColor(68, 90, 108)); titleShape.TextBlock.Shadow = new NShadow(); page.Items.AddChild(titleShape); } #endregion #region Implementation #endregion #region Event Handlers #endregion #region Fields private NDrawingView m_DrawingView; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Page Navigator Example for WPF Solution

VB.NET Page Navigator Example Code for Nevron Diagram for WPF
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Diagram
Imports Nevron.Nov.Diagram.Shapes
Imports Nevron.Nov.Diagram.UI
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Editors
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Imports System

Class MainWindow

#Region "Constructors"

	Public Sub New()
		' This call is required by the designer.
		InitializeComponent()

		' Add any initialization after the InitializeComponent() call.

		' Set form title
		Title = "NOV WPF - NPageNavigatorExample"

		' Create the NOV example and its controls
		Dim exampleContent As NWidget = CreateExampleContent()
		Dim exampleControls As NWidget = CreateExampleControls()
		If Not exampleControls Is Nothing Then
			exampleControls.PreferredWidth = 300
		End If

		' Place the example and its controls in a pair box
		Dim pairBox As NPairBox = 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
		Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
		Content = host
	End Sub


#End Region

#Region "Example"

        Public Function CreateExampleContent() As NWidget
            ' create a simple drawing
            Dim drawingViewWithRibbon As NDrawingViewWithRibbon = New NDrawingViewWithRibbon()
            m_DrawingView = drawingViewWithRibbon.View

            m_DrawingView.Document.HistoryService.Pause()
            Try
                InitDiagram(m_DrawingView.Document)
            Finally
                m_DrawingView.Document.HistoryService.Resume()
            End Try

            Return drawingViewWithRibbon
        End Function
        Public Function CreateExampleControls() As NWidget
            Dim stack As NStackPanel = New NStackPanel()

            ' Create the property editors
            Dim editors = NDesigner.GetDesigner(m_DrawingView.PageNavigator).CreateMemberEditors(m_DrawingView.PageNavigator, NPageNavigator.AllowAddPageProperty, NPageNavigator.AllowDeletePageProperty, NPageNavigator.AllowEditPageProperty, NPageNavigator.AllowReorderPagesProperty, NPageNavigator.ShowForegroundPagesProperty, NPageNavigator.ShowBackgroundPagesProperty)

            Dim i = 0, count = editors.Count

            While i < count
                stack.Add(editors(i))
                i += 1
            End While

            Return New NUniSizeBoxGroup(stack)
        End Function
        Public Function GetExampleDescription() As String
            Return "

This example demonstrates the Page Navigator. The Page Navigator is a widget positioned in the bottom-left corner of the drawing view. It allows users to switch between different drawing pages and manage their order via drag-and-drop functionality. Additionally, the Page Navigator supports adding new pages and provides per-page context menus for quick operations, including deleting, renaming, duplicating, and configuring grid, rulers, and page setup.

The Page Navigator is a part of each NDrawingView and is accessible from its PageNavigator property.

Use the controls on the right side to control the allowed operations that the user can perform upon the pages through the Page Navigator.

" End Function ''' ''' Gets the relevant documentation links for the example ''' ''' Public Function GetDocumentationUrls() As (String, String)() Return {("Page Navigator", "https://www.nevron.com/docs/openvision/diagram-page-navigator.html"), ("Pages", "https://www.nevron.com/docs/openvision/diagram-pages.html")} End Function Private Sub InitDiagram(drawingDocument As NDrawingDocument) Dim drawing = drawingDocument.Content drawing.Pages.Clear() Dim colors As NColor() = New NColor() {New NColor(247, 139, 119), New NColor(254, 236, 233), New NColor(254, 244, 242), New NColor(250, 183, 88)} ' create a page for background Dim backgroundPage As NPage = New NPage() backgroundPage.Title = "Background Page" backgroundPage.PageType = ENPageType.Background Dim rnd As Random = New Random() ' create bubbles in this page Dim factory As NBasicShapeFactory = New NBasicShapeFactory() For i = 0 To 29 ' select random x, y, size and color Dim x As Double = rnd.Next(backgroundPage.Width) Dim y As Double = rnd.Next(backgroundPage.Height) Dim size As Double = rnd.Next(200) Dim colorIndex As Integer = CByte(rnd.Next(colors.Length)) Dim shape = factory.CreateShape(ENBasicShape.Circle) backgroundPage.Items.Add(shape) shape.SetBounds(NRectangle.FromCenterAndSize(New NPoint(x, y), size, size)) shape.Geometry.Fill = New NColorFill(colors(colorIndex)) shape.Geometry.Stroke = Nothing Next drawing.Pages.Add(backgroundPage) ' create a foreground page Dim foregroundPage1 As NPage = New NPage() foregroundPage1.Title = "Foreground Page 1" foregroundPage1.BackgroundPage = backgroundPage drawing.Pages.Insert(0, foregroundPage1) CreateTitle("Foreground Page 1", foregroundPage1) Dim foregroundPage2 As NPage = New NPage() foregroundPage2.Title = "Foreground Page 2" foregroundPage2.BackgroundPage = backgroundPage drawing.Pages.Insert(1, foregroundPage2) CreateTitle("Foreground Page 2", foregroundPage2) End Sub Private Sub CreateTitle(title As String, page As NPage) ' create title Dim titleShape As NShape = New NShape() titleShape.Width = page.Width titleShape.Height = 75 titleShape.PinX = page.X + page.Width / 2 titleShape.PinY = page.Y + titleShape.Height / 2 titleShape.Text = title titleShape.TextBlock.FontName = "Arial" titleShape.TextBlock.FontSize = 40 titleShape.TextBlock.FontStyle = ENFontStyle.Bold titleShape.TextBlock.Fill = New NColorFill(New NColor(68, 90, 108)) titleShape.TextBlock.Shadow = New NShadow() page.Items.AddChild(titleShape) End Sub #End Region #Region "Implementation" #End Region #Region "Event Handlers" #End Region #Region "Fields" Private m_DrawingView As NDrawingView #End Region #Region "Static Methods" #End Region #Region "Constants" #End Region #Region "Nested Types" #End Region End Class

Download a fully functional VB.NET (.vb) Page Navigator Example for WPF Solution

Related Documentation Links