Nevron Open Vision Documentation
Diagram / Diagram DOM / Drawings / Pages / Pages
In This Topic
    Pages
    In This Topic
     About Pages

    Pages are represented by the NPage class. The pages of a drawing are contained inside the Pages collection of each NDrawing element. Of all pages inside the drawing only one can be active at a time. The active page is controlled by the ActivePage property of the drawing (NDrawing) or the ActivePage property of the drawing view (NDrawingView), which is a shortcut to the ActivePage property of the drawing. By default each drawing is created with a single page that is at the same time the active page of the drawing.

    The page is a container element that has the following child items:

    • Items - an instance of the NPageItemColleciton class that contains the items of a page. You typically use the Items collection to insert shapes inside it.
    • Grid - exposes settings related to the page grid.
    • Rulers - exposes settings related to the rulers displayed for the page.
    • Router - controls the routing of the routable connectors inside the page.
    • PrintLayout - control the arrangement of the page inside the print page dimensions.

    Additionally the page contains the currently selected page items inside its Selection attribute.

    The page also has a Width and a Height property, which can be used to set the page size. You can also set the page size for printing by assigning an NPaperSize to the PageSize property of the page's PrintLayout.The code below demonstrates how to size the active page of a drawing to the "Letter" paper size:

    Setting Page Size
    Copy Code
    // Create paper size
    NPaperSize paperSize = new NPaperSize(ENPaperKind.Letter);
    
    // Set page size
    NPage page = drawingView.ActivePage;
    page.Width = paperSize.WidthInDIPs;
    page.Height = paperSize.HeightInDIPs;
    
    // Set page size for printing
    page.PrintLayout.PageSize = paperSize;
    
     Page Navigator

    The drawing view includes a page navigator at the bottom. It lets the user quickly navigate to a different page, add, remove and rename pages.

    If you want to disable adding or removing pages you can use the AllowAdd and AllowRemove properties of the page navigator:

    Disable adding and removing pages via the page navigator
    Copy Code
    drawingView.PageNavigator.AllowAdd = false;
    drawingView.PageNavigator.AllowRemove = false;
    

    To hide the page navigator completely, use the following line of code:

    Hide the page navigator completely
    Copy Code
    drawingView.PageNavigator.Visibility = ENVisibility.Collapsed;
    
     Zooming

    Drawing pages expose a ZoomMode property, which determines the page zoom policy, the options being:

    Value Description
    Normal Page is displayed with its current zoom (default).
    Fit Page is zoomed to fit the drawing view area.
    FitToWidth Page is zoomed to fit the drawing view width.
    FitToHeight Content is zoomed to fit the drawing view height.
           

    The following code fragment demonstrates how to make the active page of a drawing zoom to fit the available area of a drawing view:

    Zoom page to fit drawing view area
    Copy Code
    drawing.ActivePage.ZoomMode = ENZoomMode.FitToHeight;
    

    To zoom a drawing page programmatically you should make sure its ZoomMode is set to Normal and then modify its ZoomFactor property, where a value of 1 means the page is at 100%, 0.8 means the page is zoomed to 80%, 1.2 means the page is zoomed to 120% and so on. You can also use the ZoomIn() and ZoomOut() methods to zoom the page in and out with the value of the ZoomStep property.

     Selection

    The selected items of the page are exposed by the NPageSelection attribute. The selection can be configured to operate in two modes via its Mode property, which are:

    • Single - only a single item can be selected
    • Multiple - multiple items can be selected

    The first or the last selected node is called selection anchor and can be used by different alignment and resize operations. Whether the first or the last selected node is the selection anchor is controlled by the AnchorMode property. The current selection anchor can be obtained from the AnchorItem property.

    The selection class provides a powerful set of methods, which can help you modify the selection. The most important ones are demonstrated in the following example:

    Selection Operations
    Copy Code
    // get the drawing view active page selection
    NPageSelection selection = drawingView.ActivePage.Selection;
    // make node1 the one and only selected node
    selection.SingleSelect(node1);
    // append node2 to the current selection
    selection.MultiSelect(node2);
    // toggle the selection state of the node3 (in this case this will select node3)
    selection.ToggleSelect(node3);
    // toggle the selection state of the node3 (in this case this will deselect node3)
    selection.ToggleSelect(node3);
    // deselect node1
    selection.Deselect(node1);
    // deselect all nodes (in this case only node2)
    selection.DeselectAll();
    
     Drawing Scale

    NOV Diagram uses the NOV UI measurement unit for all display related measures, which is the DIP (device independent pixel, which is 1/96 of an inch). By default the drawing scale is configured so that 1 DIP equals 1 DIP (identity scale).

    Some applications however require to display either too small or too large scenes, which are impossible to visualize without a drawing scale. You must have a large monitor to display a room of 3x3 meters and there is no monitor, which can display something measured in kilometers. In these cases you must use a drawing scale.

    Drawing scale is a user defined ratio between the logical unit and a display unit. For example 1 meter = 1 mm is a commonly used Metric drawing scale that is configured like this:

    Setting Drawing Scale
    Copy Code
    NPage activePage = drawingView.ActivePage;
    activePage.LogicalLength = new NLength(1, NUnit.Meter);
    activePage.DisplayLenght = new NLength(1, NUnit.Millimeter);
    

    Drawing scale helps you work with the document content as if it is measured with the real world measurement unit that you want to use. For example: a room can be defined as a rectangle with width 3 and height 3 meters in logical measurement units like this.

    Using Drawing Scale
    Copy Code
    NBasicShapesFactory basicShapes = new NBasicShapesFactory();
    NShape shape = basicShapes.CreateShape(ENBasicShapes.Rectangle);
    shape.Width = activePage.LogicalToDisplay(3);
    shape.Height = activePage.LogicalToDisplay(3);
    activePage.Items.Add(shape);
    
    The rulers, grid and status bar report measurements in the page logical unit.
    See Also