Class CommandAttribute
An attribute to be used against the Command enum to provide context to their functionality, or custom fields to provide easy referenceable commands
Also a concrete implementation of ICommandDescriptor to easily get the definition of system commands
Implements
Inherited Members
Namespace: LemonEdge.API.Client
Assembly: LemonEdge.API.dll
Syntax
[AttributeUsage(AttributeTargets.Field)]
public class CommandAttribute : Attribute, ICommandDescriptor
Remarks
To use for a custom commands, you can do the following:
public static class MyCommandsInfo
{
[Commands("Custom 1", ImageType.LemonEdge, "Explore all custom things.", ImageType.None, "Explore all custom things.")]
public const string MyCustom1CommandIDString = "3DFAE1FE-6D9C-437E-A5D4-915BBF77E245";
public static Guid MyCustom1CommandID =$gt; Guid.Parse(MyCustom1CommandIDString);
}
public class CommandDefinitions
{
public ICommandDescriptor GetCustomCommand1Info()
{
var buttonInfo = LemonEdge.Core.Client.CommandAttribute.GetDescriptors(typeof(MyCommandsInfo), MyCommandsInfo.MyCustom1CommandID);
return buttonInfo;
}
}
This provides a quick method for getting an ICommandDescriptor for your commands that can be shared between ui specific, and core code. This descriptor can be used in menu upgrades to easily provide default button implementations on the main menu for your custom commands. See IDefaultMenuInserter
Constructors
CommandAttribute(string, ImageType, string, ImageType, string)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandAttribute(string title, ImageType iconID, string description, ImageType overlayIconID = ImageType.None, string tooltip = "")
Parameters
Type | Name | Description |
---|---|---|
string | title | The title of this command |
ImageType | iconID | The image used for this command |
string | description | A user friendly description of this command |
ImageType | overlayIconID | On some clients another image can be overlayed on the bottom right of the main icon (for indicating add, remove, etc). This is the optional overlay image id |
string | tooltip | A user friendly tool tip for this command functionality |
CommandAttribute(string, ImageType, string, ImageType, string, string)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandAttribute(string title, ImageType iconID, string description, ImageType overlayIconID, string tooltip, string helpURL)
Parameters
Type | Name | Description |
---|---|---|
string | title | The title of this command |
ImageType | iconID | The image used for this command |
string | description | A user friendly description of this command |
ImageType | overlayIconID | On some clients another image can be overlayed on the bottom right of the main icon (for indicating add, remove, etc). This is the optional overlay image id |
string | tooltip | A user friendly tool tip for this command functionality |
string | helpURL | An optional url for help documentation around this commands function |
CommandAttribute(string, string, string, ImageType, string)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandAttribute(string title, string iconGuid, string description, ImageType overlayIconID = ImageType.None, string tooltip = "")
Parameters
Type | Name | Description |
---|---|---|
string | title | The title of this command |
string | iconGuid | The image used for this command |
string | description | A user friendly description of this command |
ImageType | overlayIconID | On some clients another image can be overlayed on the bottom right of the main icon (for indicating add, remove, etc). This is the optional overlay image id |
string | tooltip | A user friendly tool tip for this command functionality |
CommandAttribute(string, string, string, ImageType, string, string)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandAttribute(string title, string iconGuid, string description, ImageType overlayIconID, string tooltip, string helpURL)
Parameters
Type | Name | Description |
---|---|---|
string | title | The title of this command |
string | iconGuid | The image used for this command |
string | description | A user friendly description of this command |
ImageType | overlayIconID | On some clients another image can be overlayed on the bottom right of the main icon (for indicating add, remove, etc). This is the optional overlay image id |
string | tooltip | A user friendly tool tip for this command functionality |
string | helpURL | An optional url for help documentation around this commands function |
Properties
Description
A user friendly description of this command
Declaration
public string Description { get; }
Property Value
Type | Description |
---|---|
string |
HelpURL
An optional url for help documentation around this commands function
Declaration
public string HelpURL { get; }
Property Value
Type | Description |
---|---|
string |
IconID
Declaration
public Guid IconID { get; }
Property Value
Type | Description |
---|---|
Guid |
OverlayIconID
On some clients another image can be overlayed on the bottom right of the main icon (for indicating add, remove, etc)
This optional overlay image can be specified here, either a ImageType or ImageID
Declaration
public Guid? OverlayIconID { get; }
Property Value
Type | Description |
---|---|
Guid? |
Parameter
Any parameter for this command, deriving from CommandSerializedParam
Declaration
public string Parameter { get; }
Property Value
Type | Description |
---|---|
string |
Title
The title of this command
Declaration
public string Title { get; set; }
Property Value
Type | Description |
---|---|
string |
ToolTip
A user friendly tool tip for this command functionality
Declaration
public string ToolTip { get; }
Property Value
Type | Description |
---|---|
string |
Type
A globally unique id to identify this command in uniquel in the main menu. Comes from Type if it came from the standard set, but can be any id for custom commands, or Guid.Empty otherwise
Declaration
public Guid Type { get; }
Property Value
Type | Description |
---|---|
Guid |
Methods
GetDescriptors(Command)
Returns all ICommandDescriptors from this attribute marked against the specified Command enum value
Declaration
public static IEnumerable<ICommandDescriptor> GetDescriptors(Command type)
Parameters
Type | Name | Description |
---|---|---|
Command | type | The enum value to return all attributes (transformed to ICOmmandDescriptors) against this value |
Returns
Type | Description |
---|---|
IEnumerable<ICommandDescriptor> | All ICommandDescriptors from this attribute marked against the specified Command enum value |
GetDescriptors(Type, Guid)
Returns the attribute against the field in the specified type that holds the value matching the specified
forCommandID
. That attribute is then translated to its ICommandDescriptor
equivelant
Declaration
public static ICommandDescriptor GetDescriptors(Type typeWithCommandFields, Guid forCommandID)
Parameters
Type | Name | Description |
---|---|---|
Type | typeWithCommandFields | The type holding a set of Guid fields with CommandAttribute against them |
Guid | forCommandID | The value of a field against the specified type to look for |
Returns
Type | Description |
---|---|
ICommandDescriptor | The attribute against the field in the specified type that holds the value matching the specified
|
ToCommandDecriptor(Command)
Converts this attribute to its equivelant ICommandDescriptor with the specified type
Declaration
public ICommandDescriptor ToCommandDecriptor(Command type)
Parameters
Type | Name | Description |
---|---|---|
Command | type | The unique id of this command |
Returns
Type | Description |
---|---|
ICommandDescriptor | Its equivelant ICommandDescriptor with the specified type |
ToCommandDecriptor(Guid)
Converts this attribute to its equivelant ICommandDescriptor with the specified type
Declaration
public ICommandDescriptor ToCommandDecriptor(Guid type)
Parameters
Type | Name | Description |
---|---|---|
Guid | type | The unique id of this command |
Returns
Type | Description |
---|---|
ICommandDescriptor | Its equivelant ICommandDescriptor with the specified type |