Getting Started with the Smart Client Software Factory 2010

Are you new to the Smart Client Software Factory? The best way to get familiar with the Smart Client Software Factory is to do the following:
  • Build a Hello World application. For information about how to do this, see the section, Create Your Hello World Application, that follows.
  • Run the QuickStarts included with the software factory. The BankTeller QuickStart helps you understand the Composite UI Application Block, which is now included with the software factory. For information about the QuickStarts, see the "QuickStarts" topic in the documentation.
  • Download and complete the Hands-on-Labs.
  • Review the "Exploring the Smart Client Software Factory" topic in the documentation.

Just want to review the documentation

If you are in the evaluation phase of the factory, you can download the documentation before downloading the factory. Then when you are ready, you can download the factory.

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

  1. In Visual Studio 2010, point to New on the File menu, and then click Project.
  2. In the New Project dialog box, expand Guidance Packages Project, and then select Smart Client Development May 2010.
  3. Select the Smart Client Application (C#) Visual Studio template.
  4. In the Name box, type HelloWorldApplication, and then click OK.
  5. In the wizard, accept the default settings, and then click Finish.

To create a Hello World module

  1. In Solution Explorer, right-click the solution, point to Smart Client Software Factory, and then click Add Business Module (C#).
  2. In the Add New Project dialog box, type HelloWorldModule in the Name box.
  3. Click OK.
  4. In the wizard, accept the default settings, and then click Finish.

To add a Hello World view

  1. In Solution Explorer, right-click HelloWorldModule, point to Smart Client Software Factory, and then click Add View (with presenter).
  2. In the Add New View (with presenter) dialog box, type HelloWorldView in the View box, and then click Finish.
  3. 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.
C#
 using HelloWorldApplication.Infrastructure.Interface.Constants;

3. In the AddViews method, add the following code.
 C#
 // 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.

Next, you will associate a command with a menu item to display the Hello World text box.

To extend your first Hello World application to use a toolbar and command

1. Comment out the following code in the AddViews method in the ModuleController.cs file so that the text box does not automatically appear.
 C#
 // 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);

2. Extend the main toolbar:
a. In Solution Explorer, expand the Constants folder under the HelloWorldModule project, and then double-click CommandNames.cs to open the file.
b. Add the following code to the CommandNames class. This defines the ShowHelloWorldMessage command constant.
 C#
 // A command is an abstraction of UI elements events,
 // such as the click of a button. 
     public const string ShowHelloWorldMessage = "ShowHelloWorldMessage"; 

c. In Solution Explorer, under the HelloWorldModule project, double-click ModuleController.cs to open the file.
d. Add the following code to the ExtendToolStrip method.
 C#
    AddToolStripButton(Constants.CommandNames.ShowHelloWorldMessage, "Hello World");

e. Add the following code to implement the AddToolStripButton method.
 C#
 // This method creates a ToolStripButton and adds it to the
 // MainToolbar using the UIExtensionSites. Then it associates
 // the Click event of the button to a command.
 // UIExtensionSites are points of extension where modules can
 // add UI elements, such as items in a toolbar.
 private void AddToolStripButton(string commandName, string text)
 {
    ToolStripButton button = new ToolStripButton();
    button.Text = text;
    button.ToolTipText = text;
 
    // Add the button to the MainToolBar.
    WorkItem.UIExtensionSites[UIExtensionSiteNames.MainToolbar].Add(button);
 
    // Associate the Click event of the button to a command
    WorkItem.Commands[commandName].AddInvoker(button, "Click");
 }

3. Create a CommandHandler to handle the command you just created. This command displays a HelloWorldView on the RightWorkspace.
 C#
 // A Command Handler is used to handle the firing of a command.
  [CommandHandler(Constants.CommandNames.ShowHelloWorldMessage)]
 public void OnShowHelloWorldMessage(object sender, EventArgs e)
 {
 // 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.

After you create your Hello World application, you can use the Smart Client Software Factory How-to topics in the documentation to extend your application in the following ways:
  • It can help you create a foundational module.
  • It can help you create a disconnected service agent.
  • It can help you create a Windows Presentation Foundation (WPF) view with a presenter.
  • It can help you map business entities to user interface elements.
  • It can help you publish loosely coupled events.
  • It can help you subscribe to loosely coupled events.
  • It can help you communicate between views.
  • It can help you translate between business entities and service entities.
  • It can help you deploy your application with ClickOnce.

For information about how to perform these activities, see the "Development Activities" topic in the documentation.

More Information

For access to other documentation and resources, or to provide feedback, see the Smart Client Software Factory Web site. For more general information about the goals of this and other patterns & practices deliverables, see the Microsoft patterns & practices Developer Center.

Last edited May 21, 2010 at 8:27 PM by hanz, version 3

Comments

chrislew Feb 7, 2011 at 9:28 AM 
Step #3 - To add a Hello World view. Could not find the Smart Client Software Factory menu item when I right-click the HelloWorldModule. It only shows when I right click the Modules or WebSites solution folders, or the Website item. Any ideas?