C# Class Catel.MVVM.CommandManager

Manager that takes care of application-wide commands and can dynamically forward them to the right view models.
Inheritance: ICommandManager
Show file Open project: Catel/Catel Class Usage Examples

Public Methods

Method Description
CommandManager ( ) : System

Initializes a new instance of the CommandManager class.

CreateCommand ( string commandName, Catel.Windows.Input.InputGesture inputGesture = null, ICompositeCommand compositeCommand = null, bool throwExceptionWhenCommandIsAlreadyCreated = true ) : void

Creates the command inside the command manager. If the throwExceptionWhenCommandIsAlreadyCreated is false and the command is already created, only the input gesture is updated for the existing command.

CreateCommand ( string commandName, ICompositeCommand compositeCommand = null, bool throwExceptionWhenCommandIsAlreadyCreated = true ) : void

Creates the command inside the command manager.

ExecuteCommand ( string commandName ) : void

Executes the command.

GetCommand ( string commandName ) : ICommand

Gets the command created with the command name.

GetCommands ( ) : IEnumerable

Gets all the registered commands.

GetInputGesture ( string commandName ) : Catel.Windows.Input.InputGesture

Gets the input gesture for the specified command.

GetOriginalInputGesture ( string commandName ) : Catel.Windows.Input.InputGesture

Gets the original input gesture with which the command was initially created.

InvalidateCommands ( ) : void

Invalidates the all the currently registered commands.

IsCommandCreated ( string commandName ) : bool

Determines whether the specified command name is created.

RegisterAction ( string commandName, System.Action action ) : void

Registers the action with the specified command name.

RegisterAction ( string commandName, Action action ) : void

Registers the action with the specified command name.

RegisterCommand ( string commandName, ICommand command, IViewModel viewModel = null ) : void

Registers a command with the specified command name.

ResetInputGestures ( ) : void

Resets the input gestures to the original input gestures with which the commands were registered.

SubscribeToKeyboardEvents ( ) : void

Subscribes to keyboard events.

SubscribeToKeyboardEvents ( FrameworkElement view ) : void

Subscribes to keyboard events.

UnregisterAction ( string commandName, System.Action action ) : void

Unregisters the action with the specified command name.

UnregisterAction ( string commandName, Action action ) : void

Unregisters the action with the specified command name.

UnregisterCommand ( string commandName, ICommand command ) : void

Unregisters a command with the specified command name.

UpdateInputGesture ( string commandName, Catel.Windows.Input.InputGesture inputGesture = null ) : void

Updates the input gesture for the specified command.

Private Methods

Method Description
OnWindowLoaded ( object sender, RoutedEventArgs e ) : void

Method Details

CommandManager() public method

Initializes a new instance of the CommandManager class.
public CommandManager ( ) : System
return System

CreateCommand() public method

Creates the command inside the command manager. If the throwExceptionWhenCommandIsAlreadyCreated is false and the command is already created, only the input gesture is updated for the existing command.
The is null or whitespace. The specified command is already created using the method.
public CreateCommand ( string commandName, Catel.Windows.Input.InputGesture inputGesture = null, ICompositeCommand compositeCommand = null, bool throwExceptionWhenCommandIsAlreadyCreated = true ) : void
commandName string Name of the command.
inputGesture Catel.Windows.Input.InputGesture The input gesture.
compositeCommand ICompositeCommand The composite command. If null, this will default to a new instance of .
throwExceptionWhenCommandIsAlreadyCreated bool if set to true, this method will throw an exception when the command is already created.
return void

CreateCommand() public method

Creates the command inside the command manager.
The is null or whitespace. The specified command is already created using the method.
public CreateCommand ( string commandName, ICompositeCommand compositeCommand = null, bool throwExceptionWhenCommandIsAlreadyCreated = true ) : void
commandName string Name of the command.
compositeCommand ICompositeCommand The composite command. If null, this will default to a new instance of .
throwExceptionWhenCommandIsAlreadyCreated bool if set to true, this method will throw an exception when the command is already created.
return void

ExecuteCommand() public method

Executes the command.
The is null or whitespace. The specified command is not created using the method.
public ExecuteCommand ( string commandName ) : void
commandName string Name of the command.
return void

GetCommand() public method

Gets the command created with the command name.
The is null or whitespace.
public GetCommand ( string commandName ) : ICommand
commandName string Name of the command.
return ICommand

GetCommands() public method

Gets all the registered commands.
public GetCommands ( ) : IEnumerable
return IEnumerable

GetInputGesture() public method

Gets the input gesture for the specified command.
The specified command is not created using the method.
public GetInputGesture ( string commandName ) : Catel.Windows.Input.InputGesture
commandName string Name of the command.
return Catel.Windows.Input.InputGesture

GetOriginalInputGesture() public method

Gets the original input gesture with which the command was initially created.
The specified command is not created using the method.
public GetOriginalInputGesture ( string commandName ) : Catel.Windows.Input.InputGesture
commandName string Name of the command.
return Catel.Windows.Input.InputGesture

InvalidateCommands() public method

Invalidates the all the currently registered commands.
public InvalidateCommands ( ) : void
return void

IsCommandCreated() public method

Determines whether the specified command name is created.
The is null or whitespace.
public IsCommandCreated ( string commandName ) : bool
commandName string Name of the command.
return bool

RegisterAction() public method

Registers the action with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public RegisterAction ( string commandName, System.Action action ) : void
commandName string Name of the command.
action System.Action The action.
return void

RegisterAction() public method

Registers the action with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public RegisterAction ( string commandName, Action action ) : void
commandName string Name of the command.
action Action The action.
return void

RegisterCommand() public method

Registers a command with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public RegisterCommand ( string commandName, ICommand command, IViewModel viewModel = null ) : void
commandName string Name of the command.
command ICommand The command.
viewModel IViewModel The view model.
return void

ResetInputGestures() public method

Resets the input gestures to the original input gestures with which the commands were registered.
public ResetInputGestures ( ) : void
return void

SubscribeToKeyboardEvents() public method

Subscribes to keyboard events.
public SubscribeToKeyboardEvents ( ) : void
return void

SubscribeToKeyboardEvents() public method

Subscribes to keyboard events.
The is null.
public SubscribeToKeyboardEvents ( FrameworkElement view ) : void
view System.Windows.FrameworkElement The view.
return void

UnregisterAction() public method

Unregisters the action with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public UnregisterAction ( string commandName, System.Action action ) : void
commandName string Name of the command.
action System.Action The action.
return void

UnregisterAction() public method

Unregisters the action with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public UnregisterAction ( string commandName, Action action ) : void
commandName string Name of the command.
action Action The action.
return void

UnregisterCommand() public method

Unregisters a command with the specified command name.
The is null or whitespace. The is null. The specified command is not created using the method.
public UnregisterCommand ( string commandName, ICommand command ) : void
commandName string Name of the command.
command ICommand The command.
return void

UpdateInputGesture() public method

Updates the input gesture for the specified command.
The is null or whitespace. The specified command is not created using the method.
public UpdateInputGesture ( string commandName, Catel.Windows.Input.InputGesture inputGesture = null ) : void
commandName string Name of the command.
inputGesture Catel.Windows.Input.InputGesture The new input gesture.
return void