Diagram > Diagram DOM > Libraries > Library View and Library Document |
A library document is represented by the NLibraryDocument class, which derives from the NGenericDocument<NLibrary>, which essentially means that the content of a library document is an instance of the NLibrary class, which represents a diagram library (see Libraries for more information).
The library view is represented by the NLibraryView class, which is a widget that is designed to display the content of a library document. In this way you can integrate a library inside any NOV UI hierarchy (see UI Overview for more info).
The library document displayed by the library view is accessible via the Document property. When a library view is created, it by default also creates an empty library document inside it.
The following code creates a library view, the document of which contains the shapes produced by the basic shapes factory:
Library View Example |
Copy Code
|
---|---|
// create a stack panel NStackPanel stack = new NStackPanel(); stack.Add(new NButton("Some Button")); // add a library view in the stack panel NLibraryView libraryView = new NLibraryView(); stack.Add(libraryView); // get the library view document and its library NLibraryDocument document = libraryView.Document; NLibrary library = document.Content; // create a rectangle shape inside a library NShape shape = new NBasicShapesFactory().CreateShape(ENBasicShapes.Rectangle); NLibraryItem libraryItem = new NLibraryItem(); libraryItem.Name = "Rectangle"; libraryItem.Items.Add(shape); library.Items.Add(libraryItem); |
The library view Interactor is populated with tools that perform different actions upon the library view and its content (see the Interactors topic for a fundamental overview of interactors).
All tools that reside inside in the library view Interactor are defined in the Nevron.Nov.Diagram.LibraryTools namespace. Following is a brief overview:
Ambient Tools |
|
---|---|
NClickSelectTool | Selects library items. |
NContextMenuTool | Shows a context menu for the currently selected library items. |
NMoveTool | Implements moving and Drag and Drop of library items. |
NScrollTool | Implements mouse wheel scrolling of the library. |
NDragDropTargetTool | Extends the Drop target functionality of library views, by providing them with the ability to handle dropped library clippings, text, images etc. |
The library view Commander is populated with commands that perform different actions upon the library view and its content (see the Commanding topic for a fundamental overview of commands).
All commands that reside inside in the library view Commander are defined in the Nevron.Nov.Diagram.LibraryCommands namespace.