Class ContentPlugIn
Defines a plug in used to generate content in the editor.
Implements
Inherited Members
Namespace: Gorgon.Editor.PlugIns
Assembly: Gorgon.Editor.API.dll
Syntax
public abstract class ContentPlugIn : EditorPlugIn, IGorgonNamedObject
Remarks
A content editor plug in is used to create editors that will be used create or update content within the host application. Custom content editors can be used to create/update any type of content that the user desires. For example, a tile map editor, shader editor, etc...
The content editor plug in provides an editor object that the host application integrates into its UI. And that editor provided must implement the IEditorContent interface. The host application will pass along the required objects to manipulate the file system, access the graphics interface, and other sets of functionality.
Constructors
| Edit this page View SourceContentPlugIn(string)
Initializes a new instance of the ContentPlugIn class.
Declaration
protected ContentPlugIn(string description)
Parameters
Type | Name | Description |
---|---|---|
string | description | Optional description of the plugin. |
See Also
Properties
| Edit this page View SourceCanCreateContent
Property to return whether or not the plugin is capable of creating content.
Declaration
public abstract bool CanCreateContent { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When plugin authors return true for this property, they should also override the GetDefaultContentAsync(string, HashSet<string>) method to pre-populate the content with default data.
See Also
| Edit this page View SourceContentFileManager
Property to return the manager used to manage files in the project file system.
Declaration
protected IContentFileManager ContentFileManager { get; }
Property Value
Type | Description |
---|---|
IContentFileManager |
Remarks
Plug ins can use this to create their own directories and files within the confines of project file system.
See Also
| Edit this page View SourceContentTypeID
Property to return the ID for the type of content produced by this plug in.
Declaration
public abstract string ContentTypeID { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
The content type ID is defined by the plug in author and is used to match up content with the plug in. This value should be as unique as possible.
If the plug in creates an editor that is used to create some kind of common content type like an Image, or Sprite, the user can elect to use the CommonEditorContentTypes. If the plug in author uses this list of types to return the content type ID, then they should disable the content plug ins that come with Gorgon and have the same ID.
See Also
| Edit this page View SourceDefaultFileExtension
Property to return the default file extension used by files generated by this content plug in.
Declaration
protected virtual GorgonFileExtension DefaultFileExtension { get; }
Property Value
Type | Description |
---|---|
GorgonFileExtension |
Remarks
Plug in developers can override this to default the file name extension for their content when creating new content with GetDefaultContentAsync(string, HashSet<string>).
See Also
| Edit this page View SourceHostContentServices
Property to return the services from the host application.
Declaration
protected IHostContentServices HostContentServices { get; }
Property Value
Type | Description |
---|---|
IHostContentServices |
Remarks
Plug in developers that implement a common plug in type based on this base type, should assign this value to allow access to the common content services supplied by the host application.
This will be assigned during the initialization of the plug in.
See Also
| Edit this page View SourcePlugInType
Property to return the type of this plug in.
Declaration
public override sealed PlugInType PlugInType { get; }
Property Value
Type | Description |
---|---|
PlugInType |
Overrides
Remarks
The PlugInType returned for this property indicates the general plug in functionality.
See Also
| Edit this page View SourceTemporaryFileSystem
Property to return the file system used to hold temporary file data.
Declaration
protected IGorgonFileSystemWriter<Stream> TemporaryFileSystem { get; }
Property Value
Type | Description |
---|---|
IGorgonFileSystemWriter<Stream> |
Remarks
Plug ins can use this to write temporary working data, which is deleted after the project unloads.
See Also
Methods
| Edit this page View SourceCanOpenInPlace(IContentFile, IEditorContent)
Function to determine if a file can be opened in place, instead of closing and reopening the content document.
Declaration
public bool CanOpenInPlace(IContentFile file, IEditorContent currentContent)
Parameters
Type | Name | Description |
---|---|---|
IContentFile | file | The file containing the content to evaluate. |
IEditorContent | currentContent | The currently loaded content. |
Returns
Type | Description |
---|---|
bool | true if it can be opened in-place, false if not. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceGetDefaultContentAsync(string, HashSet<string>)
Function to retrieve the default content name, and data.
Declaration
public Task<(string name, RecyclableMemoryStream data, ProjectItemMetadata metadata)> GetDefaultContentAsync(string generatedName, HashSet<string> existingNames)
Parameters
Type | Name | Description |
---|---|---|
string | generatedName | A default name generated by the application. |
HashSet<string> | existingNames | The existing content file names in the same location as the new content file. |
Returns
Type | Description |
---|---|
Task<(string name, RecyclableMemoryStream data, ProjectItemMetadata metadata)> | The content name along with the content data serialized as a byte array, and the metadata for the content file. If either the name or data are null, then the user cancelled the operation. |
Remarks
If an empty string (or whitespace) is returned for the name, then the generatedName
will be used.
See Also
| Edit this page View SourceInitialize(IHostContentServices)
Function to perform any required initialization for the plugin.
Declaration
public void Initialize(IHostContentServices hostServices)
Parameters
Type | Name | Description |
---|---|---|
IHostContentServices | hostServices | The services passed from the host application to the content plug in. |
Remarks
This method is only called when the plugin is loaded at startup.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceOnCanOpenInPlace(IContentFile, IEditorContent)
Function to determine if a file can be loaded in-place.
Declaration
protected virtual bool OnCanOpenInPlace(IContentFile file, IEditorContent currentContent)
Parameters
Type | Name | Description |
---|---|---|
IContentFile | file | The file to evaluate. |
IEditorContent | currentContent | The currently loaded content. |
Returns
Type | Description |
---|---|
bool | true if it can be opened in-place, false if not. |
Remarks
Developers can override this method to implement the correct checking for content information for their plug ins.
See Also
| Edit this page View SourceOnGetDefaultContentAsync(string, ProjectItemMetadata)
Function to retrieve the default content name, and data.
Declaration
protected virtual Task<(string name, RecyclableMemoryStream data)> OnGetDefaultContentAsync(string generatedName, ProjectItemMetadata metadata)
Parameters
Type | Name | Description |
---|---|---|
string | generatedName | A default name generated by the application. |
ProjectItemMetadata | metadata | Custom metadata for the content. |
Returns
Type | Description |
---|---|
Task<(string name, RecyclableMemoryStream data)> | The default content name along with the content data serialized as a byte array. If either the name or data are null, then the user cancelled.. |
Remarks
Plug in authors may override this method so a custom UI can be presented when creating new content, or return a default set of data and a default name, or whatever they wish.
If an empty string (or whitespace) is returned for the name, then the generatedName
will be used.
See Also
| Edit this page View SourceOnInitialize()
Function to provide initialization for the plugin.
Declaration
protected virtual void OnInitialize()
Remarks
This method is only called when the plugin is loaded at startup.
See Also
| Edit this page View SourceOnOpenContentAsync(IContentFile, IContentFileManager, IGorgonFileSystemWriter<Stream>, IUndoService)
Function to open a content object from this plugin.
Declaration
protected abstract Task<IEditorContent> OnOpenContentAsync(IContentFile file, IContentFileManager fileManager, IGorgonFileSystemWriter<Stream> scratchArea, IUndoService undoService)
Parameters
Type | Name | Description |
---|---|---|
IContentFile | file | The file that contains the content. |
IContentFileManager | fileManager | The file manager used to access other content files. |
IGorgonFileSystemWriter<Stream> | scratchArea | The file system for the scratch area used to write transitory information. |
IUndoService | undoService | The undo service for the plug in. |
Returns
Type | Description |
---|---|
Task<IEditorContent> | A new IEditorContent object. |
Remarks
The scratchArea
parameter is the file system where temporary files to store transitory information for the plug in is stored. This file system is destroyed when the
application or plug in is shut down, and is not stored with the project.
See Also
| Edit this page View SourceOnOpenInPlace(IContentFile, IEditorContent, IUndoService)
Function to open a content object in place from this plugin.
Declaration
protected virtual void OnOpenInPlace(IContentFile file, IEditorContent current, IUndoService undoService)
Parameters
Type | Name | Description |
---|---|---|
IContentFile | file | The file that contains the content. |
IEditorContent | current | The currently open content. |
IUndoService | undoService | The undo service to use when correcting mistakes. |
See Also
| Edit this page View SourceOnProjectClosed()
Function to allow custom plug ins to implement custom actions when a project is closed.
Declaration
protected virtual void OnProjectClosed()
See Also
| Edit this page View SourceOnProjectOpened()
Function to allow custom plug ins to implement custom actions when a project is created/opened.
Declaration
protected virtual void OnProjectOpened()
See Also
| Edit this page View SourceOnRegisterSearchKeywords<T>(ISearchService<T>)
Function to register plug in specific search keywords with the system search.
Declaration
protected abstract void OnRegisterSearchKeywords<T>(ISearchService<T> searchService) where T : IGorgonNamedObject
Parameters
Type | Name | Description |
---|---|---|
ISearchService<T> | searchService | The search service to use for registration. |
Type Parameters
Name | Description |
---|---|
T | The type of object being searched, must implement IGorgonNamedObject. |
See Also
| Edit this page View SourceOnShutdown()
Function to provide clean up for the plugin.
Declaration
protected virtual void OnShutdown()
See Also
| Edit this page View SourceOpenContentAsync(IContentFile, IContentFileManager, IProject, IUndoService)
Function to open a content object from this plugin.
Declaration
public Task<IEditorContent> OpenContentAsync(IContentFile file, IContentFileManager fileManager, IProject project, IUndoService undoService)
Parameters
Type | Name | Description |
---|---|---|
IContentFile | file | The file that contains the content. |
IContentFileManager | fileManager | The file manager used to access other content files. |
IProject | project | The project information. |
IUndoService | undoService | The undo service for the plugin. |
Returns
Type | Description |
---|---|
Task<IEditorContent> | A new IEditorContent object. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
GorgonException | Thrown if the OnOpenContentAsync(IContentFile, IContentFileManager, IGorgonFileSystemWriter<Stream>, IUndoService) method returns null. |
See Also
| Edit this page View SourceOpenInPlace(IContentFile, IEditorContent, IUndoService)
Function to open the file in-place.
Declaration
public void OpenInPlace(IContentFile file, IEditorContent current, IUndoService undoService)
Parameters
Type | Name | Description |
---|---|---|
IContentFile | file | The file that contains the content. |
IEditorContent | current | The current content. |
IUndoService | undoService | The undo service to use when correcting mistakes. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceProjectClosed()
Function called when a project is unloaded.
Declaration
public void ProjectClosed()
See Also
| Edit this page View SourceProjectOpened(IContentFileManager, IGorgonFileSystemWriter<Stream>)
Function called when a project is loaded/created.
Declaration
public void ProjectOpened(IContentFileManager fileManager, IGorgonFileSystemWriter<Stream> tempFileSystem)
Parameters
Type | Name | Description |
---|---|---|
IContentFileManager | fileManager | The file manager for the project. |
IGorgonFileSystemWriter<Stream> | tempFileSystem | The file system used to hold temporary working data. |
See Also
| Edit this page View SourceRegisterSearchKeywords<T>(ISearchService<T>)
Function to register plug in specific search keywords with the system search.
Declaration
public void RegisterSearchKeywords<T>(ISearchService<T> searchService) where T : IGorgonNamedObject
Parameters
Type | Name | Description |
---|---|---|
ISearchService<T> | searchService | The search service to use for registration. |
Type Parameters
Name | Description |
---|---|
T | The type of object being searched, must implement IGorgonNamedObject. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceShutdown()
Function to perform any required clean up for the plugin.
Declaration
public void Shutdown()