Class ToolManager
The ToolManager class will attach itself to a PDFViewCtrl and provides a lot of interactive features,
such as text selection, annotation creation and editing, and form filling.
It is important to Dispose the ToolManager when it is no longer needed. This is because it subscribes
to certain events in the PDFViewCtrl that will prevent both the PDFViewCtrl and the ToolManager from
being reclaimed by garbage collection.
Inheritance
System.Object
ToolManager
Assembly: pdftron.PDF.Tools.dll
public sealed class ToolManager : IDisposable
Constructors
Declaration
public ToolManager(PDFViewCtrl ctrl)
Parameters
Type |
Name |
Description |
PDFViewCtrl |
ctrl |
|
Fields
Declaration
public double INK_MARGIN_FOR_STARTING_NEW_ANNOTATION
Field Value
Type |
Description |
System.Double |
|
Declaration
public double INK_TIME_BEFORE_INK_SAVES_ANNOTATION_IN_MILLISECONDS
Field Value
Type |
Description |
System.Double |
|
Declaration
public double MOVE_THRESHOLD_TO_START_SCROLL
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_FINGER_HIT_TESTING_MARGIN
Declaration
public static double TEXT_SELECT_FINGER_HIT_TESTING_MARGIN
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_HARD_MARGIN_X
Declaration
public double TEXT_SELECT_SCROLL_HARD_MARGIN_X
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_HARD_MARGIN_Y
Declaration
public double TEXT_SELECT_SCROLL_HARD_MARGIN_Y
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_SOFT_MARGIN_X
Declaration
public double TEXT_SELECT_SCROLL_SOFT_MARGIN_X
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_SOFT_MARGIN_Y
Declaration
public double TEXT_SELECT_SCROLL_SOFT_MARGIN_Y
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_SPEED_MULTIPLIER_IF_POST_MARGIN_X
Declaration
public double TEXT_SELECT_SCROLL_SPEED_MULTIPLIER_IF_POST_MARGIN_X
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_SPEED_MULTIPLIER_IF_POST_MARGIN_Y
Declaration
public double TEXT_SELECT_SCROLL_SPEED_MULTIPLIER_IF_POST_MARGIN_Y
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_SPEED_X
Declaration
public double TEXT_SELECT_SCROLL_SPEED_X
Field Value
Type |
Description |
System.Double |
|
TEXT_SELECT_SCROLL_SPEED_Y
Declaration
public double TEXT_SELECT_SCROLL_SPEED_Y
Field Value
Type |
Description |
System.Double |
|
Properties
Gets or sets whether an author should be added. Will open the author dialog if none is entered yet.
Declaration
public bool AddAuthorToAnnotations { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets what types of actions the tool will activate. Defaults to All
Declaration
public ToolManager.AllowedLinks AllowedLinkActions { get; set; }
Property Value
The name under which the tools store the author name in the ApplicationData.Current.RoamingSettings container.
Declaration
public static string AnnotationAuthorNameSettingsString { get; }
Property Value
Type |
Description |
System.String |
|
Create an instance of IAuthorDialog and set it here to overwrite the default the tools are using.
Declaration
public IAuthorDialog AuthorDialog { get; set; }
Property Value
CopyAnnotatedTextToNote
Gets or sets whether annotating text will autimatically copy the contents into the
text markup's note.
Declaration
public bool CopyAnnotatedTextToNote { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets the currently active tool.
Declaration
public Tool CurrentTool { get; }
Property Value
Declaration
public static string DebugAnnotationAuthorHasBeenAskedSettingsString { get; }
Property Value
Type |
Description |
System.String |
|
Gets or sets the DocumentName as the user of the ToolManager wants it displayed.
If null, the tools will use PDFDoc.GetFileName()
Useful when a temp file with a generic name is used.
Declaration
public string DocumentName { get; set; }
Property Value
Type |
Description |
System.String |
|
Gets or sets whether or not the tools will show a popup menu
when the user long presses with their finger. This will only happen while using the pan tool.
Declaration
public bool EnablePopupMenuOnLongPress { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
HasSelectedText
True if there currently is text selected as a result of the Tools.
Declaration
public bool HasSelectedText { get; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets when ink should be smoothed when finished.
Declaration
public ToolManager.InkSmoothingOptions InkSmoothingBehaviour { get; set; }
Property Value
Check if AnnotManager is enabled
Declaration
public bool IsAnnotManagerEnabled { get; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets whether or not the ToolManager will react to events from the PDFViewCtrl.
Declaration
public bool IsEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Declaration
public bool IsOnPhone { get; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets whether or not the tools will use the popup menu.
If set to false, it is up to users to modify the tools so that they can
be used with, for example, the app bar. Defaults to true.
Declaration
public bool IsPopupMenuEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or Sets whether the Signature Dialog should be displayed on Full Screen
or reduced size
Declaration
public bool IsSignatureDialogFullScreen { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or Sets whether the Sound Annotation creation is enabled or not
Declaration
public bool IsSoundAnnotEnabled { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets the ToolManager navigation stack. If not null, the Tools will use the
NavigationStack for navigation, like following links.
Declaration
public NavigationStack NavigationStack { get; set; }
Property Value
PageNumberIndicator
This is a small UI widget that displays a the current page number.
Declaration
public PageNumberIndicator PageNumberIndicator { get; }
Property Value
PanToolTextSelectionMode
Set whether click and drag actions should select text or pan the view.
Declaration
public ToolManager.TextSelectionBehaviour PanToolTextSelectionMode { get; set; }
Property Value
Gets or sets whether or not the author dialog should pop up the first time the user adds an annotations.
Declaration
public bool PopupAuthorDialogFirstTime { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets a FrameworkElement that will be used by the PDFViewCtrl tools as the acceptable area on which to target
Declaration
public FrameworkElement PopupLimitingTarget { get; set; }
Property Value
Type |
Description |
Windows.UI.Xaml.FrameworkElement |
|
Gets or sets whether read-only mode should be enabled.
In read only mode, annotations cannot be added, edited, or deleted.
Declaration
public bool ReadOnlyMode { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets the currently selected annotation.
If no annotation is selected, this is null.
Declaration
public IAnnot SelectedAnnotation { get; }
Property Value
SelectedAnnotationPageNumber
Gets the page number of the currently selected annotation.
If no annotation is selected, this number is 0.
Declaration
public int SelectedAnnotationPageNumber { get; }
Property Value
Type |
Description |
System.Int32 |
|
Gets or Sets Whether to allow displaying a default (previously saved) signature
Declaration
public bool ShowDefaultSignature { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets or sets whether the stylus should pan or ink as the default state
Declaration
public bool StylusAsPen { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
TextMarkupAdobeHack
Gets or sets whether the TextMarkup annotations are compatible with Adobe
(Adobe's quads don't follow the specification, but they don't handle quads that do).
Declaration
public bool TextMarkupAdobeHack { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Gets the UndoRedoManger. UndoRedoManger contains API for Undo / Redo operation.
Declaration
public IUndoRedoManager UndoRedoAction { get; }
Property Value
UseSmallPageNumberIndicator
This tells the Tools to use a smaller page number indicator.
If true, the page number indicator will be smaller and will only contain the current page number,
but not the total number of pages.
Declaration
public bool UseSmallPageNumberIndicator { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
Apply redaction to all Redaction Annotations present in the document
Declaration
public void ApplyRedaction(bool overlayText)
Parameters
Type |
Name |
Description |
System.Boolean |
overlayText |
Turn on/off displaying text overlay
|
Closes any open dialog the Tools have open.
User this to handle things like back buttons.
Declaration
public bool CloseOpenDialog(bool all = false)
Parameters
Type |
Name |
Description |
System.Boolean |
all |
Closes all open dialogs if true, otherwise only 1 (in case there are nested ones).
|
Returns
Type |
Description |
System.Boolean |
|
Declaration
Returns
Type |
Description |
System.Boolean |
|
Creates the default tool (the Pan tool).
Declaration
public void CreateDefaultTool()
Declaration
public MagnifyingTool CreateMagnifyingTool()
Returns
Declaration
public Tool CreateTool(ToolType mode, Tool current_tool)
Parameters
Returns
Declaration
public Tool CreateTool(ToolType mode, Tool current_tool, bool toolIsPersistent)
Parameters
Type |
Name |
Description |
ToolType |
mode |
|
Tool |
current_tool |
|
System.Boolean |
toolIsPersistent |
|
Returns
Creates a new tool based on one of the strings from GetAnnotationCreationOptions()
Declaration
public void CreateTool(string title)
Parameters
Type |
Name |
Description |
System.String |
title |
|
Declaration
public void CreateTool(string title, bool toolIsPersistent)
Parameters
Type |
Name |
Description |
System.String |
title |
|
System.Boolean |
toolIsPersistent |
|
Delete the annotation passed if it exists
Declaration
public void DeleteAnnotation(PDFViewCtrl pdfViewCtrl, IAnnot selectedAnnotation, int pageNumber)
Parameters
Type |
Name |
Description |
PDFViewCtrl |
pdfViewCtrl |
the active PDF View Control
|
IAnnot |
selectedAnnotation |
the currently selected annotation to be deleted
|
System.Int32 |
pageNumber |
the page number that contains the selected annotation
|
Disposes the ToolManager. Always perform this when the ToolManager is not needed anymore.
The ToolManager is subscribed to events on the PDFViewCtrl that prevent it from being reclaimed.
Therefore it is very important to dispose the ToolManager, so that it can unsubscribe to these events.
Declaration
Enables annotation manager for annotation syncing
Declaration
public void EnableAnnotManager(string userId)
Parameters
Type |
Name |
Description |
System.String |
userId |
|
Declaration
protected void Finalize()
Gets the list of options that are normally displayed when the user taps on blank space
in the PDFViewCtrl (i.e. no annotation or text).
Declaration
public IList<string> GetAnnotationCreationOptions()
Returns
Type |
Description |
IList<System.String> |
|
Get AnnotManager instance. Make sure to check if it is already enabled
Declaration
public AnnotManager GetAnnotManager()
Returns
Get the PDFViewCtrl which this ToolManager is attached to
Declaration
public PDFViewCtrl GetPDFViewCtrl()
Returns
Type |
Description |
PDFViewCtrl |
PDFViewCtrl instance
|
GetSelectedText()
Declaration
public string GetSelectedText()
Returns
Type |
Description |
System.String |
|
Declaration
public void KeyDownHandler(object sender, KeyRoutedEventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
Windows.UI.Xaml.Input.KeyRoutedEventArgs |
e |
|
Declaration
public void KeyUpHandler(object sender, KeyRoutedEventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
Windows.UI.Xaml.Input.KeyRoutedEventArgs |
e |
|
Select the annotation passed if it exists in the page number and displays the
context menu
NOTE: only works with IMarkup style of annotations
Declaration
public void SelectAnnotation(IAnnot annotation, int pageNumber)
Parameters
Type |
Name |
Description |
IAnnot |
annotation |
the annotation to be selected
|
System.Int32 |
pageNumber |
the page number where the annotation lives
|
Select all annotations part of the same group of annotation
Note: the annotation must be part of a annotation group in order to select it
Declaration
public void SelectAnnotationGroup(IAnnot annotation, int pageNumber)
Parameters
Type |
Name |
Description |
IAnnot |
annotation |
The annotation part of a group
|
System.Int32 |
pageNumber |
The page number where the annotation is located
|
Attach UndoRedoManager to the ToolManager
Declaration
public void SetUndoRedoManager(IUndoRedoManager undoRedoManager = null)
Parameters
Type |
Name |
Description |
IUndoRedoManager |
undoRedoManager |
IUndoRedoManager instance
|
Makes the ToolManager unselect all annotations.
Declaration
public void UnselectAllAnnotations()
Events
This event is fired when an annotation has been added to a document
Declaration
public event ToolManager.AnnotationModificationHandler AnnotationAdded
Event Type
This event is raised whenever an annotation on the current document has been edited
Declaration
public event ToolManager.AnnotationModificationHandler AnnotationEdited
Event Type
This event is fired when an annotation group has been added to a document
Declaration
public event ToolManager.AnnotationGroupModificationHandler AnnotationGroupAdded
Event Type
This event is raised whenever an annotation group on the current document has been edited
Declaration
public event ToolManager.AnnotationGroupModificationHandler AnnotationGroupEdited
Event Type
This event is raised whenever an annotation group on the current document is about to be edited
Declaration
public event ToolManager.AnnotationGroupModificationHandler AnnotationGroupPreEdited
Event Type
This event is raised just before an annotation group is deleted from the document.
At this point, the annotation group is still part of the document.
Declaration
public event ToolManager.AnnotationGroupModificationHandler AnnotationGroupPreRemoved
Event Type
This event is raised whenever an annotation group has been deleted from the document
Declaration
public event ToolManager.AnnotationGroupModificationHandler AnnotationGroupRemoved
Event Type
This event is raised just before an annotation is deleted from the document.
At this point, the annotation is still part of the document.
Declaration
public event ToolManager.AnnotationModificationHandler AnnotationPreRemoved
Event Type
This event is raised whenever an annotation has been deleted from the document
Declaration
public event ToolManager.AnnotationModificationHandler AnnotationRemoved
Event Type
This event is raised when the tools perform a save-as option. This happens when the users signs a
form. This event will provide the file the user chose to save the doc in, and should in the future
be used by the app when the user wants to save the document.
Declaration
public event OnFileChanged FileHasChanged
Event Type
This even is raised every time a new tool is created.
The type of the new tools is passed as a parameter.
Declaration
public event NewToolCreatedDelegate NewToolCreated
Event Type
This event is raised before displaying the context menu.
Declaration
public event ToolManager.ShowingContextMenuHandler OnShowContextMenu
Event Type
Declaration
public event ToolManager.ShowingPopupMenuHandler OnShowPopupMenu
Event Type
Event is raised when user selects sound annotation (Mic) on the Context Menu
Declaration
public event ToolManager.SoundAnnotCreateHandler OnSoundAnnotRequested
Event Type
This event is raised when annotations are selected or deselected by the editing tools
Declaration
public event ToolManager.AnnotationModificationHandler SelectionChanged
Event Type
This event is raised when annotation group is selected or deselected by the editing tools
Declaration
public event ToolManager.AnnotationGroupModificationHandler SelectionGroupChanged
Event Type
Declaration
public event ToolManager.InterceptAnnotationHandler ShouldHandleLinkAnnotation
Event Type
This event is raised when the ToolManager receives tap events.
Before the tools handle the event, BeforeTool is raised.
Once a single tap is confirmed (i.e. not part of a double tap)
SingleTapConfirmed is raised
Declaration
public event SingleTapDelegate SingleTap
Event Type
TextToSpeechActivated
Declaration
public event ToolManager.TextToSpeechDelegate TextToSpeechActivated
Event Type
This event is raised every time undo and redo manager has
made a change
Declaration
public event UndoRedoStatusChangedDelegate UndoRedoStatusChanged
Event Type