Using DOM Metadata for Palettes and Other Items - kaisu1986/ATF GitHub Wiki
You can add metadata to DomNodeType
objects to do various things, such as setting up a palette.
Besides adding information to DomNodeType
objects to specify property descriptors for attributes, as shown in DOM Property Descriptors, you can add information that serves other purposes, such as describing objects in a palette. Add this information by calling the NamedMetadata.SetTag()
method.
A NamedMetadata
object, such as a DomNodeType
, contains a dictionary to which you can add information. You can add any object to a DomNodeType
, with any object as a key, by using the NamedMetadata.SetTag()
method. It has two forms:
void SetTag(object key, object value)
void SetTag<T>(T value)
NamedMetadata.GetTagLocal()
method, which has two analogous forms:
object GetTagLocal(object key)
T GetTagLocal<T>()
DomNodeType
objects and retrieve it later. SetTag()
was illustrated in DOM Property Descriptors adding property descriptor information to DomNodeType
objects.
A number of ATF samples use a palette for objects that can be dragged onto a canvas, such as ATF DOM Tree Editor Sample and ATF Simple DOM Editor Sample, which contains this code:
Schema.eventType.Type.SetTag(
new NodeTypePaletteItem(
Schema.eventType.Type,
"Event".Localize(),
"Event in a sequence".Localize(),
Resources.EventImage));
Schema.animationResourceType.Type.SetTag(
new NodeTypePaletteItem(
Schema.animationResourceType.Type,
"Animation".Localize(),
"Animation resource".Localize(),
Resources.AnimationImage));
...
A NodeTypePaletteItem
object is added to the DomNodeType
for each type of object that appears on the application's palette. NodeTypePaletteItem
contains such information as a tool tip and an image that represents the object on the palette.
For details on how the ATF Simple DOM Editor Sample creates and uses a palette, including using NodeTypePaletteItem
, see Using a Palette in Simple DOM Editor Programming Discussion.
You can also add palette information with annotations in the type definition if you are using an XML Schema. For an example of how to do this from the ATF Timeline Editor Sample, see Other Uses of Annotations.