Developing User Interfaces
CMSC 498B
Spring 2005
Prof. Ben Bederson
Project #3
Due April 7, 2005
The purpose of this program is to develop an understanding of internationalization and threaded GUI program structure.
You must create an internationalized version of an application that fetches search results from Google and performs that search in a background thread that allows the application GUI to continue to function while the search is being performed. In addition, the GUI must be updated as the data comes in. Essentially, you are building a dedicated search application. There are two conceptual parts of this application - the internationalized GUI, and the threaded searching.
For the GUI part, you can design the application as you choose, but it must have at least the following elements:
- A File->Exit menu that exits the application.
- A Help->About menu that brings up a dialog that says what the application is and who wrote it.
- A text box that a user can type in search words. When the Enter key is pressed, the search must be performed.
- A "Go" button that performs the search when clicked (so the search can be initiated by either pressing the Enter key or clicking the Go button.)
- A "Cancel" button that must cancel the search.
- A View menu with three language menu items. The three languages should be English, and two languages of your choosing. Note that if you don't know two other languages to translate the interface, try asking a friend. If you can't find anyone to help, you can make up the translation with a language such as pig-latin, or Ubbi Dubbi (in which case you'll have to assign those to actual .NET cultures, such "af-ZA", etc.) When you select the language, the entire interface (except Google search results) should switch to the specified language the next time you run the application, and a dialog box should pop up immediately that specifies this. That is, except for notifying the user, nothing should happen until you exit and restart the application.
- A large text box that shows the search results from Google.
For the threaded searching part:
- You should use the Google web service to search for the string specified by the user in the text box. Note that to use this web service, you will have to personally register with Google to get a free account that will allow you to perform 1,000 free searches per day. You will have to learn about Google's APIs on your own.
- Your actual Google search must be performed in a separate thread, and you must use the synchronous Google search. In this way, it will be slow enough that your threaded usage will be appropriate.
- While the search is being performed, a progress bar that is integrated into the bottom of the form must be updated indicating that progress is being made. Note that since you won't be notified by Google while progress is being made, you will have to make the progress bar go back and forth to indicate unknown progress.
- As data comes back from Google, it must be displayed in a large text box in your application. It is up to you to decide how to format the results to make them readable. You might choose to use the RichTextBox control which will enable you to use font colors and styles.
- Your GUI must continue to be interactive and responsive even while Google is searching. That is, the slow part of your program must not affect its responsiveness. Note that I will turn off the network in the middle of the search to test your program to ensure that the GUI continues to be responsive while the search hangs.
- The cancel button must completely kill the search and its thread - bringing the program back to its original non-searching state, and thus be ready to accept a new search.
Whatever partial results had been retrieved at the time the search was canceled should remain on the display.
private void button1_Click(object sender, System.EventArgs e) { Google.GoogleSearchResult result; Google.GoogleSearchService search = new Google.GoogleSearchService(); result = search.doGoogleSearch(keyBox.Text, searchBox.Text, 0, 10, true, "", true, "", "", ""); Google.ResultElement[] elements = result.resultElements; string[] resultStrings = new string[elements.Length]; int i = 0; foreach (Google.ResultElement element in elements) { resultStrings[i++] = element.URL + element.snippet; } resultsBox.Lines = resultStrings; search.BegindoGoogleSearch(keyBox.Text, searchBox.Text, 0, 10, true, "", true, "", "", "", new AsyncCallback(Callback), search); } void Callback(IAsyncResult syncResult) { Google.GoogleSearchService search = (Google.GoogleSearchService)syncResult.AsyncState; Google.GoogleSearchResult result = search.EnddoGoogleSearch(syncResult); Console.WriteLine(result.resultElements.Length); }
Submit following the same rules as Project #2, but make the subject line of your email contain "DUI: Proj #3 submission". As before, any submissions after the deadline will be ignored. If multiple submissions are made, then only the last one before the deadline will be looked at.
The zip file you submit must contain all files within a directory named "proj3-<name>.zip" where you replace <name> with your last name.