protected override void OnDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null) // Did an error occur with the download?
            {
                this.OnSearchError(e.Error.Message);
                return;
            }

            try
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(e.Result);
                int index = 1;
                _results.Clear();
                foreach (XmlNode node in document.GetElementsByTagName("place"))
                {
                    SearchResult result = new SearchResult(index++);
                    result.DisplayName = node.Attributes.GetNamedItem("display_name").InnerText;
                    result.Latitude = double.Parse(node.Attributes.GetNamedItem("lat").InnerText, CultureInfo.InvariantCulture);
                    result.Longitude = double.Parse(node.Attributes.GetNamedItem("lon").InnerText, CultureInfo.InvariantCulture);
                    string[] boundingBox = node.Attributes.GetNamedItem("boundingbox").InnerText.Split(',');
                    if (boundingBox.Length == 4)
                    {
                        double height, width;
                        if (TryGetSize(boundingBox[0], boundingBox[1], out height) &&
                            TryGetSize(boundingBox[2], boundingBox[3], out width))
                        {
                            //result.Size = new Size(width, height);
                        }
                    }
                    _results.Add(result);
                }
                this.OnSearchCompleted();
            }
            catch (NullReferenceException) // One of the calls to GetNamesItem() couldn't find it and returned null
            {
                this.OnSearchError("XML data is invalid.");
            }
            catch (XmlException ex) // XmlDocument.LoadXml failed
            {
                this.OnSearchError(ex.Message);
            }
        }
 protected bool TryParseLatitudeLongitude(string text)
 {
     string[] tokens = text.Split(new char[] { ',', ' ', '°' }, StringSplitOptions.RemoveEmptyEntries);
     if (tokens.Length == 2)
     {
         double latitude, longitude;
         if (double.TryParse(tokens[0], out latitude) && double.TryParse(tokens[1], out longitude))
         {
             SearchResult result = new SearchResult(1);
             result.DisplayName = string.Format(CultureInfo.CurrentUICulture, "{0:f4}°, {1:f4}°", latitude, longitude);
             result.Latitude = latitude;
             result.Longitude = longitude;
             _results.Clear();
             _results.Add(result);
             this.OnSearchCompleted();
             return true;
         }
     }
     return false;
 }
 private void NavigateTo(SearchResult result)
 {
     this.resultsArea.IsExpanded = false;
     var callback = this.Navigate;
     if (callback != null)
     {
         callback(this, new NavigateEventArgs(result));
     }
 }
 /// <summary>Initializes a new instance of the NavigateEventArgs class.</summary>
 /// <param name="result">The SearchResult to navigate to.</param>
 internal NavigateEventArgs(SearchResult result)
 {
     this.Result = result;
 }