Nevron .NET Vision Documentation
Diagram Documents

In Nevron Diagram for .NET all documents derive from the NDocument abstract class. It implements the Nevron DOM INDocument interface, in order to compliant with the Nevron DOM abstraction for a document. See the Documents topics for more information.

The NDocument class inherits from System.ComponentModel.Component, which means that it is not directly visible to the user and its existence is not dependant on whether it is used under WinForm or WebForm platform. The DOM implements two types of documents - NDrawingDocument and NLibraryDocument, both sharing the following set of common features:

Services
Documents expose a common set of services (see the Diagram Services topic for more information). The services exposed by each NDocument instance are maintained by an instance of the NServiceManager class, a reference to which can be obtained from the ServiceManager property.

Currently each document registers the following services:

View Management

A single document can be displayed by multiple views. Documents need to know, which views are currently displaying them in order to update them when the document content has changed.

Views call the AddView method in order to register and the RemoveView method in order to unregister from the document. The current set of views displaying a document can be obtained from the Views property.

Document expose three useful methods, which help you perform the most common actions, which each view must implement. These are:

  • RefreshAllViews - causes all views to completely repaint themselves (calls the Refresh method of each registered view).
  • SmartRefreshAllViews - causes all views to repaint only the currently accumulated invalid area (calls the SmartRefresh method of each registered view).
  • UpdateAllViews - causes all views to synchronize themselves with the document (calls the UpdateView method of each registered view).
Data Exchange

Documents can exchange content between themselves or other applications via clipboard, drag and drop or other data exchange methods. The data exchange mechanism uses two corner stone abstractions:

  • Diagram Data Object - represents an atomic diagram unit, which can be transferred across documents. All diagram data objects derive from the NDiagramDataObject abstract class. Diagram data objects can be wrapped in an instance of the System.Windows.Forms.DataObject class.
  • Data Object Adaptor - represents an adaptor for data objects. A data object adaptor can convert data objects of certain format to instances of a concrete diagram data object type. The base class for all data object adaptors is the NDataObjectAdaptor class. The data object adaptors of a document are contained in an instance of the NDataObjectAdaptorCollection class, a reference to which can be obtained from the DataObjectAdaptors property.

Each instancable document can only work with the respective type of diagram data object (for example a NDrawingDocument can only accept NDrawingDataObject). That is why instancable documents are responsible for populating the data object adaptors collection, with the respective type of adaptor.

Since documents only rely on the adaptors to provide an instance of the diagram data object they can work with, you can virtually extend the component to support any type of data object format. The only thing you have to do is to implement an adaptor and add it in the DataObjectAdaptors collection.

Attributes

All documents have the following set of attributes:

  • Document Info - provides user friendly information about the document. Accessible from the Info property.
  • Background Style - controls the appearance of the document background. Accessible from the BackgroundStyle property.
Initializing and Updating Documents

In order to optimize the initialization and update of documents, the NDocument class defines four useful methods: BeginInitEndInit, BeginUpdate and EndUpdate.

Use the BeginInit and EndInit methods to mark the start and end of a document initialization block. These method will internally stop/start all document services and call the BeginUpdate and EndUpdate methods respectively. For example:

C#
Copy Code
document.BeginInit();
// initialize your document here
document.EndInit();
Visual Basic
Copy Code
document.BeginInit()
' initialize your document here
document.EndInit()

You can initialize your documents without calling the BeginInit and EndInit methods, but it is strongly recommended to do so, since this will increase the document initialization performance.

Use the BeginUpdate and EndUpdate methods to mark the start and end of a document update block. These methods will perform document specific optimizations. For example:

C#
Copy Code
document.BeginUpdate();
// update your document here
document.EndUpdate();
Visual Basic
Copy Code
document.BeginUpdate()
' update your document here
document.EndUpdate()

You can update your documents without calling the BeginUpdate and EndUpdate methods, but it is strongly recommended to do so, since this will increase the document update performance.

See Also

 

 


©2017. Nevron Software LLC.

Send Feedback