CAB Quickstarts: Commands

This is the forth post of a series that covers the basic ground of CAB QuickStarts from a simple point of view.

Other posts in this series

For more information about CAB see:

Commands QS

This is a list of the procedures in this post

Startup

  1. The shell defines the MainWorkItem as the root WorkItem and the ShellForm as the first view.
  2. The overridden AfterShellCreated() method assigns to fileitem = ToolStripMenuItem [“File”].
  3. An ExtensionSite is registered in the MainWorkItem, named “File” and is a DropDownItem.
  4. The MainWorkItem overridden OnRunStarted() creates a new instace of the MainController and adds it to the Workitem’s Item Collection.
  5. The ProcessCommandMap() method is called, which:
    • Loads Command Configuration File.
    • Executes a foreach statement in the CommandMap.Mapping [array]
      • Creates a ToolStripMenuItem (MenuItem.Text = mapping.Label)
      • Adds to the [“File”] Extension Site (using mapping.Site as the parameter) the ToolStripMenuItem.
      • Adds to the Commands (Collection) the invoker for the “Click” event using the AddInvoker() method.
  6. Activates the WorkItem.

Menu Item Clicking

  1. The CommandHandler related to the click event raised by the item is called.
  2. There are two kind of CommandHandlers now.
    1. The ShowCustomerHandler that MessageBox.Show(“”);
    2. The status kind. These 3 change the CommandStatus according to the ToolStripMenuItem pressed. (Enabled|Disabled|Unavailable(not visible in this case))
    3. The ToolStripItemCommandAdapter “listens” to the CommandChanged event, and based on it changes the Enabled/Visible property of the ShowCustomerHandler ToolStripMenuItem.

The next and final post in the series will cover the BankTeller QS.