private void searchProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) { if (e.Cancelled) { return; } if (e.RequestResult.ResultCode != RequestResultCode.Success) { return; } StringBuilder sb = new StringBuilder(); SearchRequestResult requestResult = e.RequestResult; sb.Append(String.Format("Result Code: {0}\n", requestResult.ResultCode)); if (String.IsNullOrEmpty(requestResult.FaultReason)) { sb.Append(String.Format("Fault Reason: (none)\n", requestResult.FaultReason)); } else { sb.Append(String.Format("Fault Reason: {0}\n", requestResult.FaultReason)); } sb.Append(String.Format("Search Location: {0}\n", requestResult.Keyword)); sb.Append(String.Format("Estimated Matches: {0}\n", requestResult.EstimatedMatches)); sb.Append(String.Format("SearchResults:\n{0}", ProcessLocationList(requestResult.SearchResults))); tbSearchResult.Text = sb.ToString(); }
void searchProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) { SearchRequestResult result = e.RequestResult; if (result.ResultCode == RequestResultCode.Success) { LocationInformation region = result.SearchRegion; if (region != null) { NavigateTo(region.Location); } else { if (result.SearchResults.Count > 0) { NavigateTo(result.SearchResults[0].Location); } } //DisplayResults(e.RequestResult); } if (result.ResultCode == RequestResultCode.BadRequest) { XtraMessageBox.Show("The Bing Search service does not work for this location."); } }
private void searchDataProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) { SearchRequestResult result = e.RequestResult; if (result.ResultCode == RequestResultCode.Success) { List <LocationInformation> regions = result.SearchResults; foreach (LocationInformation region in regions) { AddPushpin(region.Location); if (idx == addresses.Count) { map.ZoomToFitLayerItems(); } } DisplayResults(e.RequestResult); asyncResult = this.BeginInvoke((DoSearch)SearchAsync); } if (result.ResultCode == RequestResultCode.BadRequest) { tbResults.Text += "The Bing Search service does not work for this location."; } }
private void searchDataProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) { SearchRequestResult result = e.RequestResult; if (result.ResultCode == RequestResultCode.Success) { if (result.SearchResults.Count > 0) { NavigateTo(result.SearchResults[0].Location); } DisplayResults(e.RequestResult); } if (result.ResultCode == RequestResultCode.BadRequest) { tbResults.Text = "The Bing Search service does not work for this location."; } }
private void DisplayResults(SearchRequestResult requestResult) { StringBuilder resultList = new StringBuilder(""); if (requestResult.ResultCode == RequestResultCode.Success) { int resCounter = 1; foreach (LocationInformation resultInfo in requestResult.SearchResults) { resultList.Append(String.Format("\n Result {0}: \n", resCounter)); resultList.Append(String.Format(resultInfo.DisplayName + "\n")); resultList.Append(String.Format("Geographical coordinates: {0}", resultInfo.Location)); resultList.Append(String.Format("\n______________________________\n")); resCounter++; } } tbResults.Text += resultList.ToString(); }
private void SearchDataProvider_SearchCompleted(object sender, BingSearchCompletedEventArgs e) { SearchRequestResult result = e.RequestResult; if (result.ResultCode == RequestResultCode.Success) { //List<LocationInformation> regions = result.SearchResults; //Really we should display all the returned regions for disambiguation, but we're just going with the best match //which is the first one LocationInformation region = result.SearchResults.FirstOrDefault(); AddOrMovePushpin(region.Location); MapControl.ZoomLevel = 13; SaveMapData(); } if (result.ResultCode == RequestResultCode.BadRequest) { this.DisplayWarning("The Bing Search service does not work for this location."); } }