C# Класс Catel.MVVM.CommandManager

Manager that takes care of application-wide commands and can dynamically forward them to the right view models.
Наследование: ICommandManager
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
OnWindowLoaded ( object sender, RoutedEventArgs e ) : void

Описание методов

CommandManager() публичный Метод

Initializes a new instance of the CommandManager class.
public CommandManager ( ) : System
Результат System

CreateCommand() публичный Метод

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.
Результат void

CreateCommand() публичный Метод

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.
Результат void

ExecuteCommand() публичный Метод

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.
Результат void

GetCommand() публичный Метод

Gets the command created with the command name.
The is null or whitespace.
public GetCommand ( string commandName ) : ICommand
commandName string Name of the command.
Результат ICommand

GetCommands() публичный Метод

Gets all the registered commands.
public GetCommands ( ) : IEnumerable
Результат IEnumerable

GetInputGesture() публичный Метод

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.
Результат Catel.Windows.Input.InputGesture

GetOriginalInputGesture() публичный Метод

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.
Результат Catel.Windows.Input.InputGesture

InvalidateCommands() публичный Метод

Invalidates the all the currently registered commands.
public InvalidateCommands ( ) : void
Результат void

IsCommandCreated() публичный Метод

Determines whether the specified command name is created.
The is null or whitespace.
public IsCommandCreated ( string commandName ) : bool
commandName string Name of the command.
Результат bool

RegisterAction() публичный Метод

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.
Результат void

RegisterAction() публичный Метод

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.
Результат void

RegisterCommand() публичный Метод

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.
Результат void

ResetInputGestures() публичный Метод

Resets the input gestures to the original input gestures with which the commands were registered.
public ResetInputGestures ( ) : void
Результат void

SubscribeToKeyboardEvents() публичный Метод

Subscribes to keyboard events.
public SubscribeToKeyboardEvents ( ) : void
Результат void

SubscribeToKeyboardEvents() публичный Метод

Subscribes to keyboard events.
The is null.
public SubscribeToKeyboardEvents ( FrameworkElement view ) : void
view System.Windows.FrameworkElement The view.
Результат void

UnregisterAction() публичный Метод

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.
Результат void

UnregisterAction() публичный Метод

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.
Результат void

UnregisterCommand() публичный Метод

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.
Результат void

UpdateInputGesture() публичный Метод

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.
Результат void