This is the third 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
SmartPart QS
This is a list of the procedures in this post:
Startup
- The shell defines BrowseCustomerWorkItem as the default WorkItem and MainForm as the starting view.
- The List is set in the OVERLOADED BeforeShellCreated() method.
- The Run() method is called in the root WorkItem (BrowseCustomerWorkItem).
- The OnRunStarted() method at BrowseCustomerWorkItem starts the CustomerView SmartPart in the MainForm’s Workspace.
- The customer view is split (SplitContainer) between a CustomerListView SmartPart and a DeckWorkspace.
- Using Dependency Injection [CreateNew] initializes a new instance of CustomerControllers.
- The CustomerControllers gets the list of Customers ([State("Customers")])
- The OnLoad() event handler fills the customers at the Controller and by using the State updates List<Customers> in the view to fill the ListBox.
- Then it registers the SelectedIndexChanged event from the ListBox.
SelectedIndexChanged Event (ListView)
- The SelectedIndexChanged event fires and calls the controller’s ShowCustomerDetails() Method, passing the customer as a parameter.
- The controller then calls the ShowCustomerDetails() method of the BrowseCustomersWorkItem.
- The ShowCustomerDetails() method injects the “Customer” State into Child Workitems.
- It then adds a new ViewCustomerWorkItem (as a child WorkItem) and assigns the customerWorkItem.Customer property to the current “Customer” State.
- The customerWorkItem.Run() Method is called passing the CustomersDeckedWorkspace as a parameter.
- The Run method creates the views to be used by the WorkItem (CustomerTabView, which has the DetailsView in the CustomerTabView designer (this.customerDetailView1 = new SmartPartQuickStart.ViewCustomerWorkItem.CustomerDetailView();), and the CustomerSummaryView)
- Then calls the workspace.Show() method, with the CustomerTabView as a parameter, to show the view in the workspace.
- The CustomerDetailView uses dependency injection to [CreateNew]CustomerController (no “s”).
- The OnLoadMethod adds the customer to the controls.
Comments Button
- Gets the [State (“Customer”)] from the ViewCustomerWorkItem.
- The OnLoad() event handler adds the Customer (provided by the State) to the BindingSource.
- Fires the Click event handler.
- Calls the CutomerController ShowCustomerComments() method.
- By using [Service Dependency], the Controller gets a reference to ViewCustomerWorkItem.
- Then the ShowCustomerComments() method calls the ViewCustomerWorkItemShowCustomerComments() method.
- Creates a Workspace called tabbedspace.
- Adds a CustomerCommentsView SmartPart to the ViewCustomerWorkItem.
- The CustomerCommentsView:
- Creates a new SmartPartInfo and assigns (“Comments”) to the SmartPartInfo title.
- Registers the SmartPartInfo to the CustomerCommentsView.
- Shows the tabbedspace (WorkSpace).
The next post will be about the Commands QS, be sure to read it.