This topic has not yet been rated - Rate this topic

AnnotationService Class

Provides core services of the Microsoft Annotations Framework to manage and display user annotations.

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.Annotations.AnnotationService

Namespace:  System.Windows.Annotations
Assembly:  PresentationFramework (in PresentationFramework.dll)
public sealed class AnnotationService : DispatcherObject

The AnnotationService type exposes the following members.

  Name Description
Public method AnnotationService(DocumentViewerBase) Initializes a new instance of the AnnotationService class for use with a specified DocumentViewer or FlowDocumentPageViewer control.
Public method AnnotationService(FlowDocumentReader) Initializes a new instance of the AnnotationService class for use with a specified FlowDocumentReader control.
Public method AnnotationService(FlowDocumentScrollViewer) Initializes a new instance of the AnnotationService class for use with a specified FlowDocumentScrollViewer control.
Top
  Name Description
Public property Dispatcher Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public property IsEnabled Gets a value that indicates whether the AnnotationService is enabled.
Public property Store Gets the AnnotationStore used by this AnnotationService.
Top
  Name Description
Public method CheckAccess Determines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public method Disable Disables annotations processing and hides all visible annotations.
Public method Enable Enables the AnnotationService for use with a given AnnotationStore and displays all visible annotations.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Static member GetService(DocumentViewerBase) Returns the AnnotationService instance associated with a specified document viewing control.
Public method Static member GetService(FlowDocumentReader) Returns the AnnotationService associated with a specified FlowDocumentReader.
Public method Static member GetService(FlowDocumentScrollViewer) Returns the AnnotationService associated with a specified FlowDocumentScrollViewer.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Public method VerifyAccess Enforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top
  Name Description
Public field Static member ClearHighlightsCommand Represents the command to clear highlight annotations from the current selection.
Public field Static member CreateHighlightCommand Represents the command to create a highlight annotation on the current selection.
Public field Static member CreateInkStickyNoteCommand Represents the command to create an ink-note annotation on the current selection.
Public field Static member CreateTextStickyNoteCommand Represents the command to create a text-note annotation on the current selection.
Public field Static member DeleteAnnotationsCommand Represents the command to delete all ink-note, text-note, and highlight annotations in the current selection.
Public field Static member DeleteStickyNotesCommand Represents the command to delete all ink-note and text-note annotations in the current selection.
Top

The following example shows how to create and start an AnnotationService.


// ------------------------ StartAnnotations --------------------------
/// <summary>
///   Enables annotations and displays all that are viewable.</summary>
private void StartAnnotations()
{
    // If there is no AnnotationService yet, create one.
    if (_annotService == null)
        // docViewer is a document viewing control named in Window1.xaml.
        _annotService = new AnnotationService(docViewer);

    // If the AnnotationService is currently enabled, disable it.
    if (_annotService.IsEnabled == true)
        _annotService.Disable();

    // Open a stream to the file for storing annotations.
    _annotStream = new FileStream(
        _annotStorePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);

    // Create an AnnotationStore using the file stream.
    _annotStore = new XmlStreamStore(_annotStream);

    // Enable the AnnotationService using the new store.
    _annotService.Enable(_annotStore);
}// end:StartAnnotations()


.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ