Provides support for using the mouse or touch to click on page links and invoke their targets.
public class DocumentViewerPageLinksInteractiveMode : ImageViewerInteractiveMode
Public Class DocumentViewerPageLinksInteractiveMode
ref class DocumentViewerPageLinksInteractiveMode : ImageViewerInteractiveMode
Each link is of type DocumentLink that contain the LinkType property that specifies if the the target of the link is another location in the same page or document, or if the target is an external value (such as a hyperlink).
As well as the type, each link contains Bounds that specifies the location and size in the page in document coordinates.
In typical document viewing applications, the links should show an indication when the user hover over them with the mouse, such as changing the mouse cursor to a "hand". Also, when the user clicks on the link, the default action should invoked if possible, such as going to the target location specified by the link in the document.
This mode supports running links only when the user clicks over an item while pressing down a keyboard modifier through RunLinkKeyModifier. The default value is System.Windows.Forms.Keys. But can modify if needed - for example, set it to System.Windows.Forms.Keys to mimic how Microsoft Word perform clicking on links embedded in a document.
DocumentViewerPageLinksInteractiveMode is an interactive mode that can handle the actions described above automatically. It will change the mouse cursor (when the platform supports them) to a "Hand" when the user hovers over the links and when the user clicks on them, it will inform the user and optionally invoke the action specified by the link automatically if the target was a location in the document.
This mode works as follows:
At any time, the mode uses the Bounds property of the links in the current page to determine if the mouse or touch event is on a link. If this is true, then it will set the IsHandled value to true. This allows this mode to work in cooperation with the other interactive modes currently in the view ImageViewer and is only activated when the user hovers over or clicks a link. Therefore, this mode is added by the DocumentViewer automatically upon creation. It is always enabled and the user does not have to switch it off for normal operations if links support is required. If this support is not needed, then this move can be either disabled (IsEnabled) or removed completely from the InteractiveModes list of ImageViewer.
Uses the Move event when the platform supports a mouse to track when the user hovers the cursor over a link. The Operation will fire with DocumentViewerOperation object hovered over is in Data1. If the user moved the cursor out of any links, then the value of Data1 will be null. The operation will occur first with the value of IsPostOperation set to false and then true as usual. In all case, the interactive event data (InteractiveEventArgs) for the current mouse or touch move operation will be in Data2 to get the current cursor position if needed). This operation along with RunLinkKeyModifier allows application program to create rich user experience for links, such us showing the link value in a tooltip window with help on how to run the link similar to Microsoft Word or Adobe Acrobat.
Uses the DragStarted event to check if the user clicks the mouse or taps over a link bounds, when this occurs, the following happens:
The Operation will fire with DocumentViewerOperation.RunLink, the DocumentLink object being clicked in Data1 and the value of IsPostOperation to false. The user can intercept this event and set the value of Abort to true to indicate that the application handled this event and stops the mode from continuing to the next step. In all cases, the interactive event data (InteractiveEventArgs) for the current mouse or touch down operation will be in Data2 to get the current cursor position if needed).
If the user did not abort the action, this mode will check the value of LinkType. If the value is DocumentLinkType is called with Target. This will move the view to the specified page of the link and perform the fit and zoom percentage specified.