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
Implements
Inherited Members
Namespace: LemonEdge.Client.Core.Commands
Assembly: ClientCore.dll
Syntax
public abstract class EPCommand : BaseHasChildren<EPCommandWithDescriptor>, IHasChildren<EPCommandWithDescriptor>, IHasChildren, IEPCommand, ICommand, IDisposable
Constructors
EPCommand(IModelLayoutCommon, EPCommandWithDescriptor)
Creates a new EPCommand
Declaration
protected EPCommand(IModelLayoutCommon owner, EPCommandWithDescriptor parent = null)
Parameters
Type | Name | Description |
---|---|---|
IModelLayoutCommon | owner | The owning context this command operates within |
EPCommandWithDescriptor | parent | An optional parent command if this command is a child command |
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 IModelLayouHost
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 |
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 |
---|---|
System.Boolean |
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 System.Windows.Input.ICommand.CanExecute(System.Object) returning false) until it is set back to the default false.
Declaration
public bool LockExecution { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
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 |
---|---|
System.Boolean |
Seperator
The static separator instance that has no command action
Declaration
public static ViewCommandSeperator Seperator { get; }
Property Value
Type | Description |
---|---|
ViewCommandSeperator |
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
public virtual bool SubscribeToLayoutChange { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
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(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | 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 |
---|---|---|
System.Object | parameter | The command parameter |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | True if this command can currently be executed from the client application UI. |
ExternalExecute(Object)
Executes the commans as an asynchronous operation. System.Windows.Input.ICommand.CanExecute(System.Object) returns False until this call has completed
Declaration
public Task ExternalExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parameter | The command parameter |
Returns
Type | Description |
---|---|
System.Threading.Tasks.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 commmand to return the modifier key binding text for |
Returns
Type | Description |
---|---|
System.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 |
---|---|---|
System.Object | parameter | The command parameter |
Returns
Type | Description |
---|---|
System.Boolean | 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 |
---|---|---|
System.Object | parameter | The command parameter |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | 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 |
---|---|---|
System.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 |
---|---|---|
System.Object | parameter | The command parameter |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
LoadChildrenAsync()
Provides an inheriting command the opportunity to load any child commands contained within it
Declaration
public virtual Task LoadChildrenAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
OnCanExecuteChanged()
Provides a mechanism for the command to raise its
Declaration
public void OnCanExecuteChanged()
OnLayoutsChanged(IModelLayouHost, LayoutChangeEventArgs)
If SubscribeToLayoutChange is true then this is called everytime the layout changes with the type of change
Declaration
protected virtual void OnLayoutsChanged(IModelLayouHost sender, LayoutChangeEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
IModelLayouHost | 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 |
---|---|
System.EventHandler |
Explicit Interface Implementations
ICommand.CanExecute(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
bool ICommand.CanExecute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parameter | The command parameter |
Returns
Type | Description |
---|---|
System.Boolean | True if this command can currently be executed from the client application UI. |
ICommand.Execute(Object)
Executes the command.
Either InternalExecute(Object) or InternalExecuteAsync(Object) must be overridden by the implementing command
The execution is done manner where System.Windows.Input.ICommand.CanExecute(System.Object) will return false until it has finished processingDeclaration
void ICommand.Execute(object parameter)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parameter | The command parameter |