Table of Contents

Class SimpleMenuCommand

Namespace
CADability.UserInterface
Assembly
CADability.dll

An ICommandHandler made of delegates, for menu items composed in code: the command delegate is called with the menu id when the item is clicked, the optional update delegate sets the CommandState of the item. Create it with HandleCommand(Func<string, bool>) or HandleAndUpdateCommand(Func<string, bool>, Func<string, CommandState, bool>) and assign it to Target. The selection notification is ignored.

public class SimpleMenuCommand : ICommandHandler
Inheritance
SimpleMenuCommand
Implements
Inherited Members

Constructors

SimpleMenuCommand(Func<string, bool>)

Creates a command handler from a command delegate only, see HandleCommand(Func<string, bool>). The item is always enabled.

public SimpleMenuCommand(Func<string, bool> action)

Parameters

action Func<string, bool>

Receives the menu id and returns true if it handled the command

SimpleMenuCommand(Func<string, bool>, Func<string, CommandState, bool>)

Creates a command handler from a command delegate and an update delegate, see HandleAndUpdateCommand(Func<string, bool>, Func<string, CommandState, bool>).

public SimpleMenuCommand(Func<string, bool> action, Func<string, CommandState, bool> update)

Parameters

action Func<string, bool>

Receives the menu id and returns true if it handled the command

update Func<string, CommandState, bool>

Receives the menu id and the CommandState to modify and returns true if it handled the request

Methods

HandleAndUpdateCommand(Func<string, bool>, Func<string, CommandState, bool>)

Creates a command handler that calls action when the menu item is clicked and update to set the state (enabled, checked) of the item before it is shown.

public static ICommandHandler HandleAndUpdateCommand(Func<string, bool> action, Func<string, CommandState, bool> update)

Parameters

action Func<string, bool>

Receives the menu id and returns true if it handled the command

update Func<string, CommandState, bool>

Receives the menu id and the CommandState to modify and returns true if it handled the request

Returns

ICommandHandler

The handler to assign to Target

HandleCommand(Func<string, bool>)

Creates a command handler that calls action when the menu item is clicked. The item is always enabled.

public static ICommandHandler HandleCommand(Func<string, bool> action)

Parameters

action Func<string, bool>

Receives the menu id and returns true if it handled the command

Returns

ICommandHandler

The handler to assign to Target