Skip to content

Context Interfaces

gstaas edited this page Oct 2, 2014 · 2 revisions

Table of Contents

This section describes each of ATF's context interfaces and their usage. Other sections discuss Context Classes and Context Related Classes.

Context Interface List

The following table lists context interfaces; the context in which the interface can be used (for example, items can be selected); its methods, properties, and events; and some examples of where the context is used.

Context Interface Description, used where... Methods, Properties, Events Used in
IColoringContext Items can be colored. GetColor(), CanSetColor(), SetColor() CircuitEditingContext class
IEnumerableContext Context can provide an enumeration of all its items. Complements ISelectionContext. Items Numerous samples, including ATF Fsm Editor Sample, ATF Simple DOM Editor Sample, ATF Timeline Editor Sample
IHierarchicalInsertionContext Context can insert new objects (e.g., via drag and drop) under a specific parent object. Normally implemented along with IInstancingContext. CanInsert(), Insert() ATF Tree List Editor Sample to allow specific tree editors like ProjectLister to tell the context which node a user has dragged an object to. This context is used by ApplicationUtil's CanInsert() and Insert() methods and is preferred over IInstancingContext if both are implemented.
IHistoryContext Context has history, such as commands with history. It enables implementing "Undo"/"Redo" commands, tracking what has changed since the document was last saved. CanUndo(), CanRedo(), UndoDescription(), RedoDescription(), Undo(), Redo(). Dirty. Event DirtyChanged HistoryContext class
IInstancingContext Context can instance objects, which requires the ability to copy, insert, and delete items. This interface integrates well with the Windows clipboard, because it uses System.Windows.IDataObject, which is used by the Windows Cut, Copy, Paste, Delete, and drag and drop commands. IInstancingContext should be used to create new instances, as in "Group"/"Ungroup" commands. Consider implementing IHierarchicalInsertionContext, too, if this context has data that is exposed to any kind of tree control, like ProjectLister. In a WinForms application, the object type is probably System.Windows.Forms.IDataObject, and in a WPF application, this object can be a System.Windows.IDataObject. For more details, see Instancing In ATF. CanCopy(), Copy(), CanInsert(), Insert(), CanDelete(), Delete() Several samples, including ATF DOM Tree Editor Sample, ATF Fsm Editor Sample, ATF Simple DOM Editor Sample
ILabelEditingContext Context supports editing item labels. WPF only. CanEditLabel(), EditLabel(), GetLabel(), SetLabel(). Event BeginLabelEdit EditLabelCommand class
ILayeringContext Context with layering. Layering contexts control item visibility and provide a tree view of layers. Implements IVisibilityContext, ITreeView, and IItemView. SetActiveItem() LayerLister component
ILayoutContext Items can be positioned and resized. Contains methods for getting and setting item bounding rectangles, information on which parts of the bounds are meaningful, and which parts of bounds can be set. Has both WinForms and WPF versions, which have exactly the same methods and extension methods, with slightly different implementations. GetBounds(), CanSetBounds(), SetBounds() StandardLayoutCommands component. ATF Fsm Editor Sample, ATF State Chart Editor Sample
ILockingContext Designed for determining whether an object is locked, so the object cannot be changed or deleted. Can use to support read-only documents. IsLocked(), CanSetLocked(), SetLocked() StandardLockCommands. For locking documents, see ISourceControlContext and SourceControlCommands.
INamingContext Objects can be named. GetName(), CanSetName(), SetName() ATF DOM Tree Editor Sample, ATF Fsm Editor Sample, ATF State Chart Editor Sample, ATF Timeline Editor Sample
IObservableContext Context can provide update events for changes to its contents. Allow observers of list and tree data to track changes. If an application finds that the active context implements IObservableContext, it can implement an editable view that stays in sync with the data. If applications do not find IObservableContext, they can assume the view is read-only and still consume data. Events ItemInserted, ItemRemoved, ItemChanged, Reloaded Numerous samples, including ATF DOM Tree Editor Sample, ATF File Explorer Sample, ATF Simple DOM Editor Sample, ATF Simple DOM No XML Editor Sample
IPropertyEditingContext Properties can be edited by controls. Allow property editing controls, such as PropertyGrid or GridControl, to get properties and items with properties, enabling property editing controls to display objects and their properties. Items, PropertyDescriptors PropertyView class
IPrototypingContext Prototyping context, which can present a tree view of its contents and create IDataObjects from them. Implements ITreeView and IItemView. SetActiveItem(), GetInstances() PrototypeLister component. ATF Fsm Editor Sample, ATF State Chart Editor Sample
IQueryableContext Classes in which objects may be searched. Query() DomNodeQueryable class
IQueryableReplaceContext Classes in which containing objects may be replaced. Replace() DomNodeQueryable class
IQueryableResultContext Accessing the results of a query and being notified when those results change. Results. Event ResultsChanged DomNodeQueryable class
ISearchableContext Context provides search and replace capabilities through a client-defined UI. SearchUI, ReplaceUI, ResultsUI ATF Simple DOM Editor Sample
ISelectionContext Items can be selected. This interface distills what it means to have a selection in a context. It provides methods for getting the objects in a selection, setting the selection, and getting the last selection. It also provides filtering, so you can get the last selected object of a certain type. It has events detecting before and after a selection changes. It has an efficient method for determining if a selection contains an object. GetSelection<T>(), GetLastSelected<T>(), SelectionContains(). Selection, LastSelected, SelectionCount. Events SelectionChanging, SelectionChanged SelectionContext class. Several samples, including ATF File Explorer Sample, ATF Simple DOM Editor Sample, ATF Tree List Editor Sample
ISourceControlContext Source control context. Users of this interface can use the IResource to examine URIs and adapt the IResource to IDocument to track a document's dirty flag. Resources SourceControlCommands
ISubSelectionContext Context supports selection and can optionally specify a "sub-selection" context, i.e., the selection context of sub-elements, related to the selection in this context. This interface serves to abstractly allow consumers of selection contexts to hook into events from sub-selections. Implements ISelectionContext. SubSelectionContext ATF Simple DOM Editor Sample
ITemplatingContext Prototyping context, which can present a tree view of its contents and create IDataObjects from them. Implements ITreeView and IItemView. SetActiveItem(), GetInstances(), CanReference(), CreateReference() TemplatingContext class. TemplateLister component
ITransactionContext Useful for implementing transactions on data and simplifies editor design. Data is changed in transactions, which can rolled back, simplifying editor design. Transactions can be cancelled any time before calling End(). Different modules can contribute to an operation without having to know about each other, and if an exception occurs in one module, the whole transaction can be rolled back. Begin(), Cancel(), End(). InTransaction TransactionContext class. Several samples, including ATF DOM Tree Editor Sample, ATF Fsm Editor Sample, ATF Timeline Editor Sample
IValidationContext Context provides events for marking when the user begins and ends logical commands, so listeners can perform validation. Validation events allow listeners to update themselves and check constraints more efficiently. Instead of responding to every change in data, validators can wait to check constraints until after an Ending event and then update in one operation. The validator can allow invalid states as data changes, but before validation ends, it can raise an exception if a constraint is not satisfied. Operations can be cancelled. Events Beginning, Cancelled, Ending, Ended ATF Tree List Editor Sample
IViewingContext Items can be viewed. Its methods check whether objects are or can be made visible, or are framed or can be framed in the current view. Note that this context could operate on many different kinds of data; this is true of other contexts as well. CanFrame(), Frame(), CanEnsureVisible(), EnsureVisible() StandardViewCommands component. Several samples, including ATF Fsm Editor Sample, ATF State Chart Editor Sample
IViewingContext Items can be viewed. WPF version, derived from Sce.Atf.Applications.IViewingContext Adaptable, ViewingAdapter, PickingAdapters, LayoutConstraints
IVisibilityContext Items can be shown and hidden. IsVisible(), CanSetVisible(), SetVisible() StandardShowCommands component

Topics in this section

Clone this wiki locally