AnnotationService.Enable(AnnotationStore) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
启用 AnnotationService,以便与给定的 AnnotationStore 一起使用,并显示所有可见的批注。
public:
void Enable(System::Windows::Annotations::Storage::AnnotationStore ^ annotationStore);
public void Enable (System.Windows.Annotations.Storage.AnnotationStore annotationStore);
member this.Enable : System.Windows.Annotations.Storage.AnnotationStore -> unit
Public Sub Enable (annotationStore As AnnotationStore)
参数
- annotationStore
- AnnotationStore
用于读取、写入和显示批注的批注存储区。
例外
annotationStore
为 null
。
示例
以下示例演示如何在启动 AnnotationService时使用 Enable 方法。
// ------------------------ 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
注解
调用 时 Enable ,将显示查看器控件窗口中的所有注释。 (与批注服务关联的查看器控件在 AnnotationService constructor.)