Back to Devexpress

PdfViewer.CursorMode Property

windowsforms-devexpress-dot-xtrapdfviewer-dot-pdfviewer-089d40f3.md

latest7.3 KB
Original Source

PdfViewer.CursorMode Property

Gets or sets a value that specifies the interaction mode for keyboard and cursor.

Namespace : DevExpress.XtraPdfViewer

Assembly : DevExpress.XtraPdfViewer.v25.2.dll

NuGet Package : DevExpress.Win.PdfViewer

Declaration

csharp
[DefaultValue(PdfCursorMode.SelectTool)]
public PdfCursorMode CursorMode { get; set; }
vb
<DefaultValue(PdfCursorMode.SelectTool)>
Public Property CursorMode As PdfCursorMode

Property Value

TypeDefaultDescription
PdfCursorModeSelectTool

A PdfCursorMode enumeration value.

|

Available values:

NameDescriptionExample
SelectTool

This tool is used for navigation in a document. You can also select text and images in a document to copy using a keyboard and mouse.

|

| | HandTool |

This tool is used for navigation. The end-user can browse the document by moving the mouse while pressing the left button.

|

| | MarqueeZoom |

This tool is used to change the zoom level and navigate in a document. The end-user can increase the zoom level by simply clicking, decrease the zoom level by clicking while pressing the Ctrl key, or zoom in on a portion of a page by dragging the rectangle around it.

|

| | Custom |

The PDF Viewer does not handle mouse and keyboard events. You can handle these events to create your custom interaction tool. To change a cursor, use the PdfViewer.CursorMode property.

| | | TextHighlightTool |

Applies highlight formatting to text.

|

| | TextStrikethroughTool |

Applies strikethrough formatting to text.

|

| | TextUnderlineTool |

Applies underline formatting to text.

|

| | StickyNoteTool |

Creates text annotations (sticky notes).

|

| | FreeTextTool |

Create a free text annotation (a text box).

|

| | CalloutTool |

Create a callout (a combination of a text box and a pointer line to a specific location).

|

|

Remarks

The PDF Viewer does not handle mouse and keyboard events. Set the CursorMode property to Custom and handle these events to create your custom interaction tool.

The code sample below shows how to handle the MouseMove event so that when the cursor hovers over the document’s surface, it appears as follows:

csharp
public partial class Form1 : RibbonForm
{
    Cursor currentCursor = null;

    //This property checks whether the cursor is located within the document's borders
    bool CursorIsOverPage { get { return pdfViewer.IsDocumentOpened && pdfViewer.GetDocumentPosition(pdfViewer.PointToClient(MousePosition), false) != null; } }

    public Form1()
    {
        InitializeComponent();
        pdfViewer.CursorMode = PdfCursorMode.Custom;
        pdfViewer.MouseMove += PdfViewer_MouseMove;
        currentCursor = pdfViewer.Cursor;

    }

    private void PdfViewer_MouseMove(object sender, MouseEventArgs e)
    {
        //Show the No cursor when it hovers over the document
        pdfViewer.Cursor = currentCursor != null && CursorIsOverPage ? Cursors.No : currentCursor;
    }
}
vb
Partial Public Class Form1
    Inherits RibbonForm

    Private currentCursor As Cursor = Nothing

    'This property checks whether the cursor is located within the document's borders
    Private ReadOnly Property CursorIsOverPage() As Boolean
        Get
            Return pdfViewer.IsDocumentOpened AndAlso pdfViewer.GetDocumentPosition(pdfViewer.PointToClient(MousePosition), False) IsNot Nothing
        End Get
    End Property

    Public Sub New()
        InitializeComponent()
        pdfViewer.CursorMode = PdfCursorMode.Custom
        AddHandler pdfViewer.MouseMove, AddressOf PdfViewer_MouseMove
        currentCursor = pdfViewer.Cursor

    End Sub

    Private Sub PdfViewer_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
        'Show the No cursor when it hovers over the document
        pdfViewer.Cursor = If(currentCursor IsNot Nothing AndAlso CursorIsOverPage, Cursors.No, currentCursor)
    End Sub
End Class

The following code snippets (auto-collected from DevExpress Examples) contain references to the CursorMode property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-custom-draw-in-pdf-viewer/CS/PDF_Viewer/Form1.cs#L119

csharp
pdfViewer.Paint += PdfViewer_Paint;
pdfViewer.CursorMode = PdfCursorMode.Custom;
pdfViewer.MouseWheel += PdfViewer_MouseWheel;

winforms-pdf-viewer-redaction-annotations/CS/DXApplication1/Form1.cs#L31

csharp
pdfViewer.Paint += PdfViewer_Paint;
pdfViewer.CursorMode = PdfCursorMode.Custom;
pdfViewer.MouseWheel += PdfViewer_MouseWheel;

how-to-custom-draw-in-pdf-viewer/VB/PDF_Viewer/Form1.vb#L121

vb
AddHandler pdfViewer.Paint, AddressOf PdfViewer_Paint
pdfViewer.CursorMode = PdfCursorMode.Custom
AddHandler pdfViewer.MouseWheel, AddressOf PdfViewer_MouseWheel

winforms-pdf-viewer-redaction-annotations/VB/DXApplication1/Form1.vb#L20

vb
AddHandler pdfViewer.Paint, AddressOf PdfViewer_Paint
pdfViewer.CursorMode = PdfCursorMode.Custom
AddHandler pdfViewer.MouseWheel, AddressOf PdfViewer_MouseWheel

See Also

PdfViewer Class

PdfViewer Members

DevExpress.XtraPdfViewer Namespace