Annotation Service : FlowDocument « Windows Presentation Foundation « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# / C Sharp » Windows Presentation Foundation » FlowDocument 




Annotation Service
Annotation Service
  

<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="Flow Document Reader + 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>
          this is a test
          this is a test
          this is a test
          this is a test
          this is a test
          this is a test
          this is a test
        </Paragraph>
        <Paragraph>
                this is a test 
                this is a test 
                this is a test 
                this is a test 
                this is a test 
                this is a test 
                this is a test 
                this is a test 
                
        </Paragraph>
        <Paragraph>
          this is another test
        </Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
        <Paragraph>...</Paragraph>
      </FlowDocument>
    </FlowDocumentReader>
  </StackPanel>
</Window>

//File:Window.xaml.cs
using System;
using System.IO;
using System.Windows;
using System.Windows.Annotations;
using System.Windows.Annotations.Storage;

public partial class Window1 : Window
{
    Stream stream;

    public Window1()
    {
        InitializeComponent();
    }

    protected void OnInitialized(object sender, EventArgs e)
    {
        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)
    {
        AnnotationService service = AnnotationService.GetService(reader);
        if (service != null && service.IsEnabled)
        {
            service.Store.Flush();
            service.Disable();
            stream.Close();
        }
    }
}

   
    
  














Related examples in the same category
1.FlowDocument with SectionFlowDocument with Section
2.FlowDocument with UI containerFlowDocument with UI container
3.FlowDocument with TableFlowDocument with Table
4.Span and FlowDoucmentSpan and FlowDoucment
5.FlowDocument with Figure.xamlFlowDocument with Figure.xaml
6.Paragraph FontWeightParagraph FontWeight
7.FlowDocument with Hyperlink and ListFlowDocument with Hyperlink and List
8.Adding style to ParagraphAdding style to Paragraph
9.Bold text in Flow documentBold text in Flow document
10.Create Table layout in FlowDocument
11.Figures in a FlowDocumentFigures in a FlowDocument
12.Styled DocumentStyled Document
13.Add ListItem to FlowDocumentAdd ListItem to FlowDocument
14.FlowDocument with TextAlignment, ColumnWidth. Italic and bold fontFlowDocument with TextAlignment, ColumnWidth. Italic and bold font
15.Flow Document ReaderFlow Document Reader
16.Add FlowDocument to ButtonAdd FlowDocument to Button
17.FlowDocument with imagesFlowDocument with images
18.Add Shape(Ellipse, Rectangle) to ListAdd Shape(Ellipse, Rectangle) to List
19.Change FlowDocument Width and HeightChange FlowDocument Width and Height
20.Programmatically change the FlowDirection of content within a FlowDocumentReader elementProgrammatically change the FlowDirection of content within a FlowDocumentReader element
21.Use FlowDocumentReader to display FlowDocumentUse FlowDocumentReader to display FlowDocument
22.Programmatically Create and Save a FlowDocumentProgrammatically Create and Save a FlowDocument
23.Use XamlDesignerSerializationManager to write FlowDocumentUse XamlDesignerSerializationManager to write FlowDocument
24.Show FlowDocumentShow FlowDocument
25.Load a FlowDocument into a FlowDocumentReader,Load a FlowDocument into a FlowDocumentReader,
26.Convert Xaml file to FlowDocument with as operator
27.Save a FlowDocument as a Extensible Application Markup Language (XAML) file
28.Clear FlowDocumentReaderClear FlowDocumentReader
29.Programmatically add rows to a Table element.Programmatically add rows to a Table element.
30.Table Flow ContentTable Flow Content
31.Toggle Hyphenation, Optimal Paragraph, and Column FlexToggle Hyphenation, Optimal Paragraph, and Column Flex
32.Change font Change font
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.