주석 개요

업데이트: 2007년 11월

종이 문서에 메모나 설명을 적는 것은 당연하게 받아들이는 매우 일반적인 행동입니다. 이러한 메모나 설명은 나중에 참조하기 위해 관심 있는 항목에 표시하거나 정보를 기입하기 위해 문서에 추가하는 "주석"입니다. 인쇄된 문서에 메모를 적는 것은 간단하고 일반적인 일이지만 전자 문서에 개인 주석을 추가하는 기능은 대개 비록 가능하더라도 매우 제한적입니다.

이 항목에서는 스티커 메모 및 강조 표시 등과 같은 일반적인 주석의 유형을 검토하고, Microsoft Annotations Framework에서 WPF(Windows Presentation Foundation) 문서 보기 컨트롤을 통해 응용 프로그램에 이러한 유형의 주석을 사용하는 방법을 보여 줍니다. 주석을 지원하는 WPF 문서 보기 컨트롤에는 FlowDocumentReader, FlowDocumentScrollViewerDocumentViewer, FlowDocumentPageViewer와 같이 DocumentViewerBase에서 파생된 컨트롤이 포함됩니다.

이 항목에는 다음 단원이 포함되어 있습니다.

  • 스티커 메모
  • 강조 표시
  • 데이터 고정
  • 주석을 주석이 지정된 개체에 연결
  • 관련 항목

스티커 메모

일반적인 스티커 메모는 정보를 기입한 색상 있는 작은 종이 조각으로 문서에 "붙입니다". 디지털 스티커 메모는 전자 문서에 대해 비슷한 기능을 제공하지만 입력된 텍스트, 필기 메모(예: Tablet PC "잉크" 스트로크) 또는 웹 링크 등과 같은 다양한 유형의 콘텐츠를 포함할 수 있는 유연성을 가집니다.

다음 그림에서는 강조 표시, 텍스트 스티커 메모 및 잉크 스티커 메모 주석의 예를 보여 줍니다.

강조 표시, 텍스트 및 잉크 스티커 메모 주석

다음 예제에서는 응용 프로그램에서 주석 지원을 설정할 때 사용할 수 있는 방법을 보여 줍니다. 전체 샘플을 보려면 주석 XML 저장소가 있는 DocumentViewer 샘플 또는 주석 XPS 저장소가 있는 DocumentViewer 샘플을 참조하십시오.

// ------------------------ 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()

강조 표시

사람들은 종이 문서에 표시할 때 밑줄, 강조 표시, 문장에 포함된 단어에 동그라미 표시 또는 여백에 표시 또는 주석 그리기 등의 창조적 방법으로 관심 있는 항목이 시선을 끌 수 있도록 합니다. Microsoft Annotations Framework의 강조 표시 주석은 이와 유사하게 WPF 문서 보기 컨트롤에 표시되는 정보에 표시를 할 수 있는 기능을 제공합니다.

다음 그림에서는 강조 표시 주석의 예를 보여 줍니다.

강조 표시 주석

사용자는 일반적으로 우선 관심 있는 텍스트나 항목을 선택한 다음 마우스 오른쪽 단추를 클릭하여 주석 옵션의 ContextMenu를 표시합니다. 다음 예제에서는 사용자가 액세스하여 주석을 만들고 관리할 수 있는 라우팅된 명령으로 ContextMenu를 선언하는 데 사용할 수 있는 XAML(Extensible Application Markup Language)을 보여 줍니다. 전체 샘플을 보려면 주석 XPS 저장소가 있는 DocumentViewer 샘플을 참조하십시오.

<DocumentViewer.ContextMenu>
  <ContextMenu>
    <MenuItem Command="ApplicationCommands.Copy" />
    <Separator />
    <!-- Add a Highlight annotation to a user selection. -->
    <MenuItem Command="ann:AnnotationService.CreateHighlightCommand"
              Header="Add Highlight" />
    <!-- Add a Text Note annotation to a user selection. -->
    <MenuItem Command="ann:AnnotationService.CreateTextStickyNoteCommand"
              Header="Add Text Note" />
    <!-- Add an Ink Note annotation to a user selection. -->
    <MenuItem Command="ann:AnnotationService.CreateInkStickyNoteCommand"
              Header="Add Ink Note" />
    <Separator />
    <!-- Remove Highlights from a user selection. -->
    <MenuItem Command="ann:AnnotationService.ClearHighlightsCommand"
              Header="Remove Highlights" />
    <!-- Remove Text Notes and Ink Notes from a user selection. -->
    <MenuItem Command="ann:AnnotationService.DeleteStickyNotesCommand"
              Header="Remove Notes" />
    <!-- Remove Highlights, Text Notes, Ink Notes from a selection. -->
    <MenuItem Command="ann:AnnotationService.DeleteAnnotationsCommand"
              Header="Remove Highlights &amp; Notes" />
  </ContextMenu>
</DocumentViewer.ContextMenu>

데이터 고정

Annotations Framework에서는 주석을 표시 보기에서의 위치만이 아니라 사용자가 선택하는 데이터에도 바인딩합니다. 따라서 사용자가 표시 창을 스크롤하거나 크기를 변경하여 문서 보기가 변경된 경우 주석은 바인딩된 데이터 선택 항목과 함께 남아 있습니다. 예를 들어 다음 그래픽은 사용자가 텍스트 선택 항목에 추가한 주석을 보여 줍니다. 문서 보기가 변경되면(스크롤, 크기 조정, 배율 조정 또는 이동 등) 강조 표시 주석은 원래 데이터 선택 항목과 함께 이동합니다.

주석 데이터 고정

주석을 주석이 지정된 개체에 연결

주석을 해당 주석이 지정된 개체와 연결할 수 있습니다. 예를 들어 주석 창이 있는 간단한 문서 판독기 응용 프로그램을 생각해 보겠습니다. 주석 창은 문서에 고정된 주석 목록의 텍스트를 표시하는 목록 상자일 수 있습니다. 사용자가 목록 상자에서 항목을 선택하면 응용 프로그램에서 해당 주석 개체가 고정된 문서의 단락이 표시됩니다.

다음 예제에서는 주석 창으로 사용되는 목록 상자와 같은 이벤트 처리기를 구현하는 방법을 보여 줍니다.

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 object
        info = AnnotationHelper.GetAnchorInfo(this.service, comment);
        TextAnchor resolvedAnchor = info.ResolvedAnchor as TextAnchor;
        TextPointer textPointer = (TextPointer)resolvedAnchor.BoundingStart;
        textPointer.Paragraph.BringIntoView();
    }
}

다른 예제 시나리오에는 전자 메일을 통해서 문서 판독기 간에 주석 및 스티커 메모를 교환할 수 있도록 하는 응용 프로그램에 대한 내용이 포함됩니다. 이 기능을 통해 이러한 응용 프로그램은 판독기에서 교환하는 주석이 포함된 페이지로 이동할 수 있습니다.

참고 항목

작업

방법: MenuItem에 명령 추가

주석 XPS 저장소가 있는 DocumentViewer 샘플

주석 XML 저장소가 있는 DocumentViewer 샘플

주석 스타일 지정 샘플

문서 Serialization 샘플

개념

주석 스키마

ContextMenu 개요

명령 개요

유동 문서 개요

참조

DocumentViewerBase

DocumentViewer

FlowDocumentPageViewer

FlowDocumentScrollViewer

FlowDocumentReader

IAnchorInfo