Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Creating Windows Starter Kits for Visual Studio 2005 : Page 2

Microsoft has put renewed energy into its Starter Kits for Visual Studio 2005, but did you know you can create your own Starter Kit and export it to .vsi to share with others? Find out how to build a book search Starter Kit using the Amazon Web service.


advertisement
Creating the Application
The first step in creating the Starter Kit is to create the Windows application. Using Visual Studio 2005, create a new Windows application using Visual Basic and name the project LibraryApp. In the default Form1, I have populated the form with the necessary controls (see Figure 1).


Figure 1. Form1: The screen shot shows the various controls you'll need to arrange on Form1, the main UI for the application.
 
Figure 2. Form2: The screen shot shows the various controls you need to arrange on Form2 of the sample application.

In this window, you can search for books using a keyword such as the title of a book or its ISBN number. Clicking the Get Info button will retrieve a list of books that matches your search keyword. You can then view detailed book information by clicking on the titles in the Search Results listbox. To add a title to the local database, click the Add Title button. You can also optionally choose not to download the cover of a book from Amazon by unchecking the Show Cover checkbox. If you have a barcode scanner, use the Auto-add Title checkbox to make adding titles faster. The View Catalog button brings up another window to display the list of titles stored in the local database.



Author's Note: I will not be showing you the detailed steps to populate the form. For this, I suggest you download the source code that accompanies this article. Similarly, the coding of the application can be found from the source code.

I have also added a second form to the application and populated the controls as shown in Figure 2. This window will display the list of titles added to the local database. Clicking on the Close button will close the form and return to the first form.

In addition, you will need a database to hold the detailed book information. Add a SQL Server 2005 Express edition database to the project and name it Library.mdf. The schema for this database is shown in Figure 3.


Figure 3. Library Schema: The screen shot shows the schema for the Libarary.mdf database, which holds the book information.
 
Figure 4. In the Amazon: You'll need to add a Web reference to Amazon's Web service.

Finally, to consume information from Amazon, you'll need to add a Web Reference to the Amazon web service (see Figure 4). To add a web service, right-click on the project name in Solution Explorer and select Add Web References. You then specify the URL of the Amazon.com web service.

This is how the application will work: You can enter the ISBN of a book in the Search Keywords textbox and click the Get Info button (see Figure 5). The Search Results listbox will show the list of matching titles. To view the detailed book information, click the titles in the listbox and the detailed information will be displayed on the right pane of the window. To add the title to the local database, click the Add Title button.

Figure 5. Book Search: The screen shot shows how a user would use this application to search for books by keyword.

My application uses the BackgroundWorker control (new in Windows Forms 2.0) to perform multithreading so as to ensure that the user interface does not freeze when it is accessing Amazon's web service. It will also display the hourglass icon to indicate that it is busy while waiting for the results to be returned from Amazon.

This application is optimized for use with a barcode scanner. Typically a barcode scanner functions much like a keyboard—it scans in a barcode and pass in the string of digits (and appends a carriage return) just as if you had typed it using a keyboard. So if you are using a barcode scanner set the focus on the Search Keywords textbox and scan the barcode using the scanner. My application will automatically detect the carriage return character returned by the scanner and trigger the Get Info button.

Besides searching by ISBN numbers, you can also search by keywords, as shown in Figure 6.


Figure 6. Keyword: The sample application allows the user to search your library by keyword.
 
Figure 7. Browse: You can browse the entire catalog.

To view the catalog of books that you have added into the database, click the View Catalog button. Form2 will display the list of books using the DataGridView control (see Figure 7). You can also navigate the records using the BindingNavigator control (located at the top of the form).

Adding the Documentation

Figure 8. Documentation: Documentation.txt, a text file, is being added to the Starter Kit. This file will stay with your Starter Kit wherever it goes.
Once the application is built and working correctly, you should add some documentation to the project so that developers using your Starter Kit can understand how the application works. For example, you might provide the link for the developer to register for a free Amazon web service account and how to obtain the subscription ID for accessing the web service.

You can add an HTML document or just a plain text file to the project. For simplicity, add a Text file to the project and name it Documentation.txt (see Figure 8).

Exporting the Template
With the application and documentation completed, you are now ready to export the project. In order to make your application sharable, you have to put it into a template. You can do so via the File-->Export Template menu item.

You will be asked to choose a template type. For creating Starter Kits, choose the Project template. The item template is used for something less than a full project, such as a Form, Class, Module, etc. This solution has only one project, so simply choose the LibraryApp project (see Figure 9). Click Next.


Figure 9. Template: In order to output your Starter Kit, you need to decide upon the proper template type for the application.
 
Figure 10. Options: Configure your Starter Kit with the proper options.

In the next dialog box, you can assign your own icon to represent the template (see Figure 10). Name your template LibraryApp Starter Kit. Uncheck the "Automatically import the template into Visual Studio" option. While this is a handy option, it's useful to learn how to manually create a Starter Kit. Click Finish.

That's it! Your template will be created in the following folder:

C:\Documents and Settings\Wei-Meng Lee\My Documents\Visual Studio 2005\My Exported Templates\

Place the exported template files into a .zip and name it Library App Starter Kit.zip. You will use this .zip file in the next section.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap