Nevron .NET Vision
Diagram for .NET / User's Guide / WinForm Components / Pan and Zoom Control

In This Topic
    Pan and Zoom Control
    In This Topic

    The pan and zoom control is represented by the NPanAndZoomControl class. In essence it is a control, which provides a bird's-eye view of the document edited in another view (called master view) and also provides you with an easy and intuitive way to zoom and pan the master view. Pan and zoom control appears in the Visual Studio toolbox. It is represented by the following item:

     Master View

    The most important property of this control is the MasterView property, which specifies the view which is being observed by it:

    C#
    Copy Code
    // set the master view
    panAndZoom.MasterView = someView;
    
    Visual Basic
    Copy Code
    ' set the master view
    panAndZoom.MasterView = someView
    
     Zooming the Master View

    The zooming of the master view is achieved with the help of the zoom navigator, which is by default displayed on the right side of the master view preview. The zoom navigator has three controls: zoom-in button, zoom-out button and zoom-trackbar. It is important to know that these controls are synchronized with the settings of the document, which is displayed by the master view in the following way:

    1. The zoom in and zoom out buttons, zoom the master view in and out with the master view document settings ZoomStep parameter.

    2. The min and max values of the zoom trackbar are synchronized with the MinZoomFactor and MaxZoomFactor properties of the document settings attribute.

    3. The zoom trackbar small change is set to the ZoomStep parameter. The large trackbar change is calculated by multiplying the small change with the value of the LargeZoomChangeFactor property, which must be greater than 1.

    You can show/hide the zoom navigator with the help of the ShowZoomNavigator property.

    C#
    Copy Code
    // hide the zoom navigator
    panAndZoom.ShowZoomNavigator = false;
    
    Visual Basic
    Copy Code
    ' hide the zoom navigator
    panAndZoom.ShowZoomNavigator = False
    
     Panning the Resizing the Master View

    The panning of the master view is achieved by dragging the viewport band in the pan and zoom window. The resizing of the master view viewport (i.e. zoom to rectangle) is achieved by dragging the corners or the sides of the viewport band. The viewport band is represented by an instance of the NViewportBand class and is accessible with the following code:

    C#
    Copy Code
    // get a reference to the viewport band
    NViewportBand viewportBand = panAndZoomControl.ViewportPreview.Band; 
    
    Visual Basic
    Copy Code
    ' get a reference to the viewport band
    Dim viewportBand As NViewportBand = panAndZoomControl.ViewportPreview.Band
    
     Related Examples
    Windows Forms: Visual Interface Components - Pan and Zoom (Overview)
    See Also