Share via


AnnotationService Konstruktoren

Definition

Initialisiert eine neue Instanz der AnnotationService-Klasse für ein angegebenes Dokumentanzeigesteuerelement.

Überlädt

AnnotationService(FlowDocumentReader)

Initialisiert eine neue Instanz der AnnotationService-Klasse für die Verwendung mit einem angegebenen FlowDocumentReader-Steuerelement.

AnnotationService(FlowDocumentScrollViewer)

Initialisiert eine neue Instanz der AnnotationService-Klasse für die Verwendung mit einem angegebenen FlowDocumentScrollViewer-Steuerelement.

AnnotationService(DocumentViewerBase)

Initialisiert eine neue Instanz der AnnotationService-Klasse für die Verwendung mit einem angegebenen DocumentViewer- oder einem angegebenen FlowDocumentPageViewer-Steuerelement.

Beispiele

Das folgende Beispiel zeigt die Verwendung des AnnotationService Konstruktors.

// ------------------------ 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()
' ------------------------ StartAnnotations --------------------------
''' <summary>
'''   Enables annotations and displays all that are viewable.</summary>
Private Sub StartAnnotations()
    ' If there is no AnnotationService yet, create one.
    If _annotService Is Nothing Then
        ' docViewer is a document viewing control named in Window1.xaml.
        _annotService = New AnnotationService(docViewer)
    End If

    ' If the AnnotationService is currently enabled, disable it.
    If _annotService.IsEnabled = True Then
        _annotService.Disable()
    End If

    ' 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 Sub

Hinweise

Kann AnnotationService mit den folgenden Steuerelementen für die Dokumentanzeige verwendet werden:

AnnotationService(FlowDocumentReader)

Initialisiert eine neue Instanz der AnnotationService-Klasse für die Verwendung mit einem angegebenen FlowDocumentReader-Steuerelement.

public:
 AnnotationService(System::Windows::Controls::FlowDocumentReader ^ viewer);
public AnnotationService (System.Windows.Controls.FlowDocumentReader viewer);
new System.Windows.Annotations.AnnotationService : System.Windows.Controls.FlowDocumentReader -> System.Windows.Annotations.AnnotationService
Public Sub New (viewer As FlowDocumentReader)

Parameter

viewer
FlowDocumentReader

Das dem AnnotationService zugeordnete Steuerelement zum Lesen des Dokuments.

Beispiele

Das folgende Beispiel zeigt die Verwendung des AnnotationService Konstruktors.

// ------------------------ 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()
' ------------------------ StartAnnotations --------------------------
''' <summary>
'''   Enables annotations and displays all that are viewable.</summary>
Private Sub StartAnnotations()
    ' If there is no AnnotationService yet, create one.
    If _annotService Is Nothing Then
        ' docViewer is a document viewing control named in Window1.xaml.
        _annotService = New AnnotationService(docViewer)
    End If

    ' If the AnnotationService is currently enabled, disable it.
    If _annotService.IsEnabled = True Then
        _annotService.Disable()
    End If

    ' 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 Sub

Weitere Informationen

Gilt für:

AnnotationService(FlowDocumentScrollViewer)

Initialisiert eine neue Instanz der AnnotationService-Klasse für die Verwendung mit einem angegebenen FlowDocumentScrollViewer-Steuerelement.

public:
 AnnotationService(System::Windows::Controls::FlowDocumentScrollViewer ^ viewer);
public AnnotationService (System.Windows.Controls.FlowDocumentScrollViewer viewer);
new System.Windows.Annotations.AnnotationService : System.Windows.Controls.FlowDocumentScrollViewer -> System.Windows.Annotations.AnnotationService
Public Sub New (viewer As FlowDocumentScrollViewer)

Parameter

viewer
FlowDocumentScrollViewer

Das dem AnnotationService zugeordnete Dokumentanzeigesteuerelement.

Ausnahmen

viewer ist null.

Beispiele

Das folgende Beispiel zeigt die Verwendung des AnnotationService Konstruktors.

// ------------------------ 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()
' ------------------------ StartAnnotations --------------------------
''' <summary>
'''   Enables annotations and displays all that are viewable.</summary>
Private Sub StartAnnotations()
    ' If there is no AnnotationService yet, create one.
    If _annotService Is Nothing Then
        ' docViewer is a document viewing control named in Window1.xaml.
        _annotService = New AnnotationService(docViewer)
    End If

    ' If the AnnotationService is currently enabled, disable it.
    If _annotService.IsEnabled = True Then
        _annotService.Disable()
    End If

    ' 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 Sub

Weitere Informationen

Gilt für:

AnnotationService(DocumentViewerBase)

Initialisiert eine neue Instanz der AnnotationService-Klasse für die Verwendung mit einem angegebenen DocumentViewer- oder einem angegebenen FlowDocumentPageViewer-Steuerelement.

public:
 AnnotationService(System::Windows::Controls::Primitives::DocumentViewerBase ^ viewer);
public AnnotationService (System.Windows.Controls.Primitives.DocumentViewerBase viewer);
new System.Windows.Annotations.AnnotationService : System.Windows.Controls.Primitives.DocumentViewerBase -> System.Windows.Annotations.AnnotationService
Public Sub New (viewer As DocumentViewerBase)

Parameter

viewer
DocumentViewerBase

Das dem AnnotationService zugeordnete Dokumentanzeigesteuerelement.

Ausnahmen

viewer ist null.

Beispiele

Das folgende Beispiel zeigt die Verwendung des AnnotationService Konstruktors.

// ------------------------ 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()
' ------------------------ StartAnnotations --------------------------
''' <summary>
'''   Enables annotations and displays all that are viewable.</summary>
Private Sub StartAnnotations()
    ' If there is no AnnotationService yet, create one.
    If _annotService Is Nothing Then
        ' docViewer is a document viewing control named in Window1.xaml.
        _annotService = New AnnotationService(docViewer)
    End If

    ' If the AnnotationService is currently enabled, disable it.
    If _annotService.IsEnabled = True Then
        _annotService.Disable()
    End If

    ' 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 Sub

Hinweise

Dieser Konstruktor kann mit abgeleiteten DocumentViewerBase Steuerelementen verwendet werden:

Weitere Informationen

Gilt für: