Class EditorToolViewModelBase<T>
Common functionality for an editor tool plug in view model.
Inheritance
Inherited Members
Namespace: Gorgon.Editor.UI
Assembly: Gorgon.Editor.API.dll
Syntax
public abstract class EditorToolViewModelBase<T> : ViewModelBase<T, IHostContentServices>, IEditorTool, IViewModel, INotifyPropertyChanged, INotifyPropertyChanging where T : class, IEditorToolViewModelInjection
Type Parameters
Name | Description |
---|---|
T | The type of dependency injection object. Must be a class, and implement IEditorToolViewModelInjection. |
Remarks
This base class provides functionality needed to communicate the state of the tool with its UI.
An editor tool plug in is a special type of plug in that adds functionality to the editor via the main application ribbon. Tools can be anything from a special bit of functionality to manage data, to batch processing, etc... To begin implementing an editor tool, developers must inherit from this type so that their tool model data is updated from the UI, and feedback is returned to the tool UI.
As an example, if you wanted to create a tool that converted all images in the file system to grayscale (why? why not?), you would define a view with a file list containing the images to convert, and then create a BatchGrayScale view model based on this type and add an observable list to receive updates from the UI (e.g. when images are selected), and a command to process the image data and write back to the file system.
Views that are associated with view models derived from this type must inherit from the EditorToolBaseForm.
Constructors
| Edit this page View SourceEditorToolViewModelBase()
Initializes a new instance of the EditorContentCommon class.
Declaration
protected EditorToolViewModelBase()
See Also
Properties
| Edit this page View SourceCloseToolCommand
Property to return the command used to close the tool.
Declaration
public IEditorAsyncCommand<CloseToolArgs> CloseToolCommand { get; protected set; }
Property Value
Type | Description |
---|---|
IEditorAsyncCommand<CloseToolArgs> |
Remarks
This command will be executed when the user shuts down the tool via a close UI element.
Plug in developers may override this command by setting the property in their own view model. If it is not assigned by the developer, then an internal command is executed. This internal command should cover most use cases, so overriding the command should only be done in unique circumstances.
See Also
| Edit this page View SourceContentFileManager
Property to return the file manager used to manage content files.
Declaration
protected IContentFileManager ContentFileManager { get; }
Property Value
Type | Description |
---|---|
IContentFileManager |
See Also
Methods
| Edit this page View SourceOnCloseToolTaskAsync()
Function to determine the action to take when this tool is closing.
Declaration
protected virtual Task<bool> OnCloseToolTaskAsync()
Returns
Type | Description |
---|---|
Task<bool> | true to continue with closing, false to cancel the close request. |
Remarks
Tool plug in developers can override this method to verify changes, or perform last minute updates as needed.
This is set up as an asynchronous method so that users may save their data asynchronously to keep the UI usable.
See Also
| Edit this page View SourceOnInitialize(T)
Function to initialize the tool.
Declaration
protected override void OnInitialize(T injectionParameters)
Parameters
Type | Name | Description |
---|---|---|
T | injectionParameters | Common view model dependency injection parameters from the application. |
Overrides
Remarks
This is required in order to inject initialization data for the view model from an external source (i.e. the editor host application). Developers will use this area to perform setup of the editor view model, and validate any information being injected.
Ideally this can be used to create resources, child view models, and other objects that need to be initialized when the view model is created.
This method is only ever called after the view model has been created, and never again during the lifetime of the view model.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |