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:
- http://msdn.microsoft.com/en-us/library/aa480450.aspx
- CAB introduction posts (Spanish) by Mariano
- Composite UI Application Block(Spanish) by Jonathan
Commands QS
This is a list of the procedures in this post
Startup
- The shell defines the MainWorkItem as the root WorkItem and the ShellForm as the first view.
- The overridden AfterShellCreated() method assigns to fileitem = ToolStripMenuItem [“File”].
- An ExtensionSite is registered in the MainWorkItem, named “File” and is a DropDownItem.
- The MainWorkItem overridden OnRunStarted() creates a new instace of the MainController and adds it to the Workitem’s Item Collection.
- 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.
- Activates the WorkItem.
Menu Item Clicking
- The CommandHandler related to the click event raised by the item is called.
- There are two kind of CommandHandlers now.
- The ShowCustomerHandler that MessageBox.Show(“”);
- The status kind. These 3 change the CommandStatus according to the ToolStripMenuItem pressed. (Enabled|Disabled|Unavailable(not visible in this case))
- 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.