Skip to content

Creating Documents for Application Data

Gary edited this page Aug 27, 2014 · 1 revision

Table of Contents

A document is a container for application data, so most editors support creating documents. For a general description of document support, see Documents in ATF.

This topic discusses ATF document interfaces an editor implements to create documents.

IDocument Interface Implementation

IDocument is a simple interface that describes a type of document. For instance, its Type property gets a text string describing the document type. The DomDocument class is a general implementation of IDocument. For greater detail on IDocument, see IDocument Interface in What is a Document in ATF.

In the ATF Simple DOM Editor Sample, the EventSequenceDocument class uses DomDocument and overrides the Type property to indicate the document type. For details on this class, see EventSequenceDocument Class.

IDocumentClient Interface Implementation

IDocumentClient mainly provides methods for document file handling — opening and closing a document — and is implemented by a document client. An editor has a document client for each type of document it can edit. For more information about this interface, see IDocumentClient Interface in What is a Document in ATF.

Several samples contain an Editor class that implements IDocumentClient, and these classes are typically MEF components.

For a discussion of using IDocumentClient methods, see Implementing a Document and Its Client. This discussion uses the ATF Simple DOM Editor Sample as an example, and this sample's IDocumentClient implementation is also discussed in Editor Component Document Client.

Application Data Persistence

In opening and closing document files, the IDocumentClient implementation typically provides a way to persist application data. This is easy to do in ATF when you use the ATF DOM and an XML Schema to define the data model. The DomXmlWriter and DomXmlReader classes provide a simple way to save data to a file and read it back later. For details on using these classes, see DOM Persistence. That discussion uses the ATF Fsm Editor Sample, but data persistence is handled nearly the same in all ATF samples.

IControlHostClient Interface Implementation

Document handlers also implement IControlHostClient when a control is used to display a document. Such a control host client specifies the control's behavior, if any, when the control gains or loses focus, or is closed. For information about control clients, see Creating Control Clients. In particular, using the Close() method checks whether the document is dirty and offers the user the option of saving it, which is generally desired.

The ATF Simple DOM Editor Sample uses a ListView control to display event sequence documents, so its Editor class implements a control host client. For details, see Editor Component Control Host Client in Simple DOM Editor Programming Discussion.

Topics in this section

Clone this wiki locally