Diagram for .NET / User's Guide / WinForm Components / Views

In This Topic
    Views
    In This Topic

    In WinForms the diagram documents are displayed and edited with the help of views. All types of views derive from the base NView abstract class, which is on its turn derived from System.Windows.Forms.Control class.

    All views share the common set of features:

     Scene and Viewport

    The view is designed to display a scene, which is typically composed by the merged view and displayed document content.

    The first visible point of the scene is controlled by the ViewportOrigin property. The device point to which the viewport origin is mapped is accessible from the WindowOrigin property. You can scroll the scene by changing the viewport origin.

    The rectangular area of the scene, which is currently displayed by the view is called viewport and can be obtained from the Viewport property. The viewport is always measured in scene coordinates.

    The rectangular area of the view, which displays the viewport is called window and can be obtained from the Window property. The window is always measured in device (client) coordinates.

     Selection

    The selection contains the current set of manipulated document elements. It is represented by an instance of the NSelection class, which is accessible from the Selection property.

    See Selection for more information.

     Controller

    The controller is an extensible processor of mouse, keyboard and drag and drop events. The controller is represented by an instance of the NController class, which is accessible from the Controller property.

    All user events, which the view receives are delegated to the controller for processing. The controller hosts a collection of tools, which determine the current view behavior. It is up to derived views to determine what type and configuration of tools the controller must possess.

    See Controller for more information.

     Scrolling and Panning

    Views add basic support for scrolling and panning of the scene they display.

    Each view has two scrollbars - horizontal and vertical, which are automatically displayed, if the scene is too large to be displayed in the view. You can however specify, which scrollbars need to be displayed with the help of the ScrollBars property of the view. The small scroll change is controlled by the SmallScrollChange property. The large scroll change is by design always equal to the current window size.

    In cases when some drag operation is performed in the view, it will automatically scroll if the mouse pointer is positioned near to the window bounds. This feature is called auto scrolling, and its aspects can be controlled by an instance of the NAutoScroller attribute, which is accessible from the AutoScroller property.

     View Scene

    The view also hosts a scene, the purpose of which is to provide easy and native decoration of the document, which is displayed in the view. Unlike the scene of the document, which is built from elements, the scene of the view is built from nodes. In this way it is lighter from the document scene, but if needed it can host and display document elements.

    The scene of every view is divided in two layers:

    • Content layer - in this layer the view stores it's primary content. For example: drawing views use it to store their trackers, while library views use it to store library view items representing the library document masters.
    • Preview layer - in this layer the view stores dynamically generated previews.
     Hit tests

    Declared by NView are several types of hit tests, which each instancable view must support. These are:

    • Selection hit tests - these methods hit test only the document elements, which are currently selected:
      Method Description
      HitTestSelection hit test the selected elements by point
      HitTestSelection hit test the selected elements by rect
    • View hit tests - these methods hit test the entire view scene:
      Method Description
      HitTest hit test the view scene by point
      HitTest hit test the view scene by rect
      LastHit gets the last hit view node by point
    • View content hit tests - these methods hit test only the members of the view content layer:
      Method Description
      HitTestViewContent hit tests by point only the nodes in the view content layer
      HitTestViewContent hit tests by rect only the nodes in the view content layer
      LastViewContentHit gets the last hit node, which resides in the view content layer
     Render Technology

    The view object has a property called RenderTechnology which allows you to specify the technology used for rendering the diagram document in the view. The following code snippet shows how to change the render technology:

    Setting Render Technology
    Copy Code
    view.RenderTechnology = RenderTechnology.OpenGLHardware;
    RenderTechnology Description
    GDIPlus This is the default render technology. It has adequate rendering speed in most casees, but cannot leverage the video board in the way OpenGLHardware can, which is useful when the view is large or the diagram document contains many shapes.
    OpenGLSoftware This render technology is provided only for testing purposes. In most cases you need to use OpenGLHardware.
    OpenGLHardware This is the fastest rendering mode, which is useful when the view is large or the diagram document contains many shapes. Certain features like image filters are not supported in this mode.

     

    See Also