-
Notifications
You must be signed in to change notification settings - Fork 260
Document Handling Components
Several ATF components provide services document handlers can use.
Many of the sample applications use all of these components. Some of these components depend on each other, as noted in the discussion below on component requirements.
As previously discussed, the DocumentRegistry component tracks open documents (objects implementing IDocument) for an application and implements IDocumentRegistry.
To use this component, simply add it to the application's MEF catalog. It doesn't import anything, so no other components are required to use it.
However, other components import and require IDocumentRegistry: StandardFileCommands, AutoDocumentService, and MainWindowTitleService — the other components discussed here. Therefore, you must provide DocumentRegistry or some other component implementing IDocumentRegistry to use these other components. Other components besides these also import IDocumentRegistry, such as CommandLineArgsService, which parses and validates command line arguments. These components all need and take advantage of the document tracking services DocumentRegistry offers.
For additional information on this component, see IDocumentRegistry Interface and DocumentRegistry Component.
StandardFileCommands implements File menu commands that modify the document registry: New, Open, Save, SaveAs, Save All, and Close. New and Open commands are created for each IDocumentClient component in the application.
In other words, including this component in your application automatically adds all the usual menu items you need to handle documents.
StandardFileCommands is the only ATF component that implements IDocumentService and can be used to satisfy such an import. For instance, the AutoDocumentService component imports IDocumentService.
StandardFileCommands requires (except as noted) the following:
-
DocumentRegistrycomponent or some other component implementingIDocumentRegistry. -
CommandServicecomponent or component implementingICommandService. -
FileDialogServicecomponent or component implementingIFileDialogService. -
StatusServicecomponent or component implementingIStatusService(requested but not required). -
IDocumentClientimplementer for each document type.
IDocumentClient. The application must implement IDocumentClient for every document type it supports. For details on doing this, see Implementing a Document and Its Client.
Note that the application can implement as many IDocumentClient implementers as it wishes, because of the form of the import:
[ImportMany]
private Lazy<IDocumentClient>[] m_documentClients;For an example of using StandardFileCommands in an application, see StandardFileCommands.
When an application starts up, AutoDocumentService automatically opens the application's last open document or a new, empty document.
AutoDocumentService requires the following (except as noted):
-
DocumentRegistrycomponent or some other component implementingIDocumentRegistry. -
SettingsServicecomponent or component implementingISettingsService(requested but not required). -
CommandLineArgsServicecomponent (requested but not required). -
IDocumentServiceimplementer, such asStandardFileCommands, to open an existing document. -
IMainWindowimplementer, which is met by creating aMainFormcomponent. -
Formimplementer, which is met by creating aMainFormcomponent. -
IDocumentClientimplementer for each document type to open a document.
MainForm derives from Form and implements IMainWindow, so it satisfies two of the imports, as noted.
The last requirement is the most demanding: the application must implement IDocumentClient for every document type it supports. For details on doing this, see Implementing a Document and Its Client. Just as for StandardFileCommands, the application can have as many IDocumentClient implementers as it wants.
MainWindowTitleService updates the application main form's title to reflect the current document and indicate whether it is dirty or not.
MainWindowTitleService requires the following:
-
DocumentRegistrycomponent or some other component implementingIDocumentRegistry. -
IMainWindowimplementer, which is met by creating aMainFormcomponent.
-
What is a Document in ATF: Introduces the
IDocumentandIDocumentClientinterfaces that an individual document uses. -
Document Registry and Services: Discusses the
DocumentRegistryto track documents and other document services offered inIDocumentService. - Document Handling Components: Details the MEF components providing services document handlers need.
-
Implementing a Document and Its Client: Shows how to implement both
IDocumentandIDocumentClientinterfaces for a document type.
- Home
- Getting Started
- Features & Benefits
- Requirements & Dependencies
- Gallery
- Technology & Samples
- Adoption
- News
- Release Notes
- ATF Community
- Searching Documentation
- Using Documentation
- Videos
- Tutorials
- How To
- Programmer's Guide
- Reference
- Code Samples
- Documentation Files
© 2014-2015, Sony Computer Entertainment America LLC