コード例 #1
0
 /// <summary>
 /// Cache button: look up a URL in the Google cache, display size of page
 /// </summary>
 private void cacheButton_Click(object sender, System.EventArgs e)
 {
     // Create a Google Search object
     Google.GoogleSearchService s = new Google.GoogleSearchService();
     try
     {
         // Invoke the doGetCachedPage method and get the cached bytes
         System.Byte[] bytes = s.doGetCachedPage(keyBox.Text, cacheBox.Text);
         // Display the length of the cached page
         cacheResultLabel.Text = Convert.ToString(bytes.Length);
     }
     catch (System.Web.Services.Protocols.SoapException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
 /// <summary>
 /// Search button: do a search, display number of results
 /// </summary>
 private void searchButton_Click(object sender, System.EventArgs e)
 {
     // Create a Google Search object
     Google.GoogleSearchService s = new Google.GoogleSearchService();
     try {
         // Invoke the search method
         Google.GoogleSearchResult r = s.doGoogleSearch(keyBox.Text, searchBox.Text,
                                                        0, 1, false, "", false, "", "", "");
         // Extract the estimated number of results for the search and display it
         int estResults = r.estimatedTotalResultsCount;
         searchResultLabel.Text = Convert.ToString(estResults);
     }
     catch (System.Web.Services.Protocols.SoapException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #3
0
 /// <summary>
 /// Spell button: ask Google for a suggested alternate spelling, display it
 /// </summary>
 private void spellButton_Click(object sender, System.EventArgs e)
 {
     // Create a Google Search object
     Google.GoogleSearchService s = new Google.GoogleSearchService();
     try
     {
         // Ask for spelling suggestion
         String suggestion = s.doSpellingSuggestion(keyBox.Text, spellBox.Text);
         // Display the suggestion, if any
         if (suggestion == null)
         {
             spellResultLabel.Text = "<no suggestion>";
         }
         else
         {
             spellResultLabel.Text = suggestion;
         }
     }
     catch (System.Web.Services.Protocols.SoapException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }