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); |