Nevron Open Vision Documentation
Diagram / Diagram DOM / Libraries / Libraries
In This Topic
    Libraries
    In This Topic
     About Libraries

    In NOV Diagram for .NET libraries are represented by the NLibrary element. Libraries are the root element of the NLibraryDocument class, which is typically displayed by an instance of the NLibraryView class. A library is designed to contain multiple library items, that can be dragged and dropped on a drawing view. In this way libraries facilitate the management of reusable drawing clippings. Each library item can contain one or multiple shapes, so it is virtually possible to store any drawing clipping in a reusable library item.

    Typically in end-user applications the user needs to be presented with multiple libraries from which to create shapes. The Library Browser UI element facilitates the management of multiple libraries in end-user applications.

     Library Items

    Libraries contain library items. Library items are represented by the NLibraryItem class. Library items contain reusable drawing clippings that you can drag and drop inside drawing views. The content of a library item are the page items contained inside the NPageItemCollection accessible from the Items property of the library item. Inside the library the library item is rendered as an Image-Text pair. The image is automatically generated by the library item. The text can be assigned by the user by setting the library item Text property. The following example demonstrates how to create a library item:

    Create Library Item
    Copy Code
    NShape shape = new NBasicShapesFactory().CreateShape(ENBasicShapes.Rectangle);
    NLibraryItem libraryItem = new NLibraryItem();
    libraryItem.Name = "Rectangle";
    libraryItem.Text = "Rectangle";
    libraryItem.Tooltip = new NTooltip("Drag and drop me onto the drawing");
    libraryItem.Items.Add(shape);
    
     Libraries and Shape Factories
    Shape factories are the most common way to create predefined shapes in code. Shape factories however can generate entire library elements that contain a library item for each shape generated by the factory. The following code example demonstrates how to create a library from the basic shapes factory:
    Create Library from Shape Factory
    Copy Code
    NBasicShapesFactory basicShapesFactory = new NBasicShapesFactory();
    NLibrary library = basicShapesFactory.CreateLibrary();
    
     Libraries View Type

    Libraries are designed to be displayed in several view types, which are enumerated by the ENLibraryViewType enumeration, that currently contains the following values:

    • List
    • Icons
    • Thumbnails

    The view type of a library is controlled by the ViewType property that accepts a value from the ENLibraryViewType enumeration. For each view type the library contains a specific settings object, that is derived from the NLibraryItemsView abstract class. The following table summarizes the library view settings objects for each specific type of view:

    View Type Class Accessible via Property Description
    Icons

    NIconsLibraryItemsView

    IconsItemsView

    Controls the settings of the Icons items view. By default the preview size is set to 32x32 dips.
    List

    NListLibraryItemsView

    ListItemsView

    Controls the settings of the List items view. By default the preview size is set to 16x16 dips.
    Thumbnails

    NThumbnailsLibraryItemsView

    ThumbnailsItemsView

    Controls the settings of the Thumbnails items view. By default the preview size is set to 64x64 dips.

    In this way you can adjust the settings for a specific library view type, by altering the properties of the respective view type settings object. The following code example instructs the library to display the previews in Icons view in 24x24 size and specifies the custom horizontal and vertical spacing between the items:

    Changing the settings for a specific library view type
    Copy Code
    library.ViewType = ENLibraryViewType.Icons;
    library.IconsItemsView.PreviewSize = new NSize(24, 24);
    library.IconsItemsView.HorizontalSpacing = 5;
    library.IconsItemsView.VerticalSpacing = 10;
    
     Library Display Order

    By default libraries are displaying their items in the order in which they are defined (added to the library). It is in many cases useful to order the items by their name, so that the user can search for a specific shape by name more quickly. The library display order is controlled the LibraryDisplayOrder property that accepts value from the ENLibraryDisplayOrder enumeration. The following code example displays the items inside a library by their name ascending order:

    Changing the library display order
    Copy Code
    library.DisplayOrder = ENLibraryDisplayOrder.NameAscending;