Class CommandsAttribute
An attribute to be used against the Commands 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
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.Core.Client
Assembly: API.dll
Syntax
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public class CommandsAttribute : 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.CommandsAttribute.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
CommandsAttribute(String, ImageType, String, ImageType, String)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandsAttribute(string title, ImageType iconID, string description, ImageType overlayIconID = ImageType.None, string tooltip = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title of this command |
ImageType | iconID | The image used for this command |
System.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 |
System.String | tooltip | A user friendly tool tip for this command functionality |
CommandsAttribute(String, ImageType, String, ImageType, String, String)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandsAttribute(string title, ImageType iconID, string description, ImageType overlayIconID, string tooltip, string helpURL)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title of this command |
ImageType | iconID | The image used for this command |
System.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 |
System.String | tooltip | A user friendly tool tip for this command functionality |
System.String | helpURL | An optional url for help documentation around this commands function |
CommandsAttribute(String, String, String, ImageType, String)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandsAttribute(string title, string iconGuid, string description, ImageType overlayIconID = ImageType.None, string tooltip = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title of this command |
System.String | iconGuid | The image used for this command |
System.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 |
System.String | tooltip | A user friendly tool tip for this command functionality |
CommandsAttribute(String, String, String, ImageType, String, String)
Creates a new ICommandDescriptor attribute against the marked field using the specified parameters
Declaration
public CommandsAttribute(string title, string iconGuid, string description, ImageType overlayIconID, string tooltip, string helpURL)
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title of this command |
System.String | iconGuid | The image used for this command |
System.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 |
System.String | tooltip | A user friendly tool tip for this command functionality |
System.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 |
---|---|
System.String |
HelpURL
An optional url for help documentation around this commands function
Declaration
public string HelpURL { get; }
Property Value
Type | Description |
---|---|
System.String |
IconID
Declaration
public Guid IconID { get; }
Property Value
Type | Description |
---|---|
System.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 |
---|---|
System.Nullable<System.Guid> |
Parameter
Any parameter for this command, deriving from CommandSerializedParam
Declaration
public string Parameter { get; }
Property Value
Type | Description |
---|---|
System.String |
Title
The title of this command
Declaration
public string Title { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ToolTip
A user friendly tool tip for this command functionality
Declaration
public string ToolTip { get; }
Property Value
Type | Description |
---|---|
System.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 |
---|---|
System.Guid |
Methods
GetDescriptors(Commands)
Returns all ICommandDescriptors from this attribute marked against the specified Commands enum value
Declaration
public static IEnumerable<ICommandDescriptor> GetDescriptors(Commands type)
Parameters
Type | Name | Description |
---|---|---|
Commands | type | The enum value to return all attributes (transformed to ICOmmandDescriptors) against this value |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ICommandDescriptor> | All ICommandDescriptors from this attribute marked against the specified Commands 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 |
---|---|---|
System.Type | typeWithCommandFields | The type holding a set of Guid fields with CommandsAttribute against them |
System.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(Commands)
Converts this attribute to its equivelant ICommandDescriptor with the specified type
Declaration
public ICommandDescriptor ToCommandDecriptor(Commands type)
Parameters
Type | Name | Description |
---|---|---|
Commands | 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 |
---|---|---|
System.Guid | type | The unique id of this command |
Returns
Type | Description |
---|---|
ICommandDescriptor | Its equivelant ICommandDescriptor with the specified type |