To define Smart Client Software Factory, we need to understand the Composite Smart Client Application. This describes a smart client that combines several loosely coupled modules in one shell. They for instance share a menu, status bar and several services, but remain independent besides those. A smart client is the name that is used, mainly by Microsoft , for a client application that combines the rich GUI of the well-known windows applications like Word and Excel (the fat client) with the connectedness of a browser application (thin client). The Smart Client Software Factory, that has such a smart client as an end result, consists of: 1) A number of libraries that give you the possibility to make a smart client with a composite GUI. These libraries also contain solutions for recurring problems in logging, caching, etc. 2) The possibility to combine these standard elements in a configurable and pre-determined manner to form an application. This is done through the use of wizards in Visual Studio. The SCSF makes use of the Composite UI Application Block (CAB). This application block is meant to support the development of a smart client with a GUI that contains dynamically loaded modules that are loosely coupled between each other and to the GUI. This loose coupling is realised by events with a (string based) URL, standard command objects that can be dynamically loaded and services that are declares as interfaces. The coupling is performed by the CAB when a module is loaded. This architecture is built with a regularly changing mix of modules in mind. Understanding Composite UI Application Block The Composite UI Application Block is a framework based on .NET 2.0, developed the patterns & practices team to assist anyone building complex UIs using Winforms. The key design pattern: composability, allows more complex UIs to be assembled from simpler “parts” (SmartParts as called in CAB architecture, “WinParts” in other architectures). The key point is that if we want our components to be released independently then they can’t have direct references to each other (Loosely coupling). In short we want ‘applications’ or components that appear in the same user interface (same window) with common menus and some ability to talk to each other, but don’t directly reference each other. To create a Smart Client Project, you’ll need:
- Supported Operating Systems: Windows Server 2003; Windows Vista; Windows XP
- Smart Client Software Factory – April 2008
- Microsoft Visual Studio 2008
- Microsoft .NET Framework 3.5
- Guidance Automation Extensions (February 2008 or later)
- Enterprise Library 4.1-October 2008
- SQL Server 2005 Compact Edition
Create Your Hello World Application This section describes how to create and display a view using the software factory. To create your first Hello World application, perform the procedures in this section.
| Note: The following procedures require the guidance package to be installed. |
To create a new smart client application project
- In Visual Studio 2008, point to New on the File menu, and then click Project.
- In the New Project dialog box, expand Guidance Packages Project, and then select Smart Client Development – April 2008.
- Select the Smart Client Application (C#) Visual Studio template.
- In the Name box, type HelloWorldApplication, and then click OK.
- In the wizard, accept the default settings, select the Show documentation after recipe completes check box, and then click Finish.

Figure 1: Solution Structure
The smart client solution unfolded by the Smart Client Application template is composed of the following projects:
- Infrastructure.Layout (only if you selected the option to create a separate module to define the layout for the Shell)
- Infrastructure.Interface. This project contains the event topic names, UI extension site names, command names, and workspace names that are the public interface to the Infrastructure.Module module.
- Infrastructure.Library. This project contains common components used by a set of smart client applications. For example, it includes the service to retrieve the profile catalog from a Web service.
- Infrastructure.Module. This project contains elements that are shared across projects in your smart client solution.
- Shell. This project is the basis of a typical Composite UI Application Block application. It contains the startup form and the root WorkItem.
Infrastructure.Interface
This project is the interface for infrastructure modules and contains only the elements that have to be exposed to other modules of the application. It is composed of service interfaces, constant definitions, business entities (only those that are passed between modules), and other shared elements, such as general purpose base classes.
Constant Definitions
Commands, event topics, UI extension sites, and workspaces are identified by unique strings. These unique strings are defined as constants for each of these element types, grouped in different classes located in the Constants folder.
CommandNames Class
The Composite UI Application Block uses commands to easily assign the same executable code to multiple user interface elements. For example, you can have a toolbar button and menu item execute the same code. You do this by executing the same command for both the toolbar button and menu item. Each command has a unique string identifier. The CommandNames class contains definitions for the command identifiers that are global to the application.
EventTopicNames class
The Composite UI Application Block includes an event broker system that enables you to publish events that allow communication between components in WorkItems. The event name is a string that identifies the event. The EventTopicNames class contains definitions for the event topic identifiers that are global to the application.
UIExtensionSiteNames Class
A Composite UI Application Block UIExtensionSite is a named user interface element that can support child elements. Each UIExtensionSite is identified by a unique string value. This string is used to identify elements when interacting with and adding child elements to that site, such as when adding a menu item to a menu bar. The UIExtensionSiteNames class contains definitions for the UIExtensionSite identifiers that are global to the application.
WorkspaceNames Class
Workspaces are components that encapsulate a particular visual way of displaying controls and SmartParts. Each Workspace is identified by a unique string value. The WorkspaceNames class contains definitions for the Workspace identifiers that are global to the application.
Business Entities
The BusinessEntities folder contains business entity classes. These are class definitions for business object instances that are shared by different modules in the smart client application. For example business entities, see the BusinessEntities folder of the Infrastructure.Interface project in the Bank Branch Client reference implementation.
Service Interfaces
The Services folder contains interfaces for public services (services that WorkItems in other projects can consume). For an example of this, see the Services folder of the Infrastructure.Interface project of the Bank Branch Client reference implementation.
EventArgs Class
Different event handlers can expect different argument types. The EventArgs class is a generic class that allows you to specify a type-safe argument for use in event publishing and subscription.
Classes to Partition Business Logic and WorkItem Code
The WorkItemController is an abstract base class that contains a WorkItem. This class contains logic that would otherwise exist in the WorkItem. You can use this class to partition your code between a class that derives from WorkItemController and a WorkItem. When you create a new Composite UI Application Block module using the Add Business Module template, a ModuleController class is automatically added to control the WorkItem of the module. This class is a specialization of the WorkItemController class. For an example of a ModuleController class, see the Composite UI Application Block module in the Bank Branch Client reference implementation. The ControlledWorkItem represents a WorkItem that is managed by another class. The other class is the controller and contains the business logic (the WorkItem provides the container).
Presenter Base Class
This class contains code that would otherwise be repeated in every presenter when using the Model-View-Presenter (MVP) pattern. It includes a reference to a generic view and a reference to the WorkItem it belongs to. It also provides virtual methods to work with the controlled view. To see examples of classes that derive from the Presenter class, see the presenters in the Views folder of the BranchSystems.Module project in the Bank Branch Client reference implementation.
ActionAttribute
This attribute is used to specify that a segment of code is a business action. Whenever you create an object with ObjectBuilder, a strategy will register each method decorated with this attribute as a business action in the action catalog. For more information, see How to: Use the Action Catalog.
Infrastructure.Module
This project is a Composite UI Application Block module that acts as a container for the implementation of elements that are shared across projects in your smart client application. When the CreateSolution recipe is executed, this module is added to the profile catalog. This means that Composite UI Application Block loads the Infrastructure.Module module when the application starts. When created, this module is empty. You modify it to include the implementation of elements that different modules of your application will use, such as services. For example, the Infrastructure.Module in the Bank Branch Client reference implementation module adds the impersonation service to the root WorkItem
.
Infrastructure.Library
This project contains the implementation of elements that are common to a set of smart client applications.
SmartClientApplication Base Class
This class extends FormShellApplication, which performs all the initial tasks that are required to start the application, including creating the default root WorkItem, adding the standard set of services, and loading any services and modules that are defined in the profile or configuration of the application. The SmartClientApplication class adds additional services to the root WorkItem that will be consumed from different projects of your smart client application. For instance, it adds the action catalog service (IActionCatalogService) and the entity translator service (IEntityTranslatorService).
Builder Strategies
The Infrastructure.Library project contains an ObjectBuilder strategy named ActionStrategy. This strategy is used to reflect on methods of objects that have the Action attribute to register them with the action catalog. For more information, see How to: Use the Action Catalog
.
Services and User Interface Elements
Services and UI folders contain implementation of services and user interface elements common to a set of smart client applications. It includes the following elements:
- Action catalog service. You can use the action catalog to control whether a business action is executed. For more information, see How to: Use the Action Catalog.
- Module loading and enumeration services. These services extend Composite UI Application Block built-in services to provide extra features, such as loading modules depending on user roles and retrieving the profile catalog from a Web service.
- Entity translator service. This service allows you to translate entities from one type to another, and vice versa. For more information, see How to: Translate Between Business Entities and Service Entities.
- Workspace locator service. This service searches for SmartParts in a particular WorkItem and returns a reference to the workspace it belongs to.
- WindowsWorkspace. This is a wrapper for the Composite UI Application Block built-in WindowsWorkspace. It allows you set property values for controls of the modal window.
Shell
This project is the shell for the application. It provides the overall user interface structure and contains the root WorkItem. The basis of the smart client application is the ShellApplication class, which contains the program entry code to load and run the application. This class extends SmartClientApplication class, which makes it easier to start building an application that will have a startup form.
Startup Form
The ShellForm is the startup form of the application. It contains two workspaces, the LeftWorkspace and the RightWorkspace, as shown in Figure 4. If you define the layout for the shell in a separate module, the ShellForm contains only a DeckWorkspace. Figure 5 illustrates the ShellForm when a solution contains a separate module that defines the layout.

Figure 2: ShellForm for an application without a separate module that defines the layout
Module Catalog File
The Shell also contains the module catalog file, named ProfileCatalog.xml. The Composite UI Application Block provides a service to load modules when the application starts. By default, it uses the XML catalog file to determine the modules to load.
| Note: |
| You can modify your smart client solution to retrieve the catalog from other data sources. For example, the Bank Branch Client reference implementation retrieves the module catalog from a Web service. |
Infrastructure.Layout
The Infrastructure.Layout project is a module that provides a view that defines the layout of the shell. This project is only created for foundational modules with the option to create a separate module for layout selected. To create a Hello World module
- In Solution Explorer, right-click the solution, point to Smart Client Software Factory, and then click Add Business Module (C#).
- In the Add New Project dialog box, type HelloWorldModule in the Name box.
- Click OK.
- In the wizard, accept the default settings, select the Show documentation after recipe completes check box, and then click Finish.
To add a Hello World view
- In Solution Explorer, right-click HelloWorldModule, point to Smart Client Software Factory, and then click Add View (with presenter).
- In the Add New View (with presenter) dialog box, type HelloWorldView in the View box, select the Show documentation after recipe completes check box, and then click Finish.
- In Solution Explorer, double-click the file HelloWorldView.cs to view it in the Designer.* Drag a *text box onto the view, and set the text to Hello World.
To configure HelloWorldView to display on the shell’s right workspace
1. In Solution Explorer, open ModuleController.cs in the HelloWorldModule project. 2. Add the following code.
using HelloWorldApplication.Infrastructure.Interface.Constants;
3. In the AddViews method, add the following code.
// Add the HelloWorld view (smart part) to the WorkItem and show // the view through the RightWorkspace on the shell. HelloWorldView hwview = ShowViewInWorkspace< HelloWorldView >(WorkspaceNames.RightWorkspace);
4. Press F5 to build and run your Hello World application. 5. On the File menu, click Exit. Communicating Between Views To prepare a solution for this topic
- Install the Smart Client Development Package. For information about how to install this guidance package, see Guidance Automation.
- Use the Visual Studio template Smart Client Application to create the initial smart client solution. For information about how to create a solution with this template, see How to: Create Smart Client Solutions.
- Use the Add View (with presenter) recipe to create a view in the Shell project. Enter LeftView for the name of the view.
- Use the Add View (with presenter) recipe to create a view in the Shell project. Enter RightView for the name of the view.
Steps To implement the communication between views, add the code that performs the following:
- Define the event topic.
- Publish the event from the presenter for the LeftView view.
- Capture a button click in the view LeftView.
- Refresh the view RightView.
- Subscribe to the event in the presenter for the RightView view.
To define an event topic
- Open the file EventTopicNames.cs that is located in the Constants folder of the Infrastructure.Interface project.
- Add the constant definition, as shown in the following code.
| public const string ChangeColor = “ChangeColor”; |
| Note: |
| The following procedure uses “rootnamespace” to refer to the root namespace that you used when you created your smart client solution. Replace “rootnamespace” with your application’s root namespace. |
To create the code to publish the event
- Open the file LeftViewPresenter.cs.
- Add the following using statements.
using rootnamespace.Infrastructure.Interface.Constants; using Microsoft.Practices.CompositeUI.EventBroker; |
|
- Add the code to declare the event handler, as shown in the following code.
[EventPublication(EventTopicNames.ChangeColor, PublicationScope.Global)] public event EventHandler<eventargs> ChangeColor; |
|
- Add the code to publish the event, as shown in the following code.
public void ChangeViewColor() { Random random = new Random(); int r = random.Next(256); int g = random.Next(256); int b = random.Next(256); System.Drawing.Color color = System.Drawing.Color.FromArgb(r,g,b); if (ChangeColor != null) { ChangeColor(this, new EventArgs<system .Drawing.Color>(color)); } }
To capture the button click and call the presenter
- In Solution Explorer, right-click LeftView.cs, and then click View Designer.
- Drag a button from the Visual Studio Toolbox onto the LeftView view. Change the name of the button to changeColorButton.
- Double-click the changeColorButton button. Visual Studio creates the method changeColorButton_Click.
- Implement the changeColorButton_Click method, as shown in the following code.
private void changeColorButton_Click(object sender, System.EventArgs e) { _presenter.ChangeViewColor(); }
To create the code to update the right view
- In Solution Explorer, right-click IRightView.cs, and then click View Code.
- Add the method, as shown in the following code.
void ChangeColor(System.Drawing.Color color);
- In Solution Explorer, right-click RightView.cs, and then click View Code.
- Add a method that changes the background color of the view, as shown in the following code.
public void ChangeColor(System.Drawing.Color color) { this.BackColor = color; }
To create the code to subscribe to the event
- Open the file RightViewPresenter.cs.
- Add the following using statements.
using rootnamespace.Infrastructure.Interface.Constants; using Microsoft.Practices.CompositeUI.EventBroker;
- Add the code to subscribe to the event and notify the view, as shown in the following code.
[EventSubscription(EventTopicNames.ChangeColor, Thread = ThreadOption.UserInterface)] public void ChangeColorHandler(object sender, EventArgs</system><system .Drawing.Color> e) { View.ChangeColor(e.Data); }
Enjoy Smart Client, Bora Bilgin Note: Most parts of this article are compiled from original Smart Client Software Factory from Microsoft, and Rich Newman‘s blog. Note 2: I think that Rich Newman’s notes on SCSF/CAB are far more better than the original documentation

wanted to start smart classes in our school at rural area in dehra dun.
bonjour comment ça va?
how to study it?