The viewer's model of the annotations, links and form fields on its pages, independent of any UI framework: hit-testing, hover, selection and keyboard focus with page rectangles for the shell to draw; link activation (raised as ActionRequested, never performed); notes and popups; field editing through the form API; and annotation creation, moving and deletion through the annotation API. Every edit redraws only the tiles it touches (Invalidate(Int32, PdfRectangle, DisplayLayers)).
public sealed class AnnotationLayer : IAccessibleElementProvider
Spec #33 viewer capability 6; ISO 32000-2 §12.5 (annotations), §12.6 (actions), §12.7 (interactive forms). The shell maps pointer
positions with TryGetPageAt(in Viewport, Double, Double, out PagePoint), sends PointerDown(in PagePoint), PointerMove(in PagePoint) and
PointerUp(in PagePoint) before its own panning or text selection (a press that returns true is the layer's), and
draws hover, selection and focus from GetScreenRectangle(AnnotationTarget, PageLayout, in Viewport) when Changed fires.
Like the document, the layer is single-threaded: call it from the shell's UI thread. A page takes part once LoadPageAsync(Int32, CancellationToken) has loaded it. Pointer moves allocate nothing.
kind:method, kind:property, kind:ctor. Press Esc to clear.AnnotationLayer(DocumentSession, TileScheduler?)Initializes a new instance of the AnnotationLayer class.DragThresholdHow far, in default user space units, a press must travel on a selected annotation before it drags it.AccessibilityGets or sets the accessibility bridge built over this layer (new AccessibilityBridge(session, layer)), so the layer keeps it current: a value or annotation edit rebuilds the page's accessible nodes, and the layer's keyboard focus moves the bridge's.FocusedGets the annotation with keyboard focus (any role), or null.FocusedFieldGets the field of the focused widget, or null: the shell opens its editor over the widget.HoveredGets the annotation under the pointer, or null.IsDraggingGets whether a press is dragging the selected annotation.PressedGets the annotation a pointer is pressing (from PointerDown(in PagePoint) until PointerUp(in PagePoint) or PointerCancel()), or null: a shell draws it pressed, so a tap on a link or field shows at once. Changed is raised when it changes.SelectedGets the selected annotation (one of role Annotation), or null.SessionGets the session.Activate(AnnotationTarget)Activates an annotation (a click, or Enter on the focused one): a link raises ActionRequested for its destination or each action of its action tree; a widget gets focus, a check box toggles and a radio button turns on (unless read-only), and its own action, if any, is raised; any other annotation is selected.Add(Int32, Func<PdfPage, PdfAnnotation>)Adds an annotation to a loaded page through the annotation API (for example layer.Add(0, page => page.AddSquareAnnotation(rect, options))), redraws its area and selects it.Edit(AnnotationTarget, Action<PdfAnnotation>, Boolean)Edits an annotation (not a widget or a locked one) through its setters and redraws it; the appearance is regenerated after a visual edit (colour, border width, interior colour) unless regenerateAppearance is false.Focus(Nullable<AnnotationTarget>)Gives an annotation keyboard focus, or clears it.FocusNext()Moves keyboard focus to the next annotation in tab order (Tab): within a page in its Tabs order, then on to the next loaded page. The accessibility seam: a screen-reader shell follows Focused and reads GetAccessibleName(AnnotationTarget).FocusPrevious()Moves keyboard focus to the previous annotation in tab order (Shift+Tab), as FocusNext() describes.GetAccessibleName(AnnotationTarget)Gets a short text naming an annotation for assistive technology: a field's alternate name (TU) or name, else the annotation's Contents, else a link's URI, else its subtype.GetAnnotation(AnnotationTarget)Gets an annotation.GetCount(Int32)Gets how many annotations of a page take part: 0 until LoadPageAsync(Int32, CancellationToken) loaded it.GetDestinationViewport(PdfExplicitDestination, PageLayout, in Viewport)Works out the viewport that shows a destination: its page scrolled to, then its left and top edge (XYZ, FitH, FitV, FitR and the bounding-box forms) at the viewport's top-left corner when it has them. The zoom is kept.GetElements(PdfPage, Int32, ICollection<AccessibleElement>)Lists a page's links, form fields and markup annotations (comments) as accessible elements in keyboard focus order (GetFocusOrder(Int32, Span<AnnotationTarget>)), each named by GetAccessibleName(AnnotationTarget), with a field's value and its checked, read-only and required states; the source is the annotation's dictionary (stable across edits). Links with a structure parent are left out: a tagged page's content already has them as Link nodes.GetFocusOrder(Int32, Span<AnnotationTarget>)Lists a loaded page's annotations in tab order.GetNote(AnnotationTarget)Gets an annotation's note: its text, author, popup and replies.GetRectangle(AnnotationTarget)Gets an annotation's rectangle (Rect) in its page's default user space.GetRole(AnnotationTarget)Gets what an annotation does when activated.GetScreenRectangle(AnnotationTarget, PageLayout, in Viewport)Gets where to draw an annotation's hover, selection or focus chrome, in viewport pixels: its rectangle, moved along while it is dragged.HitTest(in PagePoint)Finds the topmost annotation at a point: links by their activation region (QuadPoints, else Rect), others by Rect, edges included.LoadPageAsync(Int32, CancellationToken)Loads (once) a page's annotations into the layer.Move(AnnotationTarget, Double, Double)Moves an annotation (not a widget or a locked one) and redraws where it was and where it is.PointerCancel()Abandons a press: a drag in progress snaps back.PointerDown(in PagePoint)A press: on an annotation, selects it (and may start dragging it); on a widget, focuses its field. Links and widgets activate on PointerUp(in PagePoint) over the same annotation.PointerMove(in PagePoint)A pointer move: drags the selected annotation while a press on it lasts, otherwise updates Hovered.PointerUp(in PagePoint)A release: ends a drag by moving the annotation (Move(Double, Double)), or activates the pressed link or widget when released over it (Activate(AnnotationTarget)).Remove(AnnotationTarget)Removes an annotation (not a widget or a locked one), with its popup and replies, and redraws the page's annotations.Select(Nullable<AnnotationTarget>)Selects an annotation, or clears the selection.SetFieldChoice(String?)Sets the focused choice field's value (an option's export value or text; any text in an editable combo box).SetFieldSelection(IEnumerable<Int32>)Selects options of the focused choice field by index (several in a multi-select list box).SetFieldText(String?)Sets the focused text field's value and redraws its widgets.ToggleField()Toggles the focused check box, or turns on the focused radio button (Space).ActionRequestedRaised for each action of an activated link or widget, in execution order. The viewer performs none: go-tos are navigated by the shell, URIs and other files opened only after asking the user, and scripts never run (IsScript).ChangedRaised when the hovered, selected or focused annotation changes, or a dragged annotation moves: redraw the chrome.InvalidatedRaised after an edit changed what part of a page draws (also passed to the scheduler, when there is one).