Share via


AnnotationService.Store Eigenschaft

Definition

Ruft die von der AnnotationStore-Klasse verwendete AnnotationService-Klasse ab.

public:
 property System::Windows::Annotations::Storage::AnnotationStore ^ Store { System::Windows::Annotations::Storage::AnnotationStore ^ get(); };
public System.Windows.Annotations.Storage.AnnotationStore Store { get; }
member this.Store : System.Windows.Annotations.Storage.AnnotationStore
Public ReadOnly Property Store As AnnotationStore

Eigenschaftswert

AnnotationStore

Der von diesem AnnotationStore verwendete AnnotationService.

Beispiele

Im folgenden Beispiel wird gezeigt, wie Sie die Store Eigenschaft beim Starten und Beenden einer AnnotationServiceEigenschaft verwenden.

// ------------------------ 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()

// ------------------------ StopAnnotations ---------------------------
/// <summary>
///   Disables annotation processing and hides all annotations.</summary>
private void StopAnnotations()
{
    // If the AnnotationStore is active, flush and close it.
    if (_annotStore != null)
    {
        _annotStore.Flush();
        _annotStream.Flush();
        _annotStream.Close();
        _annotStore = null;
    }

    // If the AnnotationService is active, shut it down.
    if (_annotService != null)
    {
        if (_annotService.IsEnabled)
        {
            _annotService.Disable();  // Disable the AnnotationService.
            _annotService = null;
        }
    }
}// end:StopAnnotations()
' ------------------------ 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


' ------------------------ StopAnnotations ---------------------------
''' <summary>
'''   Disables annotation processing and hides all annotations.</summary>
Private Sub StopAnnotations()
    ' If the AnnotationStore is active, flush and close it.
    If _annotStore IsNot Nothing Then
        _annotStore.Flush()
        _annotStream.Flush()
        _annotStream.Close()
        _annotStore = Nothing
    End If

    ' If the AnnotationService is active, shut it down.
    If _annotService IsNot Nothing Then
        If _annotService.IsEnabled Then
            _annotService.Disable() ' Disable the AnnotationService.
            _annotService = Nothing
        End If
    End If
End Sub

Hinweise

Der AnnotationStore vom AnnotationService Dienst verwendete Parameter wird als Parameter in der Methode des Diensts Enable angegeben.

Gilt für