AnnotationService Конструкторы

Определение

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления, предназначенным для просмотра документов.

Перегрузки

AnnotationService(FlowDocumentReader)

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления FlowDocumentReader.

AnnotationService(FlowDocumentScrollViewer)

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления FlowDocumentScrollViewer.

AnnotationService(DocumentViewerBase)

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления DocumentViewer или FlowDocumentPageViewer.

Примеры

В следующем примере показано использование конструктора 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()
' ------------------------ 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

Комментарии

Его AnnotationService можно использовать со следующими элементами управления просмотра документов:

AnnotationService(FlowDocumentReader)

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления FlowDocumentReader.

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)

Параметры

viewer
FlowDocumentReader

Элемент управления, предназначенный для чтения документов, связанный с AnnotationService.

Примеры

В следующем примере показано использование конструктора 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()
' ------------------------ 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

См. также раздел

Применяется к

AnnotationService(FlowDocumentScrollViewer)

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления FlowDocumentScrollViewer.

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)

Параметры

viewer
FlowDocumentScrollViewer

Элемент управления, предназначенный для просмотра документов, связанный с AnnotationService.

Исключения

viewer имеет значение null.

Примеры

В следующем примере показано использование конструктора 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()
' ------------------------ 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

См. также раздел

Применяется к

AnnotationService(DocumentViewerBase)

Инициализирует новый экземпляр класса AnnotationService для использования с заданным элементом управления DocumentViewer или FlowDocumentPageViewer.

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)

Параметры

viewer
DocumentViewerBase

Элемент управления, предназначенный для просмотра документов, связанный с AnnotationService.

Исключения

viewer имеет значение null.

Примеры

В следующем примере показано использование конструктора 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()
' ------------------------ 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

Комментарии

Этот конструктор можно использовать с производными DocumentViewerBase элементами управления:

См. также раздел

Применяется к