Comprehensive Windows Forms Application (C#)

This sample application enables you to submit queries to, and return results from, the Live Search Web Service through an interactive Windows Forms application that exposes all the functionality available through the API. The source code, below, is well-commented, and demonstrates how to configure requests and process responses from the search engine. You can modify this code to produce useful applications, or use it as a learning tool to better understand the API.

To set up the project in Microsoft Visual Studio .NET 2005

  1. Open Microsoft Visual Studio .NET 2005 and, from the File menu, choose New | Project. The New Project dialog box appears.

  2. In the Project types pane, choose Visual C# and then choose Windows.

  3. In the Templates pane, choose Windows Application.

  4. Type the name of the project, LiveSearchAPISample, in the Name text box and click OK. Visual Studio creates a new project.

  5. In the Solution Explorer, right-click References and, from the pop-up menu, select Add Web Reference.

  6. Type the following address in the URL text box: http://soap.search.msn.com/webservices.asmx?wsdl.

  7. Click Go.

  8. In the Web reference name text box, type LiveSearch and click Add Reference.

  9. Change the name of the form to frmSearchSample.cs. Click OK to rename all references and save your work.

To add the source code to the project

  1. Replace the source code in the file frmSearchSample.cs with the source code in the first Example section (Example, Part One). To do this:

    1. Click Copy Code to place the code in the Windows Clipboard.

    2. Open frmSearchSample.cs from the Solution Explorer, place your cursor anywhere in the file, and press Ctrl + A.

    3. Press Ctrl + V to paste the code into the Visual Studio source file, overwriting the template-generated code.

  2. Replace the source code in the file frmSearchSample.Designer.cs with the source code in the second Example section (Example, Part Two). To do this:

    1. Click Copy Code to place the code in the Windows Clipboard.

    2. Open frmSearchSample.Designer.cs from the Solution Explorer, place your cursor anywhere in the file, and press Ctrl + A.

    3. Press Ctrl + V to paste the code into the Visual Studio source file, overwriting the template-generated code.

  3. Search for and replace the text YOUR_APP_ID_GOES_HERE with the AppID you generated from the Developer Provisioning System.

  4. Press F5 to run the application in Debug mode.

Requirements

  • Microsoft Visual Studio .NET 2005 or Microsoft Visual C# .NET 2005.

  • Internet connection.

  • Application ID (see Getting Started with the Live Search API for more information on obtaining an AppID for use with the Live Search Web Service).

Demonstrates

All functionality in the current release of the Live Search Web Service API in an interactive format.

Example, Part One

Code

//THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
//TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//PARTICULAR PURPOSE.
//
//Copyright (C) 2007  Microsoft Corporation.  All rights reserved.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web.Services.Protocols;
using System.Net;
using LiveSearchAPISample.LiveSearch;

namespace LiveSearchAPISample
{
    public partial class frmSearchSample : Form
    {
        public frmSearchSample()
        {
            InitializeComponent();
        }

        public void executeQuery(bool nearMe)
        {
            try
            {
                // Create a new MSNSearchService object. MSNSearchService is the top-level
                // proxy class for accessing the service. MSNSearchService has one synchronous method:
                // Search, which takes a single SearchRequest object as an argument.
                // Asynchronous search methods, such as BeginSearch and EndSearch, may also be
                // available, depending on the SOAP toolkit used to generate the proxies.
                MSNSearchService s = new MSNSearchService();

                // Create a new SearchRequest object that represents the search request. Each SearchRequest can
                // contain multiple SourceRequest objects; however, each SearchRequest can contain
                // only one SourceRequest of each type. (More on this later.)
                SearchRequest searchRequest = new SearchRequest();

                // For the sample application, we will use seven SourceRequest objects: SourceType.Web,
                // which returns Web results or Web-Local results if a Location object is present;
                // SourceType.Spelling, which returns spelling suggestions; SourceType.PhoneBook,
                // which returns White Pages and Yellow Pages entries and geographic information for
                // select markets when a Location object is present; SourceType.News, which returns
                // news stories; SourceType.QueryLocation, which returns the keyword and place name,
                // for a query such as "pizza new york" or "pizza 98052," as "pizza" in the Title field and
                // the location name requested, such as a postal code ("98052") or a place name ("New York, NY");
                // SourceType.InlineAnswers, which returns Encarta, Finance, Weather, and ShowTimes
                // for commercial partners who have subscribed to these services; and SourceType.Image,
                // which returns information about images returned by the query, including the URI to 
                // the full-size image, the URI to the generated thumbnail, the height and width of the 
                // full-size image, the height and width of the thumbnail, the file size of the full-size
                // image, and the file size of the thumbnail.

                int arraySize = 7;

                // Each SourceRequest can be configured to return one or more common result fields:
                // Title, Description, Url, DisplayUrl, CacheUrl, Source, SearchTags, Phone, Address, Location;
                // The fields return vary by SourceType. Extended data fields can also be returned for specific
                // SourceTypes; see the online documentation for details.

                // Fields can be combined using the bitwise OR operator (|); 
                // All returns all available fields in the enumeration.
                // Note that some SourceRequest objects cannot return all of the fields
                // described. For example, a SourceRequest of type Spelling returns one spelling
                // suggestion in the Title field, so the returned data is the same when the
                // ResultFields property is set to ResultFieldMask.All or ResultFieldMask.Title.
                SourceRequest[] sr = new SourceRequest[arraySize];

                // The first SourceRequest is a Web source request. This can be a request for Web or
                // Web-Local results, depending on whether the Location object is set. When the user clicks
                // "Near Me," the sample application applies the Location information to the search and
                // returns Web-Local results (results that consider Location as a relevance factor) and
                // PhoneBook results.
                sr[0] = new SourceRequest();
                sr[0].Source = SourceType.Web;

                // For this SourceRequest, we can return all fields...
                sr[0].ResultFields = ResultFieldMask.All | ResultFieldMask.SearchTagsArray;

                // or just specific fields, such as SearchTags.

                // sr[0].ResultFields = ResultFieldMask.SearchTags;

                // To return a subset of all fields, combine the result fields using the bitwise
                // OR operator (|). The following example returns the Title and URL fields only:

                // sr[0].ResultFields = ResultFieldMask.Title | ResultFieldMask.Url;

                // Check for the number of results to return per page. If this value is not set,
                // the service returns the default number of results, which is ten per page.
                if (txtNumResults.Text != String.Empty)
                    sr[0].Count = Int32.Parse(txtNumResults.Text);

                // Check for an offset value. The default offset is zero, meaning that results are
                // returned from the Live Search Engine with the highest-ranking result displayed first.
                // The Offset property is most commonly used in conjunction with the Count
                // property, above, for paging through long lists of results.
                if (txtOffset.Text != String.Empty)
                    sr[0].Offset = Int32.Parse(txtOffset.Text);

                // If the user chooses to specify a SearchTagFilter or filters, the SearchTags returned will contain
                // only those specified. The sample application limits the number of filters to five (5). Example:
                // Query: MSDN, SearchTagFilter: search.title;search.mscategory
                if (txtWebSearchTagFilters.Text != String.Empty)
                {
                    string strUserSuppliedSearchTags = txtWebSearchTagFilters.Text;
                    string[] strFiltersWeb = new string[5];
                    strFiltersWeb = strUserSuppliedSearchTags.Split(';');
                    sr[0].SearchTagFilters = strFiltersWeb;
                }

                // Determine the user's choice of FileType. The default setting is any file
                // type. To restrict the FileType, set the SourceRequest.FileType to a specific string
                // value, as in the following setting for the Microsoft .DOC type.
                
                // sr[0].FileType = "DOC";

                // In this sample, all valid Web FileType values are listed in a combo box. To apply the user-
                // selected extension, the application gets the substring from the listed value and applies it
                // to the request.
                string strRawFileTypeString = cbxWebFileType.SelectedItem.ToString();
                if (strRawFileTypeString != "No File Type Preference")
                {
                    string[] strFileTypeProcessingArray = new string[2];
                    strFileTypeProcessingArray = strRawFileTypeString.Split('(');
                    string strFileType = strFileTypeProcessingArray[1].Substring(1, 4);
                    strFileType = strFileType.Trim();
                    sr[0].FileType = strFileType;
                }

                // The second SourceRequest is a spelling source request. Spelling returns only one
                // result per call, in the Title field.
                sr[1] = new SourceRequest();
                sr[1].Source = SourceType.Spelling;
                sr[1].ResultFields = ResultFieldMask.Title;
                // Set the Count to 1 and the Offset to 0 for SourceType.Spelling; Spelling returns
                // only one result per request (Count = 1) at offset zero (Offset = 0).
                sr[1].Count = 1;
                sr[1].Offset = 0;

                // The third SourceRequest is a PhoneBook source request. PhoneBook results include
                // a title, description, URL, phone number, address object, and location object.
                sr[2] = new SourceRequest();
                sr[2].Source = SourceType.PhoneBook;
                if (optRelevanceSort.Checked)
                    sr[2].SortBy = SortByType.Relevance;
                else if (optDistanceSort.Checked)
                    sr[2].SortBy = SortByType.Distance;
                else
                    sr[2].SortBy = SortByType.Default;

                // In this sample, we will return the Title, Description, and Url fields, as well as
                // the PhoneBook-specific return fields Phone, Address, and Location.
                sr[2].ResultFields = ResultFieldMask.Address | ResultFieldMask.Description | ResultFieldMask.Location | ResultFieldMask.Phone | ResultFieldMask.Title | ResultFieldMask.Url;
                if (txtNumResults.Text != String.Empty)
                    sr[2].Count = Int32.Parse(txtNumResults.Text);
                if (txtOffset.Text != String.Empty)
                    sr[2].Offset = Int32.Parse(txtOffset.Text);
                // PhoneBook results can be restricted by listing types to return all results, White Pages (Residential)
                // listings only, or Yellow Pages (Commercial) listings only. The following FileType values are
                // supported for the PhoneBook SourceType.
                if (optFileTypeWP_Only.Checked)
                    sr[2].FileType = "WP";
                if (optFileTypeYP_Only.Checked)
                    sr[2].FileType = "YP";

                // The fourth SourceRequest is a News source request. News results include
                // a title, description, URL, news source, and a date/time object.
                sr[3] = new SourceRequest();
                sr[3].Source = SourceType.News;

                // If the user chooses to specify a SearchTagFilter or filters, the SearchTags returned will contain
                // only those specified. The sample application limits the number of filters to five (5).
                // Example: Query: MSNBC, SearchTagFilter: search.source
                if (txtNewsSearchTagFilters.Text != String.Empty)
                {
                    string strUserSuppliedSearchTags = txtNewsSearchTagFilters.Text;
                    string[] strFiltersNews = new string[5];
                    strFiltersNews = strUserSuppliedSearchTags.Split(';');
                    sr[3].SearchTagFilters = strFiltersNews;
                }

                // In this sample, we will return the Title, Description, and Url fields, as well as
                // the extended news return fields Source and DateTime.
                sr[3].ResultFields = ResultFieldMask.All | ResultFieldMask.DateTime | ResultFieldMask.SearchTagsArray;
                if (txtNumResults.Text != String.Empty)
                    sr[3].Count = Int32.Parse(txtNumResults.Text);
                if (txtOffset.Text != String.Empty)
                    sr[3].Offset = Int32.Parse(txtOffset.Text);

                // The fifth SourceRequest is a QueryLocation request. The response includes the keyword for the query,
                // such as "pizza" and the location name requested, such as a postal code ("98052") or a place name
                // ("New York, NY"). The keyword is returned in the QueryLocation.Title field and the place name or
                // postal code is returned in the QueryLocation.Description field.
                sr[4] = new SourceRequest();
                sr[4].Source = SourceType.QueryLocation;
                sr[4].ResultFields = ResultFieldMask.All;

                // The sixth SourceRequest is an InlineAnswers request. Inline Answers are returned only to those
                // commercial partners who have subscribed to the service(s). Possible types include: Encarta,
                // Finance, Weather, and movie ShowTimes. InlineAnswers extended fields include the Summary field,
                // which displays a compact version of the answer, suitable for mobile devices such as smart phones,
                // and a ResultType field, which returns the name of the InlineAnswer type that responded to the
                // query.
                sr[5] = new SourceRequest();
                sr[5].Source = SourceType.InlineAnswers;
                sr[5].ResultFields = ResultFieldMask.All | ResultFieldMask.ResultType | ResultFieldMask.Summary;

                // The seventh SourceRequest is an Image request. Image results can include the URL and Display URL
                // for the HTML page that contains the image, the image name (in the Title field), the image file size,
                // the image height and width, the thumbnail file size, the thumbnail height and width, and URIs for
                // the full image and thumbnail.
                sr[6] = new SourceRequest();
                sr[6].Source = SourceType.Image;
                sr[6].ResultFields = ResultFieldMask.All | ResultFieldMask.Image;
                if (txtNumResults.Text != String.Empty)
                    sr[6].Count = Int32.Parse(txtNumResults.Text);
                if (txtOffset.Text != String.Empty)
                    sr[6].Offset = Int32.Parse(txtOffset.Text);

                // The Query field of the SearchRequest object is the text of the query submitted to the
                // Live Search Engine. The query can contain any valid query text supported by the 
                // Live Search Engine, including advanced query syntax. 
                searchRequest.Query = txtQuery.Text;

                // The Requests field of the SearchRequest object is the array of SourceRequest objects
                // for this search.
                searchRequest.Requests = sr;

                // Check the user selection for SafeSearchOptions.
                // The default setting is Moderate.
                if (optSafeSearchOff.Checked)
                    searchRequest.SafeSearch = SafeSearchOptions.Off;
                else if (optSafeSearchStrict.Checked)
                    searchRequest.SafeSearch = SafeSearchOptions.Strict;
                else
                    searchRequest.SafeSearch = SafeSearchOptions.Moderate;

                // Enter the Application ID, in double quotation marks, supplied by the 
                // Developer Provisioning System, as the value of the AppID on the SearchRequest.
                searchRequest.AppID = "YOUR_APP_ID_GOES_HERE";

                // Determine whether the user chose to enable query word marking, disable spell correction
                // for search operators, and disable host collapsing.
                int searchFlagsValue = 0;

                if (chkQueryWordMarking.Checked)
                    searchFlagsValue += 1;
                if (chkDisableSpellCorrectForSpecialWords.Checked)
                    searchFlagsValue += 2;
                if (chkDisableHostCollapsing.Checked)
                    searchFlagsValue += 4;

                switch (searchFlagsValue)
                {
                    case 0:
                        searchRequest.Flags = SearchFlags.None;
                        break;
                    case 1:
                        searchRequest.Flags = SearchFlags.MarkQueryWords;
                        break;
                    case 2:
                        searchRequest.Flags = SearchFlags.DisableSpellCorrectForSpecialWords;
                        break;
                    case 3:
                        searchRequest.Flags = SearchFlags.MarkQueryWords | SearchFlags.DisableSpellCorrectForSpecialWords;
                        break;
                    case 4:
                        searchRequest.Flags = SearchFlags.DisableHostCollapsing;
                        break;
                    case 5:
                        searchRequest.Flags = SearchFlags.MarkQueryWords | SearchFlags.DisableHostCollapsing;
                        break;
                    case 6:
                        searchRequest.Flags = SearchFlags.DisableSpellCorrectForSpecialWords | SearchFlags.DisableHostCollapsing;
                        break;
                    case 7:
                        searchRequest.Flags = SearchFlags.MarkQueryWords | SearchFlags.DisableSpellCorrectForSpecialWords | SearchFlags.DisableHostCollapsing;
                        break;
                    default:
                        searchRequest.Flags = SearchFlags.None;
                        break;
                }

                // Determine the user's CultureInfo selection.
                // The following code gets the CultureInfo value from the combo box.
                // The combo box collection contains all values recognized by the Live Search Engine.
                // You can also set the CultureInfo to a specific value in the code, as shown in the
                // following example:
                // searchRequest.CultureInfo = "fr-CA";
                searchRequest.CultureInfo = cbxCultureInfo.SelectedItem.ToString();

                // To return PhoneBook results in addition to Web results, the user must set the Location.
                // The following code sets the Latitude and Longitude fields of the Location
                // object, and the Radius of the search.

                // If invalid Location data is specified, the Live Search Engine will attempt to
                // return search results based on the information provided. Note that zero results
                // may return if the Location data does not map to a valid geographic location.
                // The value of Radius also affects the search results; a small value for Radius may
                // return fewer results than expected.

                // The sample application user interface does not validate user input.
                if (nearMe)
                {
                    double latitude = Double.Parse(txtLatitude.Text);
                    double longitude = Double.Parse(txtLongitude.Text);
                    double radius = Double.Parse(txtRadius.Text);
                    searchRequest.Location = new Location();
                    searchRequest.Location.Latitude = latitude;
                    searchRequest.Location.Longitude = longitude;
                    searchRequest.Location.Radius = radius;
                }

                // Once the SearchRequest has been configured, and all of the SourceRequest
                // objects have been configured and added to the SearchRequest, the
                // application can process the request.

                // Create a SearchResponse object for the SourceResponse objects returned by the query.
                SearchResponse searchResponse;

                // Execute the search request and return the search response by
                // setting the SearchResponse to MSNSearchService.Search(SearchRequest).
                searchResponse = s.Search(searchRequest);

                // Check the SearchResponse to determine whether it contains a spelling suggestion.
                // The spelling suggestion is returned in the Title field of the Spelling SourceResponse.
                // If the SearchResponse does not contain a Spelling SourceResponse, there is no
                // spelling suggestion and the application passes the SearchResponse to the printResults method.
                // If a Spelling SourceResponse is returned, the application displays a MessageBox that asks
                // the user to choose whether to ignore the spelling suggestion, or accept the spelling
                // suggestion and re-execute the query with the updated query string.
                // To test for the presence of the Spelling SourceResponse, check the Total field for
                // the SearchResponse.Response for the Spelling SourceType.
                if (searchResponse.Responses[1].Total != 0)
                    handleSpellingSuggestion(searchResponse, nearMe);
                else
                    printResults(searchResponse);
            }

            // Catch SOAP exceptions.
            catch (System.Web.Services.Protocols.SoapException fault)
            {
                MessageBox.Show(fault.Detail.InnerText.ToString());
            }

            // Catch Web exceptions.
            catch (System.Net.WebException webx)
            {
                MessageBox.Show(webx.ToString());
            }
        }

        public void handleSpellingSuggestion(SearchResponse searchResponse, bool nearMe)
        {
            // Get the spelling suggestion from the Spelling SourceResponse.
            String strSpellingSuggestion = searchResponse.Responses[1].Results[0].Title;
            // Remove tokens from the spelling suggestion.
            char[] trimChars = new char[2];
            trimChars[0] = '\xe000';
            trimChars[1] = '\xe001';
            strSpellingSuggestion = strSpellingSuggestion.Trim(trimChars);
            strSpellingSuggestion = strSpellingSuggestion.Replace(trimChars[0], ' ');
            strSpellingSuggestion = strSpellingSuggestion.Replace(trimChars[1], ' ');

            // Display a MessageBox, and ask the user if he or she wants to accept the suggested spelling.
            // If the user chooses Yes, replace the text in the query text box (txtQuery)
            // with the spelling suggestion, and execute a new query with the changed query string.
            // If the user chooses No, close the MessageBox and pass the SearchResponse, which includes the
            // Spelling SourceResponse, to the printResults method.
            if (MessageBox.Show("Were you looking for " + strSpellingSuggestion + "?", "Spelling Suggestion",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString() == "Yes")
            {
                txtQuery.Text = strSpellingSuggestion;
                if (nearMe)
                    executeQuery(true);
                else
                    executeQuery(false);
            }
            else
                printResults(searchResponse);
        }

        public void printResults(SearchResponse searchResponse)
        {
            // Create a new StringBuilder to accumulate the text to be displayed in the WebBrowser
            // control when the search is complete and all results are returned.
            StringBuilder sb = new StringBuilder(8192);

            // Set up the HTML tags for the output returned from the search.
            sb.Append("<HTML><BODY>");

            // Using foreach, loop through all the SourceResponses in the SearchResponse.
            foreach (SourceResponse sourceResponse in searchResponse.Responses)
            {
                // The requested result fields for each SourceRequest are returned in the 
                // Results field of the respective SourceResponse.
                Result[] sourceResults = sourceResponse.Results;

                // For each SourceResponse, determine whether the total number of results returned
                // is greater than zero. If so, print a simple heading for that SourceResponse
                // type. Note that Total is an *estimate* of the total number of returned results,
                // with the exception of Spelling results, which return zero results or one result.
                if (sourceResponse.Total > 0)
                {
                    // List the source type.
                    sb.Append("<H3><B>" + sourceResponse.Source.ToString() + " - Total Results: ");
                    // Show the estimated total of results.
                    sb.Append(sourceResponse.Total.ToString() + "</B></H3><HR>");
                }
                // Using foreach, loop through the results returned in each SourceResponse.
                foreach (Result sourceResult in sourceResults)
                {
                    // Do not print any labels for results that are not returned (NULL) or
                    // contain no text (String.Empty).
                    if ((sourceResult.Title != null) && (sourceResult.Title != String.Empty))
                        sb.Append("<B>Title: </B>" + sourceResult.Title + "<BR>");
                    if ((sourceResult.Description != null) && (sourceResult.Description != String.Empty))
                        sb.Append("<B>Description: </B>" + sourceResult.Description + "<BR>");
                    if ((sourceResult.DisplayUrl != null) && (sourceResult.DisplayUrl != String.Empty))
                        sb.Append("<B>DisplayUrl: </B><A HREF=\"" + sourceResult.DisplayUrl + "\">" + sourceResult.DisplayUrl + "</A><BR>");
                    if ((sourceResult.Url != null) && (sourceResult.Url != String.Empty))
                        sb.Append("<B>Url: </B><A HREF=\"" + sourceResult.Url + "\">" + sourceResult.Url + "</A><BR>");
                    if ((sourceResult.SearchTags != null) && (sourceResult.SearchTags != String.Empty))
                        sb.Append("<B>SearchTags: </B>" + sourceResult.SearchTags + "<BR>");
                    if (sourceResult.SearchTagsArray != null)
                    {
                        sb.Append("<B>SearchTagsArray (Length " + sourceResult.SearchTagsArray.Length.ToString() + ")</B><BR><BR>");
                        int counter = 0;
                        foreach (SearchTag nameValuePair in sourceResult.SearchTagsArray)
                        {
                            sb.Append("<B>SearchTagsArray[" + counter.ToString() + "] Name: </B>" + nameValuePair.Name + "<BR>");
                            sb.Append("<B>SearchTagsArray[" + counter.ToString() + "] Value: </B>" + nameValuePair.Value + "<BR>");
                            counter++;
                        }
                    }
                    if ((sourceResult.CacheUrl != null) && (sourceResult.CacheUrl != String.Empty))
                        sb.Append("<B>CacheUrl: </B><A HREF=\"" + sourceResult.CacheUrl + "\">" + sourceResult.CacheUrl + "</A><BR>");
                    if ((sourceResult.Source != null) && (sourceResult.Source != String.Empty))
                        sb.Append("<B>Source: </B>" + sourceResult.Source + "<BR>");
                    if ((sourceResult.Summary != null) && (sourceResult.Summary != String.Empty))
                        sb.Append("<B>Summary: </B>" + sourceResult.Summary + "<BR>");
                    if ((sourceResult.ResultType != null) && (sourceResult.ResultType != String.Empty))
                        sb.Append("<B>ResultType: </B>" + sourceResult.ResultType + "<BR>");

                    if (sourceResult.DateTime != null)
                    {
                        int year = sourceResult.DateTime.Year;
                        int month = sourceResult.DateTime.Month;
                        int day = sourceResult.DateTime.Day;
                        int hour = sourceResult.DateTime.Hour;
                        int minute = sourceResult.DateTime.Minute;
                        int second = sourceResult.DateTime.Second;

                        System.DateTime newsDateTime = new System.DateTime(year, month, day, hour, minute, second);
                        // Print the raw data for the DateTime returned.
                        sb.Append("<B>NewsDateTime (Raw Data): </B>" + newsDateTime.ToString() + "<BR>");
                        // Print the age of the news story, as on the Live Search Web site.
                        System.TimeSpan newsAge = new System.TimeSpan();
                        newsAge = System.DateTime.Now.ToUniversalTime() - newsDateTime;

                        if ((newsAge.Days == 0) && (newsAge.Hours == 0))
                            sb.Append("<B>NewsDateTime (Age of Story): " + newsAge.Minutes.ToString() + " minutes ago</B><BR>");
                        if ((newsAge.Days == 0) && (newsAge.Hours == 1))
                            sb.Append("<B>NewsDateTime (Age of Story): " + newsAge.Hours.ToString() + " hour ago</B><BR>");
                        else if ((newsAge.Days == 0) && (newsAge.Hours > 1))
                            sb.Append("<B>NewsDateTime (Age of Story): " + newsAge.Hours.ToString() + " hours ago</B><BR>");
                        else if (newsAge.Days >= 1)
                            sb.Append("<B>NewsDateTime (Age of Story): " + newsDateTime.ToShortDateString() + "</B><BR>");
                    }
                    sb.Append("<BR>");

                    // Process PhoneBook results.
                    // If the search was a "Near Me" search, the Location settings are considered as a relevance factor in the 
                    // Web search, and PhoneBook results may also be returned for appropriate queries.
                    // If the SourceType returned is a PhoneBook SourceType, print a label for the Phone field, each field
                    // in the Address Object, and each field in the returned Location object.
                    // Since Address.FormattedAddress is always blank and Location.Radius always returns 5,
                    // these fields are skipped in the sample.
                    // The SecondaryCity and PostalCode fields are not returned for addresses in the United States;
                    // the SecondaryCity field is used for addresses in the United Kingdom.
                    if (sourceResponse.Source == SourceType.PhoneBook)
                    {
                        if ((sourceResult.Phone != null) && (sourceResult.Phone != String.Empty))
                            sb.Append("<B>Phone: </B>" + sourceResult.Phone + "<BR>");
                        if (sourceResult.Address != null)
                        {
                            if ((sourceResult.Address.AddressLine != null) && (sourceResult.Address.AddressLine != String.Empty))
                                sb.Append("<B>AddressLine: </B>" + sourceResult.Address.AddressLine + "<BR>");
                            if ((sourceResult.Address.CountryRegion != null) && (sourceResult.Address.CountryRegion != String.Empty))
                                sb.Append("<B>CountryRegion: </B>" + sourceResult.Address.CountryRegion + "<BR>");
                            if ((sourceResult.Address.PostalCode != null) && (sourceResult.Address.PostalCode != String.Empty))
                                sb.Append("<B>PostalCode: </B>" + sourceResult.Address.PostalCode + "<BR>");
                            if ((sourceResult.Address.PrimaryCity != null) && (sourceResult.Address.PrimaryCity != String.Empty))
                                sb.Append("<B>PrimaryCity: </B>" + sourceResult.Address.PrimaryCity + "<BR>");
                            if ((sourceResult.Address.SecondaryCity != null) && (sourceResult.Address.SecondaryCity != String.Empty))
                                sb.Append("<B>SecondaryCity: </B>" + sourceResult.Address.SecondaryCity + "<BR>");
                            if ((sourceResult.Address.Subdivision != null) && (sourceResult.Address.Subdivision != String.Empty))
                                sb.Append("<B>Subdivision: </B>" + sourceResult.Address.Subdivision + "<BR>");
                        }
                        if (sourceResult.Location != null)
                        {
                            sb.Append("<B>Latitude: </B>" + sourceResult.Location.Latitude.ToString() + "<BR>");
                            sb.Append("<B>Longitude: </B>" + sourceResult.Location.Longitude.ToString() + "<BR>");

                            // Calculate the "Great Circle" distance between the Location specified in the SearchRequest
                            // and the longitude and latitude of each Location returned by the query in miles and kilometers.
                            // 
                            // Note: The distance is calculated based on the values entered in the Latitude and Longitude
                            // text boxes, which are in the user interface in the Location Information section of the Settings tab.
                            // For queries of the form "keyword, place name" or "keyword, ZIP code," this code will not compute
                            // the distance from the center of the city, as returned in the QueryLocation.Location object.
                            double earthRadius = 3963.0;
                            double earthRadiusKM = 6392.0;
                            double latitudeIn = Double.Parse(txtLatitude.Text);
                            double longitudeIn = Double.Parse(txtLongitude.Text);
                            double latitudeOut = sourceResult.Location.Latitude;
                            double longitudeOut = sourceResult.Location.Longitude;
                            double radianConversion = (Math.PI / 180.0);

                            double operandOne;
                            double operandTwo;
                            double acosOfSum;
                            double finalValue;
                            double finalValueKM;

                            operandOne = Math.Cos(radianConversion * (90.0 - latitudeIn)) * Math.Cos(radianConversion * (90.0 - latitudeOut));
                            operandTwo = Math.Sin(radianConversion * (90.0 - latitudeIn)) * Math.Sin(radianConversion * (90.0 - latitudeOut)) * Math.Cos(radianConversion * (longitudeIn - longitudeOut));
                            acosOfSum = Math.Acos(operandOne + operandTwo);
                            finalValue = earthRadius * acosOfSum;
                            finalValueKM = earthRadiusKM * acosOfSum;

                            sb.Append("<B>Distance (Miles): </B>" + finalValue.ToString("F") + "<BR>");
                            sb.Append("<B>Distance (Kilometers): </B>" + finalValueKM.ToString("F") + "<BR><HR>");
                        }
                    }

                    // If the query was of the form "keyword(s) Place_Name" or "keyword(s) ZIP_Code,"
                    // and SourceType.QueryLocation was requested, print a string showing the
                    // QueryLocation result, as on the Live Search Web site. QueryLocation can be used in conjunction
                    // with PhoneBook results for select markets, as listed in the online documentation.
                    // Examples of this type of location-based keyword query are:
                    // "pizza new york," "pizza ottawa," and "pizza 98052."
                    if (sourceResponse.Source == SourceType.QueryLocation)
                    {
                        if (sourceResult.Location != null)
                        {
                            sb.Append("<B>Sample Return String for QueryLocation:</B><BR>");
                            sb.Append("Top local listings for " + "<B>" + sourceResult.Title + "</B>" + " near ");
                            sb.Append("<B>" + sourceResult.Description + "</B>");
                            sb.Append(" (" + sourceResult.Location.Longitude.ToString() + ", " + sourceResult.Location.Latitude.ToString() + ")<BR>");
                        }
                    }
                    if (sourceResult.Image != null)
                    {
                        if (sourceResult.Image.ThumbnailFileSizeSpecified)
                            sb.Append("<B>Thumbnail File Size: </B>" + sourceResult.Image.ThumbnailFileSize.ToString() + "<BR>");
                        if (sourceResult.Image.ThumbnailHeightSpecified && sourceResult.Image.ThumbnailWidthSpecified)
                            sb.Append("<B>Thumbnail Height: </B>" + sourceResult.Image.ThumbnailHeight.ToString() +
                                "<B>, Thumbnail Width: </B>" + sourceResult.Image.ThumbnailWidth.ToString() + "<BR>");
                        sb.Append("<B>Thumbnail:</B><BR><IMG SRC=\"" + sourceResult.Image.ThumbnailURL + "\"></A><BR>");
                        if (sourceResult.Image.ImageFileSizeSpecified)
                            sb.Append("<B>Image File Size: </B>" + sourceResult.Image.ImageFileSize.ToString() + "<BR>");
                        if (sourceResult.Image.ImageHeightSpecified && sourceResult.Image.ImageWidthSpecified)
                            sb.Append("<B>Image Height: </B>" + sourceResult.Image.ImageHeight.ToString() +
                                "<B>, Image Width: </B>" + sourceResult.Image.ImageWidth.ToString() + "<BR>");
                        sb.Append("<B>Full Size Image URL: </B><A HREF=\"" + sourceResult.Image.ImageURL + "\">" + sourceResult.Image.ImageURL + "</A><BR><HR>");
                    }
                }
                // Close the BODY and HTML tags.
                sb.Append("</BODY></HTML>");

                // Handle the user request for query word marking. Query words are marked with
                // the Unicode characters 0xE000 and 0xE001 (begin and end, respectively).
                // Create String objects for each Unicode character.
                if (chkQueryWordMarking.Checked)
                {
                    string MarkBegin = "\xe000";
                    string MarkEnd = "\xe001";
                    // Replace the marking characters with boldface tags in the text.
                    sb.Replace(MarkBegin, "<B>");
                    sb.Replace(MarkEnd, "</B>");
                }
            }
            // Set the text of the WebBrowser control to the HTML contained in the StringBuilder.
            webBrowser1.DocumentText = sb.ToString();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            // Call Method executeQuery with "false" to indicate that the search is not for PhoneBook results,
            // and that Location should not be included as a factor in relevance.
            executeQuery(false);
        }

        private void btnNearMe_Click(object sender, EventArgs e)
        {
            // Call Method executeQuery with "true" to indicate that the search is for PhoneBook results,
            // and that Location should be included as a factor in relevance.
            executeQuery(true);
        }
    }
}

Example, Part Two

Code

namespace LiveSearchAPISample
{
    partial class frmSearchSample
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.SearchPage = new System.Windows.Forms.TabPage();
            this.txtQuery = new System.Windows.Forms.TextBox();
            this.btnNearMe = new System.Windows.Forms.Button();
            this.btnSearch = new System.Windows.Forms.Button();
            this.webBrowser1 = new System.Windows.Forms.WebBrowser();
            this.SettingsPage = new System.Windows.Forms.TabPage();
            this.label18 = new System.Windows.Forms.Label();
            this.cbxWebFileType = new System.Windows.Forms.ComboBox();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.optFileTypeYP_Only = new System.Windows.Forms.RadioButton();
            this.optFileTypeWP_Only = new System.Windows.Forms.RadioButton();
            this.optFileTypeAny = new System.Windows.Forms.RadioButton();
            this.txtNewsSearchTagFilters = new System.Windows.Forms.TextBox();
            this.txtWebSearchTagFilters = new System.Windows.Forms.TextBox();
            this.label12 = new System.Windows.Forms.Label();
            this.label17 = new System.Windows.Forms.Label();
            this.label13 = new System.Windows.Forms.Label();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.optRelevanceSort = new System.Windows.Forms.RadioButton();
            this.optDistanceSort = new System.Windows.Forms.RadioButton();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.optSafeSearchModerate = new System.Windows.Forms.RadioButton();
            this.optSafeSearchStrict = new System.Windows.Forms.RadioButton();
            this.optSafeSearchOff = new System.Windows.Forms.RadioButton();
            this.chkDisableHostCollapsing = new System.Windows.Forms.CheckBox();
            this.chkDisableSpellCorrectForSpecialWords = new System.Windows.Forms.CheckBox();
            this.txtRadius = new System.Windows.Forms.TextBox();
            this.txtLatitude = new System.Windows.Forms.TextBox();
            this.txtLongitude = new System.Windows.Forms.TextBox();
            this.chkQueryWordMarking = new System.Windows.Forms.CheckBox();
            this.label11 = new System.Windows.Forms.Label();
            this.cbxCultureInfo = new System.Windows.Forms.ComboBox();
            this.label10 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.label16 = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.label14 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.txtOffset = new System.Windows.Forms.TextBox();
            this.txtNumResults = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.tabControl1.SuspendLayout();
            this.SearchPage.SuspendLayout();
            this.SettingsPage.SuspendLayout();
            this.groupBox3.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.Add(this.SearchPage);
            this.tabControl1.Controls.Add(this.SettingsPage);
            this.tabControl1.Location = new System.Drawing.Point(-1, -1);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(680, 735);
            this.tabControl1.TabIndex = 0;
            // 
            // SearchPage
            // 
            this.SearchPage.Controls.Add(this.txtQuery);
            this.SearchPage.Controls.Add(this.btnNearMe);
            this.SearchPage.Controls.Add(this.btnSearch);
            this.SearchPage.Controls.Add(this.webBrowser1);
            this.SearchPage.Location = new System.Drawing.Point(4, 22);
            this.SearchPage.Name = "SearchPage";
            this.SearchPage.Padding = new System.Windows.Forms.Padding(3);
            this.SearchPage.Size = new System.Drawing.Size(672, 709);
            this.SearchPage.TabIndex = 0;
            this.SearchPage.Text = "Search";
            this.SearchPage.UseVisualStyleBackColor = true;
            // 
            // txtQuery
            // 
            this.txtQuery.Location = new System.Drawing.Point(10, 24);
            this.txtQuery.Name = "txtQuery";
            this.txtQuery.Size = new System.Drawing.Size(480, 20);
            this.txtQuery.TabIndex = 3;
            // 
            // btnNearMe
            // 
            this.btnNearMe.Location = new System.Drawing.Point(589, 23);
            this.btnNearMe.Name = "btnNearMe";
            this.btnNearMe.Size = new System.Drawing.Size(75, 23);
            this.btnNearMe.TabIndex = 2;
            this.btnNearMe.Text = "Near Me";
            this.btnNearMe.UseVisualStyleBackColor = true;
            this.btnNearMe.Click += new System.EventHandler(this.btnNearMe_Click);
            // 
            // btnSearch
            // 
            this.btnSearch.Location = new System.Drawing.Point(502, 23);
            this.btnSearch.Name = "btnSearch";
            this.btnSearch.Size = new System.Drawing.Size(75, 23);
            this.btnSearch.TabIndex = 1;
            this.btnSearch.Text = "Search";
            this.btnSearch.UseVisualStyleBackColor = true;
            this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
            // 
            // webBrowser1
            // 
            this.webBrowser1.Location = new System.Drawing.Point(10, 65);
            this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
            this.webBrowser1.Name = "webBrowser1";
            this.webBrowser1.Size = new System.Drawing.Size(655, 636);
            this.webBrowser1.TabIndex = 0;
            // 
            // SettingsPage
            // 
            this.SettingsPage.Controls.Add(this.label18);
            this.SettingsPage.Controls.Add(this.cbxWebFileType);
            this.SettingsPage.Controls.Add(this.groupBox3);
            this.SettingsPage.Controls.Add(this.txtNewsSearchTagFilters);
            this.SettingsPage.Controls.Add(this.txtWebSearchTagFilters);
            this.SettingsPage.Controls.Add(this.label12);
            this.SettingsPage.Controls.Add(this.label17);
            this.SettingsPage.Controls.Add(this.label13);
            this.SettingsPage.Controls.Add(this.groupBox2);
            this.SettingsPage.Controls.Add(this.groupBox1);
            this.SettingsPage.Controls.Add(this.chkDisableHostCollapsing);
            this.SettingsPage.Controls.Add(this.chkDisableSpellCorrectForSpecialWords);
            this.SettingsPage.Controls.Add(this.txtRadius);
            this.SettingsPage.Controls.Add(this.txtLatitude);
            this.SettingsPage.Controls.Add(this.txtLongitude);
            this.SettingsPage.Controls.Add(this.chkQueryWordMarking);
            this.SettingsPage.Controls.Add(this.label11);
            this.SettingsPage.Controls.Add(this.cbxCultureInfo);
            this.SettingsPage.Controls.Add(this.label10);
            this.SettingsPage.Controls.Add(this.label9);
            this.SettingsPage.Controls.Add(this.label16);
            this.SettingsPage.Controls.Add(this.label15);
            this.SettingsPage.Controls.Add(this.label14);
            this.SettingsPage.Controls.Add(this.label8);
            this.SettingsPage.Controls.Add(this.txtOffset);
            this.SettingsPage.Controls.Add(this.txtNumResults);
            this.SettingsPage.Controls.Add(this.label7);
            this.SettingsPage.Controls.Add(this.label6);
            this.SettingsPage.Controls.Add(this.label5);
            this.SettingsPage.Controls.Add(this.label4);
            this.SettingsPage.Controls.Add(this.label3);
            this.SettingsPage.Controls.Add(this.label2);
            this.SettingsPage.Controls.Add(this.label1);
            this.SettingsPage.Location = new System.Drawing.Point(4, 22);
            this.SettingsPage.Name = "SettingsPage";
            this.SettingsPage.Padding = new System.Windows.Forms.Padding(3);
            this.SettingsPage.Size = new System.Drawing.Size(672, 709);
            this.SettingsPage.TabIndex = 1;
            this.SettingsPage.Text = "Settings";
            this.SettingsPage.UseVisualStyleBackColor = true;
            // 
            // label18
            // 
            this.label18.AutoSize = true;
            this.label18.BackColor = System.Drawing.Color.Transparent;
            this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label18.Location = new System.Drawing.Point(39, 604);
            this.label18.Name = "label18";
            this.label18.Size = new System.Drawing.Size(510, 16);
            this.label18.TabIndex = 35;
            this.label18.Text = "Return Listings of this Type (PhoneBook SourceType - US Markets Only):";
            // 
            // cbxWebFileType
            // 
            this.cbxWebFileType.FormattingEnabled = true;
            this.cbxWebFileType.Items.AddRange(new object[] {
            "No File Type Preference",
            "Microsoft Word Document Files (.DOC Extension)",
            "Autodesk .DWF Files (.DWF Extension)",
            "HTML Files (.HTM Extension)",
            "HTML Files (.HTML Extension)",
            "Adobe Acrobat Portable Document Format Files (.PDF Extension)",
            "Microsoft PowerPoint Files (.PPT Extension)",
            "Adobe PostScript Files (.PS Extension)",
            "Microsoft Rich Text Format Files (.RTF or .DOC Extension)",
            "Generic Text Files (.TEXT Extension)",
            "Generic Text Files (.TXT Extension)",
            "Microsoft Excel Workbook Files (.XLS Extension)"});
            this.cbxWebFileType.Location = new System.Drawing.Point(144, 565);
            this.cbxWebFileType.Name = "cbxWebFileType";
            this.cbxWebFileType.Size = new System.Drawing.Size(421, 21);
            this.cbxWebFileType.TabIndex = 34;
            this.cbxWebFileType.Text = "No File Type Preference";
            // 
            // groupBox3
            // 
            this.groupBox3.Controls.Add(this.optFileTypeYP_Only);
            this.groupBox3.Controls.Add(this.optFileTypeWP_Only);
            this.groupBox3.Controls.Add(this.optFileTypeAny);
            this.groupBox3.Location = new System.Drawing.Point(251, 622);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Size = new System.Drawing.Size(315, 71);
            this.groupBox3.TabIndex = 33;
            this.groupBox3.TabStop = false;
            // 
            // optFileTypeYP_Only
            // 
            this.optFileTypeYP_Only.AutoSize = true;
            this.optFileTypeYP_Only.Location = new System.Drawing.Point(30, 46);
            this.optFileTypeYP_Only.Name = "optFileTypeYP_Only";
            this.optFileTypeYP_Only.Size = new System.Drawing.Size(214, 17);
            this.optFileTypeYP_Only.TabIndex = 2;
            this.optFileTypeYP_Only.Text = "Yellow Pages (Commercial) Listings Only";
            this.optFileTypeYP_Only.UseVisualStyleBackColor = true;
            // 
            // optFileTypeWP_Only
            // 
            this.optFileTypeWP_Only.AutoSize = true;
            this.optFileTypeWP_Only.Location = new System.Drawing.Point(30, 29);
            this.optFileTypeWP_Only.Name = "optFileTypeWP_Only";
            this.optFileTypeWP_Only.Size = new System.Drawing.Size(209, 17);
            this.optFileTypeWP_Only.TabIndex = 1;
            this.optFileTypeWP_Only.Text = "White Pages (Residential) Listings Only";
            this.optFileTypeWP_Only.UseVisualStyleBackColor = true;
            // 
            // optFileTypeAny
            // 
            this.optFileTypeAny.AutoSize = true;
            this.optFileTypeAny.Checked = true;
            this.optFileTypeAny.Location = new System.Drawing.Point(30, 11);
            this.optFileTypeAny.Name = "optFileTypeAny";
            this.optFileTypeAny.Size = new System.Drawing.Size(133, 17);
            this.optFileTypeAny.TabIndex = 0;
            this.optFileTypeAny.TabStop = true;
            this.optFileTypeAny.Text = "All PhoneBook Listings";
            this.optFileTypeAny.UseVisualStyleBackColor = true;
            // 
            // txtNewsSearchTagFilters
            // 
            this.txtNewsSearchTagFilters.Location = new System.Drawing.Point(209, 511);
            this.txtNewsSearchTagFilters.Name = "txtNewsSearchTagFilters";
            this.txtNewsSearchTagFilters.Size = new System.Drawing.Size(357, 20);
            this.txtNewsSearchTagFilters.TabIndex = 32;
            // 
            // txtWebSearchTagFilters
            // 
            this.txtWebSearchTagFilters.Location = new System.Drawing.Point(209, 489);
            this.txtWebSearchTagFilters.Name = "txtWebSearchTagFilters";
            this.txtWebSearchTagFilters.Size = new System.Drawing.Size(357, 20);
            this.txtWebSearchTagFilters.TabIndex = 31;
            // 
            // label12
            // 
            this.label12.AutoSize = true;
            this.label12.BackColor = System.Drawing.Color.Transparent;
            this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label12.Location = new System.Drawing.Point(39, 444);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(351, 16);
            this.label12.TabIndex = 30;
            this.label12.Text = "Set SearchTagFilter(s) for Web and News Results";
            // 
            // label17
            // 
            this.label17.AutoSize = true;
            this.label17.BackColor = System.Drawing.Color.Transparent;
            this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label17.Location = new System.Drawing.Point(39, 540);
            this.label17.Name = "label17";
            this.label17.Size = new System.Drawing.Size(315, 16);
            this.label17.TabIndex = 30;
            this.label17.Text = "Return Files of this Type (Web SourceType):";
            // 
            // label13
            // 
            this.label13.AutoSize = true;
            this.label13.BackColor = System.Drawing.Color.Transparent;
            this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label13.Location = new System.Drawing.Point(41, 372);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(202, 16);
            this.label13.TabIndex = 30;
            this.label13.Text = "Sort PhoneBook Results By:";
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.optRelevanceSort);
            this.groupBox2.Controls.Add(this.optDistanceSort);
            this.groupBox2.Location = new System.Drawing.Point(251, 379);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(314, 56);
            this.groupBox2.TabIndex = 29;
            this.groupBox2.TabStop = false;
            // 
            // optRelevanceSort
            // 
            this.optRelevanceSort.AutoSize = true;
            this.optRelevanceSort.Location = new System.Drawing.Point(30, 30);
            this.optRelevanceSort.Name = "optRelevanceSort";
            this.optRelevanceSort.Size = new System.Drawing.Size(77, 17);
            this.optRelevanceSort.TabIndex = 1;
            this.optRelevanceSort.Text = "Relevance";
            this.optRelevanceSort.UseVisualStyleBackColor = true;
            // 
            // optDistanceSort
            // 
            this.optDistanceSort.AutoSize = true;
            this.optDistanceSort.Checked = true;
            this.optDistanceSort.Location = new System.Drawing.Point(30, 13);
            this.optDistanceSort.Name = "optDistanceSort";
            this.optDistanceSort.Size = new System.Drawing.Size(110, 17);
            this.optDistanceSort.TabIndex = 0;
            this.optDistanceSort.TabStop = true;
            this.optDistanceSort.Text = "Distance (Default)";
            this.optDistanceSort.UseVisualStyleBackColor = true;
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.optSafeSearchModerate);
            this.groupBox1.Controls.Add(this.optSafeSearchStrict);
            this.groupBox1.Controls.Add(this.optSafeSearchOff);
            this.groupBox1.Location = new System.Drawing.Point(251, 89);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(314, 71);
            this.groupBox1.TabIndex = 27;
            this.groupBox1.TabStop = false;
            // 
            // optSafeSearchModerate
            // 
            this.optSafeSearchModerate.AutoSize = true;
            this.optSafeSearchModerate.Checked = true;
            this.optSafeSearchModerate.Location = new System.Drawing.Point(30, 31);
            this.optSafeSearchModerate.Name = "optSafeSearchModerate";
            this.optSafeSearchModerate.Size = new System.Drawing.Size(234, 17);
            this.optSafeSearchModerate.TabIndex = 8;
            this.optSafeSearchModerate.TabStop = true;
            this.optSafeSearchModerate.Text = "Moderate - Filter sexually explicit images only";
            this.optSafeSearchModerate.UseVisualStyleBackColor = true;
            // 
            // optSafeSearchStrict
            // 
            this.optSafeSearchStrict.AutoSize = true;
            this.optSafeSearchStrict.Location = new System.Drawing.Point(30, 13);
            this.optSafeSearchStrict.Name = "optSafeSearchStrict";
            this.optSafeSearchStrict.Size = new System.Drawing.Size(260, 17);
            this.optSafeSearchStrict.TabIndex = 7;
            this.optSafeSearchStrict.Text = "Strict - Filter sexually explicit text and image results";
            this.optSafeSearchStrict.UseVisualStyleBackColor = true;
            // 
            // optSafeSearchOff
            // 
            this.optSafeSearchOff.AutoSize = true;
            this.optSafeSearchOff.Location = new System.Drawing.Point(30, 49);
            this.optSafeSearchOff.Name = "optSafeSearchOff";
            this.optSafeSearchOff.Size = new System.Drawing.Size(170, 17);
            this.optSafeSearchOff.TabIndex = 9;
            this.optSafeSearchOff.Text = "Off - Do not filter search results";
            this.optSafeSearchOff.UseVisualStyleBackColor = true;
            // 
            // chkDisableHostCollapsing
            // 
            this.chkDisableHostCollapsing.AutoSize = true;
            this.chkDisableHostCollapsing.Location = new System.Drawing.Point(179, 347);
            this.chkDisableHostCollapsing.Name = "chkDisableHostCollapsing";
            this.chkDisableHostCollapsing.Size = new System.Drawing.Size(217, 17);
            this.chkDisableHostCollapsing.TabIndex = 22;
            this.chkDisableHostCollapsing.Text = "Check this box to disable host collapsing";
            this.chkDisableHostCollapsing.UseVisualStyleBackColor = true;
            // 
            // chkDisableSpellCorrectForSpecialWords
            // 
            this.chkDisableSpellCorrectForSpecialWords.AutoSize = true;
            this.chkDisableSpellCorrectForSpecialWords.Location = new System.Drawing.Point(179, 330);
            this.chkDisableSpellCorrectForSpecialWords.Name = "chkDisableSpellCorrectForSpecialWords";
            this.chkDisableSpellCorrectForSpecialWords.Size = new System.Drawing.Size(309, 17);
            this.chkDisableSpellCorrectForSpecialWords.TabIndex = 21;
            this.chkDisableSpellCorrectForSpecialWords.Text = "Check this box to disable spell correction for query operators";
            this.chkDisableSpellCorrectForSpecialWords.UseVisualStyleBackColor = true;
            // 
            // txtRadius
            // 
            this.txtRadius.Location = new System.Drawing.Point(466, 274);
            this.txtRadius.Name = "txtRadius";
            this.txtRadius.Size = new System.Drawing.Size(100, 20);
            this.txtRadius.TabIndex = 20;
            this.txtRadius.Text = "5.0";
            // 
            // txtLatitude
            // 
            this.txtLatitude.Location = new System.Drawing.Point(466, 252);
            this.txtLatitude.Name = "txtLatitude";
            this.txtLatitude.Size = new System.Drawing.Size(100, 20);
            this.txtLatitude.TabIndex = 19;
            this.txtLatitude.Text = "47.422433";
            // 
            // txtLongitude
            // 
            this.txtLongitude.Location = new System.Drawing.Point(466, 230);
            this.txtLongitude.Name = "txtLongitude";
            this.txtLongitude.Size = new System.Drawing.Size(100, 20);
            this.txtLongitude.TabIndex = 18;
            this.txtLongitude.Text = "-122.305833";
            // 
            // chkQueryWordMarking
            // 
            this.chkQueryWordMarking.AutoSize = true;
            this.chkQueryWordMarking.Checked = true;
            this.chkQueryWordMarking.CheckState = System.Windows.Forms.CheckState.Checked;
            this.chkQueryWordMarking.Location = new System.Drawing.Point(179, 313);
            this.chkQueryWordMarking.Name = "chkQueryWordMarking";
            this.chkQueryWordMarking.Size = new System.Drawing.Size(314, 17);
            this.chkQueryWordMarking.TabIndex = 17;
            this.chkQueryWordMarking.Text = "Check this box to enable query word marking (hit highlighting)";
            this.chkQueryWordMarking.UseVisualStyleBackColor = true;
            // 
            // label11
            // 
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(109, 188);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(293, 13);
            this.label11.TabIndex = 16;
            this.label11.Text = "Specify the Language and Country/Region for search results";
            // 
            // cbxCultureInfo
            // 
            this.cbxCultureInfo.FormattingEnabled = true;
            this.cbxCultureInfo.Items.AddRange(new object[] {
            "da-DK",
            "de-AT",
            "de-CH",
            "de-DE",
            "en-AU",
            "en-CA",
            "en-GB",
            "en-ID",
            "en-IE",
            "en-IN",
            "en-MY",
            "en-NZ",
            "en-PH",
            "en-SG",
            "en-US",
            "en-XA",
            "en-ZA",
            "es-AR",
            "es-ES",
            "es-MX",
            "es-US",
            "es-XL",
            "fi-FI",
            "fr-BE",
            "fr-CA",
            "fr-CH",
            "fr-FR",
            "it-IT",
            "ja-JP",
            "ko-KR",
            "nb-NO",
            "nl-BE",
            "nl-NL",
            "pt-BR",
            "sv-SE",
            "tr-TR",
            "zh-CN",
            "zh-HK",
            "zh-TW"});
            this.cbxCultureInfo.Location = new System.Drawing.Point(445, 184);
            this.cbxCultureInfo.Name = "cbxCultureInfo";
            this.cbxCultureInfo.Size = new System.Drawing.Size(121, 21);
            this.cbxCultureInfo.TabIndex = 15;
            this.cbxCultureInfo.Text = "en-US";
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Location = new System.Drawing.Point(109, 278);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(198, 13);
            this.label10.TabIndex = 14;
            this.label10.Text = "Specify the Radius of the search in miles";
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(109, 256);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(180, 13);
            this.label9.TabIndex = 13;
            this.label9.Text = "Specify the Latitude of your Location";
            // 
            // label16
            // 
            this.label16.AutoSize = true;
            this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label16.Location = new System.Drawing.Point(141, 515);
            this.label16.Name = "label16";
            this.label16.Size = new System.Drawing.Size(42, 13);
            this.label16.TabIndex = 12;
            this.label16.Text = "News:";
            // 
            // label15
            // 
            this.label15.AutoSize = true;
            this.label15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label15.Location = new System.Drawing.Point(141, 493);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(37, 13);
            this.label15.TabIndex = 12;
            this.label15.Text = "Web:";
            // 
            // label14
            // 
            this.label14.AutoSize = true;
            this.label14.Location = new System.Drawing.Point(109, 466);
            this.label14.Name = "label14";
            this.label14.Size = new System.Drawing.Size(433, 13);
            this.label14.TabIndex = 12;
            this.label14.Text = "Type your SearchTag Name(s) in the appropriate text box, below, separated by semi" +
                "colons";
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(109, 234);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(189, 13);
            this.label8.TabIndex = 12;
            this.label8.Text = "Specify the Longitude of your Location";
            // 
            // txtOffset
            // 
            this.txtOffset.Location = new System.Drawing.Point(466, 52);
            this.txtOffset.Name = "txtOffset";
            this.txtOffset.Size = new System.Drawing.Size(100, 20);
            this.txtOffset.TabIndex = 11;
            this.txtOffset.Text = "0";
            // 
            // txtNumResults
            // 
            this.txtNumResults.Location = new System.Drawing.Point(466, 29);
            this.txtNumResults.Name = "txtNumResults";
            this.txtNumResults.Size = new System.Drawing.Size(100, 20);
            this.txtNumResults.TabIndex = 10;
            this.txtNumResults.Text = "5";
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(109, 56);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(286, 13);
            this.label7.TabIndex = 6;
            this.label7.Text = "Specify the starting point for results (Offset Value - 0 to 999)";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(109, 33);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(272, 13);
            this.label6.TabIndex = 5;
            this.label6.Text = "Specify the number of results per page to return (1 to 50)";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.BackColor = System.Drawing.Color.Transparent;
            this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.Location = new System.Drawing.Point(41, 301);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(96, 16);
            this.label5.TabIndex = 4;
            this.label5.Text = "SearchFlags";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.Location = new System.Drawing.Point(41, 164);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(133, 16);
            this.label4.TabIndex = 3;
            this.label4.Text = "CultureInfo Setting";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.Location = new System.Drawing.Point(41, 212);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(147, 16);
            this.label3.TabIndex = 2;
            this.label3.Text = "Location Information";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.Location = new System.Drawing.Point(41, 85);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(146, 16);
            this.label2.TabIndex = 1;
            this.label2.Text = "SafeSearch Options";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.Location = new System.Drawing.Point(41, 9);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(203, 16);
            this.label1.TabIndex = 0;
            this.label1.Text = "Results Per Page and Offset";
            // 
            // frmSearchSample
            // 
            this.AcceptButton = this.btnSearch;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.SystemColors.Control;
            this.ClientSize = new System.Drawing.Size(680, 734);
            this.Controls.Add(this.tabControl1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.Name = "frmSearchSample";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Live Search API Version 1.1 Sample Application";
            this.tabControl1.ResumeLayout(false);
            this.SearchPage.ResumeLayout(false);
            this.SearchPage.PerformLayout();
            this.SettingsPage.ResumeLayout(false);
            this.SettingsPage.PerformLayout();
            this.groupBox3.ResumeLayout(false);
            this.groupBox3.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.TabControl tabControl1;
        private System.Windows.Forms.TabPage SearchPage;
        private System.Windows.Forms.TabPage SettingsPage;
        private System.Windows.Forms.TextBox txtQuery;
        private System.Windows.Forms.Button btnNearMe;
        private System.Windows.Forms.Button btnSearch;
        private System.Windows.Forms.WebBrowser webBrowser1;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.RadioButton optSafeSearchStrict;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.CheckBox chkQueryWordMarking;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.ComboBox cbxCultureInfo;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.TextBox txtOffset;
        private System.Windows.Forms.TextBox txtNumResults;
        private System.Windows.Forms.RadioButton optSafeSearchOff;
        private System.Windows.Forms.RadioButton optSafeSearchModerate;
        private System.Windows.Forms.TextBox txtRadius;
        private System.Windows.Forms.TextBox txtLatitude;
        private System.Windows.Forms.TextBox txtLongitude;
        private System.Windows.Forms.CheckBox chkDisableSpellCorrectForSpecialWords;
        private System.Windows.Forms.CheckBox chkDisableHostCollapsing;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Label label13;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.RadioButton optRelevanceSort;
        private System.Windows.Forms.RadioButton optDistanceSort;
        private System.Windows.Forms.Label label12;
        private System.Windows.Forms.Label label14;
        private System.Windows.Forms.TextBox txtNewsSearchTagFilters;
        private System.Windows.Forms.TextBox txtWebSearchTagFilters;
        private System.Windows.Forms.Label label16;
        private System.Windows.Forms.Label label15;
        private System.Windows.Forms.Label label17;
        private System.Windows.Forms.GroupBox groupBox3;
        private System.Windows.Forms.RadioButton optFileTypeYP_Only;
        private System.Windows.Forms.RadioButton optFileTypeWP_Only;
        private System.Windows.Forms.RadioButton optFileTypeAny;
        private System.Windows.Forms.ComboBox cbxWebFileType;
        private System.Windows.Forms.Label label18;
    }
}

Page view tracker