<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:a="clr-namespace:System.Windows.Annotations;assembly=PresentationFramework"
Title="FlowDocumentReader + Annotations"
x:Class="Window1" Initialized="OnInitialized" Closed="OnClosed">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label>Control Annotations:</Label>
<Button Command="a:AnnotationService.CreateTextStickyNoteCommand"
CommandTarget="{Binding ElementName=reader}">Create Text Note</Button>
<Button Command="a:AnnotationService.CreateInkStickyNoteCommand" CommandTarget="{Binding ElementName=reader}">
Create Ink Note
</Button>
<Button Command="a:AnnotationService.DeleteStickyNotesCommand" CommandTarget="{Binding ElementName=reader}">
Remove Note
</Button>
<Button Command="a:AnnotationService.CreateHighlightCommand" CommandTarget="{Binding ElementName=reader}">
Create Yellow Highlight
</Button>
<Button Command="a:AnnotationService.ClearHighlightsCommand" CommandTarget="{Binding ElementName=reader}">
Remove Highlight
</Button>
</StackPanel>
<FlowDocumentReader x:Name="reader">
<FlowDocument>
<Paragraph FontSize="22" FontWeight="Bold">Chapter 1</Paragraph>
<Paragraph FontSize="35" FontWeight="Bold">Why WPF?</Paragraph>
<Paragraph>
In movies and on TV, the main characters are typically
an exaggeration of the people you encounter in real life.
They're more attractive, they react quicker, and they
somehow always know exactly what to do. The same could
be said about the software they use.
</Paragraph>
<Paragraph>
This first struck me back in 1994 when watching the movie
Disclosure, starring Michael Douglas, Demi Moore, and an
email program that looks nothing like Microsoft Outlook!
Throughout the movie, we're treated to various visual
features of the program: a spinning three-dimensional "e,"
messages that unfold when you open them and crumple
when you delete them, hints of inking support, and slick
animations when you print messages. (The email program
isn't even the most unrealistic software in the movie. I'll
just say "virtual reality database" and leave it at that.)
</Paragraph>
<Paragraph>
Usability issues aside, Hollywood has been telling us for a
long time that software in the real world isn't as
compelling as it should be. You can probably think of
several examples on your own of TV shows and movies
with comically unrealistic software. But real-world software
is starting to catch up to Hollywood's standards! You can
already see it in traditional operating systems (such as Mac
OS and more recently Windows Vista), in software for
devices such as TiVo or Xbox, and on the Web thanks to
Adobe Flash. Users have increasing expectations for the
experience of using software, and companies are spending
a great deal of time and money on user interfaces that
differentiate themselves from the competition.
</Paragraph>
<Paragraph>
Microsoft now has a solution for helping people create 21st-century software that meets
these high demands, using less time and less money. This solution is Windows
Presentation Foundation (WPF).
</Paragraph>
</FlowDocument>
</FlowDocumentReader>
</StackPanel>
</Window>
protected void OnInitialized(object sender, EventArgs e)
{
// Enable and load annotations
AnnotationService service = AnnotationService.GetService(reader);
if (service == null)
{
stream = new FileStream("storage.xml", FileMode.OpenOrCreate);
service = new AnnotationService(reader);
AnnotationStore store = new XmlStreamStore(stream);
service.Enable(store);
}
}
protected void OnClosed(object sender, EventArgs e)
{
// Disable and save annotations
AnnotationService service = AnnotationService.GetService(reader);
if (service != null && service.IsEnabled)
{
service.Store.Flush();
service.Disable();
stream.Close();
}
}
分享到:
相关推荐
在Windows Presentation Foundation (WPF) 中,FlowDocument是一种强大的文档呈现技术,用于创建富文本内容,如复杂的排版、表格、图像和列表等。本文将深入探讨如何在WPF环境中显示FlowDocument的内容,并通过实例...
FlowDocument是WPF的高级文档功能(如分页和列)承载流内容和设置流内容格式。 其中的块元素Table可以很方便的添加并展示表格,但是其无法实现自动换行,我尝试了网上搜索解决方案以及自己尝试修改。 在网上搜索了...
wpf分页打印打印(使用printDialog.PrintDocument打印flowDocument流文档)第一版本。以后功能完善了更新第二版本。 使用此方法打印:printDialog.PrintDocument(((IDocumentPaginatorSource)flowDocument)....
1. **创建FlowDocument**:首先,你需要创建一个FlowDocument对象,然后可以添加各种元素,如Paragraph、List、Table等。例如: ```csharp FlowDocument flowDoc = new FlowDocument(); Paragraph para = new ...
项目中用到DataGrid, 需要在第一列添加checkbox, 可以多选、全选。 其中涉及的概念DataTemplate, DataGridCellStyle, DataGridCellControlTemplate,Binding, OnPropertyChanged等。
本文将深入探讨如何在WPF中实现DataGrid的动态添加行列功能。 首先,我们需要理解DataGrid的基本用法。DataGrid可以通过绑定到一个数据源(如ObservableCollection或List)来自动生成列,而行则会根据数据源中的...
本教程将基于标题“wpf 后台添加控件(多个)”和描述中的内容,详细介绍如何在WPF应用的后台代码中动态地添加多个控件,并实现滚动条效果。 首先,我们要理解WPF中的控件创建。在XAML中,我们通常静态地定义界面...
以上就是WPF中动态添加`TabControl`选项卡和`Frame`的基本实现方式。通过这种方式,你可以构建出灵活且可扩展的用户界面,满足各种动态内容的需求。在实际项目中,可能还需要考虑样式定制、数据绑定以及性能优化等...
在Windows Presentation ...总之,在WPF的ListView中添加CheckBox列涉及数据模型的设计、数据绑定、以及UI模板的创建。理解这些概念并能灵活运用,将使你能够在WPF应用程序中构建出交互性强、用户体验良好的用户界面。
在C# WPF应用开发中,动态添加ProgressBar到ListView是一种常见的需求,特别是在处理大量数据或者进行后台任务执行时,为了提供用户友好的界面反馈。在VS(Visual Studio)开发环境中,我们可以利用WPF的灵活性和...
在WPF中添加图标,通常使用`Image`控件结合`BitmapImage`类。`Image`控件用于显示图像,而`BitmapImage`则负责加载图片资源。例如,你可以这样创建一个显示图标的`Image`控件: ```xml ``` 这里的`IconPath`是...
在本文中,我们将深入探讨如何在WPF(Windows Presentation Foundation)环境中实现动态的菜单栏、工具栏、TabControl的添加和删除功能,同时提供标题栏背景色的自定义修改。WPF是.NET Framework的一个重要组成部分...
"百度贴吧打豆豆单机版(wpf c#源码及注释)" 这个标题揭示了我们正在讨论一个基于C#编程语言,并使用Windows Presentation Foundation (WPF) 框架开发的单机游戏项目。这个项目是模仿百度贴吧中的“打豆豆”游戏,...
FlowDocument是WPF(Windows Presentation Foundation)框架中的一个重要组件,用于创建富文本内容,它可以包含文本、图片、表格、超链接等多种元素,提供了一种灵活的方式来组织和展示内容。本示例将深入探讨...
"WPF动态添加行列DATAGRID.zip"这个压缩包文件很可能包含了示例代码或教程,教你如何在WPF应用中实现这一功能。 首先,让我们深入理解WPF中的DataGrid控件。DataGrid控件源自.NET Framework 3.5 SP1,是专为WPF设计...
详情参见 http://blog.csdn.net/a582127421/article/details/77835679 http://blog.csdn.net/a582127421/article/details/77835679
现在,我们有了包含窗口内容的DrawingVisual,我们可以将其添加到一个固定尺寸的FixedDocument中,以便于打印。FixedDocument是XPS文档的一部分,适合打印或预览。 ```csharp FixedDocument fixedDoc = new ...
在HTML到FlowDocument的转换过程中,C#代码会处理解析HTML、创建WPF元素并添加到FlowDocument中的逻辑。 6. **库和工具**:有一些现成的库,如HTML agility pack,可以帮助解析HTML。同时,Microsoft自家的System....
《TextileForWPF:将Textile解析为WPF FlowDocument的.NET-Assembly》 在软件开发中,特别是在构建用户界面时,文本格式化是不可或缺的一部分。Windows Presentation Foundation (WPF) 是Microsoft提供的一种强大的...
WPF实现RichTextBox添加文本、自动滚动