A drawing document is represented by the NDrawingDocument class, which derives from the NGenericDocument<NDrawing>, which essentially means that the content of a drawing document is an instance of the NDrawing class, which represents a diagram drawing (see Drawings for more information).
The drawing view is represented by the NDrawingView class, which is essentially a widget that is designed to display the content of a drawing document. In this way you can integrate a drawing inside any NOV UI hierarchy (see UI Overview for more info).
The drawing document displayed by the drawing view is accessible via the Document property. When a drawing view is created, it by default also creates an empty drawing document inside it.
The following code creates a drawing view, the document of which has some shapes and is placed inside a stack panel.
Drawing View Example |
Copy Code
|
---|---|
// Create a stack panel NStackPanel stack = new NStackPanel(); stack.Add(new NButton("Some Button")); // Add a drawing view in the stack panel NDrawingView drawingView = new NDrawingView(); stack.Add(drawingView); // Get the drawing view document, the drawing and its active page NDrawingDocument document = drawingView.Document; NDrawing drawing = document.Content; NPage activePage = drawing.ActivePage; // Instead of the 3 lines above you can also use the shortcut property: // NPage activePage = drawingView.ActivePage; // Add a rectangle shape to the active page items NShape rectangleShape = new NBasicShapeFactory().CreateShape(ENBasicShape.Rectangle); rectangleShape.Text = "My First Shape"; activePage.Items.Add(rectangleShape); |