CAB Quickstarts: SmartPart

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:

SmartPart QS

This is a list of the procedures in this post:

Startup

  1. The shell defines BrowseCustomerWorkItem as the default WorkItem and MainForm as the starting view.
  2. The List is set in the OVERLOADED BeforeShellCreated() method.
  3. The Run() method is called in the root WorkItem (BrowseCustomerWorkItem).
  4. The OnRunStarted() method at BrowseCustomerWorkItem starts the CustomerView SmartPart in the MainForm’s Workspace.
  5. The customer view is split (SplitContainer) between a CustomerListView SmartPart and a DeckWorkspace.
  6. Using Dependency Injection [CreateNew] initializes a new instance of CustomerControllers.
  7. The CustomerControllers gets the list of Customers ([State("Customers")])
  8. 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.
  9. Then it registers the SelectedIndexChanged event from the ListBox.

SelectedIndexChanged Event (ListView)

  1. The SelectedIndexChanged event fires and calls the controller’s ShowCustomerDetails() Method, passing the customer as a parameter.
  2. The controller then calls the ShowCustomerDetails() method of the BrowseCustomersWorkItem.
  3. The ShowCustomerDetails() method injects the “Customer” State into Child Workitems.
  4. It then adds a new ViewCustomerWorkItem (as a child WorkItem) and assigns the customerWorkItem.Customer property to the current “Customer” State.
  5. The customerWorkItem.Run() Method is called passing the CustomersDeckedWorkspace as a parameter.
  6. 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)
  7. Then calls the workspace.Show() method, with the CustomerTabView as a parameter, to show the view in the workspace.
  8. The CustomerDetailView uses dependency injection to [CreateNew]CustomerController (no “s”).
  9. The OnLoadMethod adds the customer to the controls.

Comments Button

  1. Gets the [State (“Customer”)] from the ViewCustomerWorkItem.
  2. The OnLoad() event handler adds the Customer (provided by the State) to the BindingSource.
  3. Fires the Click event handler.
  4. Calls the CutomerController ShowCustomerComments() method.
  5. By using [Service Dependency], the Controller gets a reference to ViewCustomerWorkItem.
  6. Then the ShowCustomerComments() method calls the ViewCustomerWorkItemShowCustomerComments() method.
  7. Creates a Workspace called tabbedspace.
  8. Adds a CustomerCommentsView SmartPart to the ViewCustomerWorkItem.
  9. The CustomerCommentsView:
    1. Creates a new SmartPartInfo and assigns (“Comments”) to the SmartPartInfo title.
    2. Registers the SmartPartInfo to the CustomerCommentsView.
    3. Shows the tabbedspace (WorkSpace).

The next post will be about the Commands QS, be sure to read it.