Class EPCommand
The base command for all commands in the LemonEdge platform, implementing the IEPCommand interface
Commands inheriting this can be displayed on the main menu and anywhere throughout the application. View specific commands should typically inherit from ViewCommand
Inheritance
Inherited Members
Namespace: LemonEdge.Client.UI.API.Commands
Assembly: LemonEdge.Client.UI.API.dll
Syntax
public abstract class EPCommand : BaseHasChildren<EPCommandWithDescriptor>, IHasChildren<EPCommandWithDescriptor>, IHasChildren, IEPCommand, ICommand, IDisposable
Constructors
EPCommand(IRootController, IModelLayoutCommon?, EPCommandWithDescriptor?)
Creates a new EPCommand, with the app controller, for when the owner is not available.
Declaration
protected EPCommand(IRootController root, IModelLayoutCommon? owner = null, EPCommandWithDescriptor? parent = null)
Parameters
Type | Name | Description |
---|---|---|
IRootController | root | |
IModelLayoutCommon | owner | The owning context this command operates within |
EPCommandWithDescriptor | parent |
Properties
ActiveDisplayerFromOwner
Returns the active layout this command is working against depending on the owner type.
Returns the owner itself if it is of type IModelLayoutDisplayer, else returns the active layout if it is of type IModelLayoutHost
Declaration
protected IModelLayoutDisplayer ActiveDisplayerFromOwner { get; }
Property Value
Type | Description |
---|---|
IModelLayoutDisplayer |
CustomType
The custom type of command if this command needs special handling in the client UI that can not be performed generically from the core UI
Declaration
public EPCommandCustomType CustomType { get; }
Property Value
Type | Description |
---|---|
EPCommandCustomType |
From
Declaration
public ICommandDescriptor From { get; set; }
Property Value
Type | Description |
---|---|
ICommandDescriptor |
HasChildCommands
Indicates this command has child commands that should be loaded by the LemonEdge system using LoadChildrenAsync()
The default is false
Declaration
public virtual bool HasChildCommands { get; }
Property Value
Type | Description |
---|---|
bool |
IsQuickAccessCommand
Indicates this command should also be available in a quick access manner if the ui permits it to be highlighted and seperated for quick access among a group of other commands
For instance in the desktop application view commands are accessible from a drop down menu by default, but if this is true they are also directly accessible from the view itself
Declaration
public virtual bool IsQuickAccessCommand { get; }
Property Value
Type | Description |
---|---|
bool |
Key
Indicates the command key to use for executing this from a keyboard command
Declaration
public virtual KeyboardKey Key { get; }
Property Value
Type | Description |
---|---|
KeyboardKey |
LockExecution
An external lock that will disable execution of this command (via CanExecute(object) returning false) until it is set back to the default false.
Declaration
public bool LockExecution { get; set; }
Property Value
Type | Description |
---|---|
bool |
ModifierKeys
Indicates the modifier keys to be used with Key when executing this command from the keyboard
Declaration
public virtual KeyboardModifierKeys ModifierKeys { get; }
Property Value
Type | Description |
---|---|
KeyboardModifierKeys |
Owner
The owning context this command operates within
Declaration
public IModelLayoutCommon? Owner { get; }
Property Value
Type | Description |
---|---|
IModelLayoutCommon |
ReloadChildrenOnEachOpen
Indicates each time this command is "expanded" in the client application that it should reload the child commands in case they have changed
The default is false, in that child commands are only loaded once and cached for the command itself
Declaration
public virtual bool ReloadChildrenOnEachOpen { get; }
Property Value
Type | Description |
---|---|
bool |
RootController
Returns the ModelController, for access to common services.
Declaration
public IRootController RootController { get; }
Property Value
Type | Description |
---|---|
IRootController |
SubscribeToLayoutChange
Indicates this command should track changes to the layouts and reevaluate its Can Execute status.
Used by commands such as Save which change their enabled status depending on the currently active layout
Declaration
protected virtual bool SubscribeToLayoutChange { get; }
Property Value
Type | Description |
---|---|
bool |
Toggler
If this command can toggle between two states, then this toggler implementation provides a mechanism for the command to react to the toggled state changing
Declaration
public IHasToggleStatus Toggler { get; }
Property Value
Type | Description |
---|---|
IHasToggleStatus |
Methods
Dispose()
Declaration
public void Dispose()
Dispose(bool)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
ExternalCanExecute(object)
Returns if this command can be executed from the client application UI.
You must override InternalCanExecute(object?) or InternalCanExecuteAsync(object?) in order to implement if it can be executed
The system also checks if it is currently executing or if it is locked, to return false as wellDeclaration
public Task<bool> ExternalCanExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
Task<bool> | True if this command can currently be executed from the client application UI. |
ExternalExecute(object)
Executes the commands as an asynchronous operation. CanExecute(object) returns False until this call has completed
Declaration
public Task ExternalExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
Task | A task indicating the completion of the command execution |
GetModifierText(IEPCommand)
Returns the helper text indicating how to execute this command using modifier keys. For instance if Key = A, and ModifierKeys = Alt, this would return [Alt+A]
Declaration
public static string GetModifierText(IEPCommand command)
Parameters
Type | Name | Description |
---|---|---|
IEPCommand | command | The command to return the modifier key binding text for |
Returns
Type | Description |
---|---|
string | Helper text indicating how to execute this command using modifier keys. For instance if Key = A, and ModifierKeys = Alt, this would return [Alt+A] |
InternalCanExecute(object?)
Returns if this command can be executed or not from the client application UI
You must override InternalCanExecute(object?) or InternalCanExecuteAsync(object?) in order to implement if it can be executed
Declaration
public virtual bool InternalCanExecute(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
bool | If this command can be executed or not from the client application UI |
InternalCanExecuteAsync(object?)
Returns if this command can be executed or not from the client application UI
You must override InternalCanExecute(object?) or InternalCanExecuteAsync(object?) in order to implement if it can be executed
Declaration
public virtual Task<bool> InternalCanExecuteAsync(object? parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
Task<bool> | If this command can be executed or not from the client application UI |
InternalExecute(object)
You must override InternalExecuteAsync(object) or InternalExecute(object) in order to implement your commands action
Declaration
public virtual void InternalExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
InternalExecuteAsync(object)
You must override InternalExecuteAsync(object) or InternalExecute(object) in order to implement your commands action
Declaration
public virtual Task InternalExecuteAsync(object parameter)
Parameters
Type | Name | Description |
---|---|---|
object | parameter | The command parameter |
Returns
Type | Description |
---|---|
Task |
LoadChildrenAsync()
Provides an inheriting command the opportunity to load any child commands contained within it
Declaration
public virtual Task LoadChildrenAsync()
Returns
Type | Description |
---|---|
Task |
OnCanExecuteChanged()
Provides a mechanism for the command to raise its CanExecuteChanged event
Declaration
public void OnCanExecuteChanged()
OnLayoutsChanged(IModelLayoutHost, LayoutChangeEventArgs)
If SubscribeToLayoutChange is true then this is called everytime the layout changes with the type of change
Declaration
protected virtual void OnLayoutsChanged(IModelLayoutHost sender, LayoutChangeEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
IModelLayoutHost | sender | The source host that is raising the change of layout |
LayoutChangeEventArgs | e | The way in which the main form layouts have changed |
RemoveEventHandlersOnDispose()
Provides an inheriting command the opoortunity to remove any event handlers being listened to before this command is disposed
Declaration
protected virtual void RemoveEventHandlersOnDispose()
SetToggler(IHasToggleStatus)
Sets the toggler to use for this command if it should be represented as a toggle command
Declaration
protected void SetToggler(IHasToggleStatus toggler)
Parameters
Type | Name | Description |
---|---|---|
IHasToggleStatus | toggler | The toggler to use for the Toggler of this command |
Events
CanExecuteChanged
The event indicating the commands can execute has changed
Declaration
public event EventHandler CanExecuteChanged
Event Type
Type | Description |
---|---|
EventHandler |