Back to Devexpress

Cursor Modes

windowsforms-120685-controls-and-libraries-pdf-viewer-visual-elements-cursor-modes.md

latest5.0 KB
Original Source

Cursor Modes

  • Dec 02, 2024
  • 3 minutes to read

The PDF Viewer has the following cursor modes:

ModeExampleDescriptionHow to Activate
Select ToolUsed to select text and images in a document.Right-click within the document and select Select Tool in the context menu or set the PdfViewer.CursorMode property to SelectTool.
Hand ToolUsed for navigation. Move the mouse while pressing the left button to navigate through the document. After you click the document’s page, the mouse pointer changes from to . Drag the mouse pointer to scroll the document.Right-click within the document and select Hand Tool in the context menu or set the PdfViewer.CursorMode property to HandTool.
Marquee Zoom ToolUsed to change the zoom level and view a particular part of the page. Click to increase the zoom level, or click while pressing the Ctrl key to decrease the zoom level. Drag a rectangle around the page portion to zoom in on it.Right-click within the document and select Marquee Zoom in the context menu or set the PdfViewer.CursorMode property to MarqueeZoom.
Text Markup ToolsUsed to highlight, underline or strike out text.Click one of the Text ribbon group buttons on the Comment tab or set the PdfViewer.CursorMode to TextHighlightTool, TextStrikethroughTool, or TextUnderlineTool.
Text Annotation ToolsUsed to create text annotations (sticky notes), free text annotations (text boxes), and callouts (text boxes with pointer lines).Click Sticky Note , Free Text , or Callout on the Comment ribbon tab or set the PdfViewer.CursorMode to StickyNoteTool, FreeTextTool, or CalloutTool.

Create Custom Interaction Tool

Handle mouse and keyboard events to create a custom interaction tool.

The following code sample handles the MouseMove event to change the appearance of the mouse pointer over different parts of the document’s surface:

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