网站内链如何做优化,市场宣传的方法有哪些,如何制作公司app,手机制作app工具本文内容
便笺要点数据锚定匹配批注与批注对象
在纸质文档上编写说明或注释毫不稀奇#xff0c;我们几乎认为这是理所当然的。 这些说明或注释就是“批注”#xff0c;我们将其添加到文档#xff0c;用于标注信息或突出显示兴趣项以供日后参考。 虽然在打印文档上编写注释…本文内容
便笺要点数据锚定匹配批注与批注对象
在纸质文档上编写说明或注释毫不稀奇我们几乎认为这是理所当然的。 这些说明或注释就是“批注”我们将其添加到文档用于标注信息或突出显示兴趣项以供日后参考。 虽然在打印文档上编写注释很简单也很平常但是就算在所有电子文档上添加个人注释功能上却通常有很多限制。
本主题介绍几种常见类型的批注重点介绍便笺和突出显示并举例说明 Microsoft Annotations Framework 如何通过 Windows Presentation Foundation (WPF) 文档查看控件简化在应用程序中使用这些类型的批注。 支持批注的 WPF 文档查看控件包括 FlowDocumentReader 和 FlowDocumentScrollViewer以及派生自 DocumentViewerBase 的控件如 DocumentViewer 和 FlowDocumentPageViewer。
1、便笺
平常的便笺是将信息写在小块彩纸上随后将这张彩纸“粘贴”到文档。 数字便笺为电子文档提供类似的功能但灵活性更高可包括许多其他类型的内容如键入文本、手写注释如 Tablet PC“墨迹”笔划或 Web 链接。
下图显示了突出显示、文本便笺以及墨迹便笺批注的一些示例。 下面的示例演示了可用于在应用程序中启用批注支持的方法。
// ------------------------ 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()2、要点
当人们在纸质文档上作标记时往往使用创造性的方法来突出显示兴趣项例如对于句子中的某些字词加下划线、高亮显示、圈出或者将在空白的地方绘制标记或符号。 Microsoft Annotations Framework 中的突出显示批注具有类似的功能用于标记在 WPF 文档查看控件中显示的信息。
下图演示了一个突出显示批注的示例。 用户通常以如下方法创建批注首先选择感兴趣的文本或者项然后单击右键显示批注选项的 ContextMenu。 在下面的示例中你可以使用 Extensible Application Markup Language 声明包含路由命令的 ContextMenu用户可以访问这些命令来创建和管理批注。
DocumentViewer.ContextMenuContextMenuMenuItem CommandApplicationCommands.Copy /Separator /!-- Add a Highlight annotation to a user selection. --MenuItem Commandann:AnnotationService.CreateHighlightCommandHeaderAdd Highlight /!-- Add a Text Note annotation to a user selection. --MenuItem Commandann:AnnotationService.CreateTextStickyNoteCommandHeaderAdd Text Note /!-- Add an Ink Note annotation to a user selection. --MenuItem Commandann:AnnotationService.CreateInkStickyNoteCommandHeaderAdd Ink Note /Separator /!-- Remove Highlights from a user selection. --MenuItem Commandann:AnnotationService.ClearHighlightsCommandHeaderRemove Highlights /!-- Remove Text Notes and Ink Notes from a user selection. --MenuItem Commandann:AnnotationService.DeleteStickyNotesCommandHeaderRemove Notes /!-- Remove Highlights, Text Notes, Ink Notes from a selection. --MenuItem Commandann:AnnotationService.DeleteAnnotationsCommandHeaderRemove Highlights amp; Notes //ContextMenu
/DocumentViewer.ContextMenu3、数据锚定
Annotations Framework 将批注与用户选择的数据绑定而不仅仅是绑定到显示视图中的某个位置。 因此如果文档视图更改例如当用户滚动显示窗口或者调整其大小时批注将仍然跟随它绑定到的所选数据。 例如下图显示了用户在所选文本上做的批注。 当文档视图更改时滚动、调整大小、缩放或者移动突出显示批注将与最初所选数据一起移动。 4、匹配批注与批注对象
你可以将批注与对应的批注对象匹配。 以具有注释窗格的简单文档读取器应用程序为例。 注释窗格可能是一个列表框用于显示锚定到文档的批注列表的文本。 如果用户在列表框中选择一项应用程序将显示相应的批注对象所锚定到的文档段落。
下面的示例演示如何实现充当注释窗格的此类列表框的事件处理程序。
void annotationsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{Annotation comment (sender as ListBox).SelectedItem as Annotation;if (comment ! null){// IAnchorInfo info;// service is an AnnotationService object// comment is an Annotation objectinfo AnnotationHelper.GetAnchorInfo(this.service, comment);TextAnchor resolvedAnchor info.ResolvedAnchor as TextAnchor;TextPointer textPointer (TextPointer)resolvedAnchor.BoundingStart;textPointer.Paragraph.BringIntoView();}
}另一示例方案涉及通过电子邮件在文档读取器之间实现交换批注和便笺的应用程序。 凭借此功能这些应用程序可以将读取器导航到包含要交换的批注的页面。