void wc_DownloadSearchResultsCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Debug.WriteLine("ERROR: Web error happened. Error: " + e.Error.ToString());
                ToastPrompt toast = new ToastPrompt();
                toast.Title = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
                return;
            }

            XDocument searchXml;
            try
            {
                searchXml = XDocument.Parse(e.Result);
            }
            catch (System.Xml.XmlException ex)
            {
                Debug.WriteLine("ERROR: Cannot parse gPodder.net search result XML. Error: " + ex.Message);
                ToastPrompt toast = new ToastPrompt();
                toast.Title = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
                return;
            }

            var query = from podcast in searchXml.Descendants("podcast")
                        select podcast;

            List<GPodderResultModel> results = new List<GPodderResultModel>();
            foreach (var result in query)
            {
                GPodderResultModel resultModel = new GPodderResultModel();
                try
                {
                    XElement logoElement = result.Element("logo_url");

                    if (logoElement == null
                        || String.IsNullOrEmpty(logoElement.Value))
                    {
                        logoElement = result.Element("scaled_logo_url");
                    }

                    if (logoElement != null
                        && String.IsNullOrEmpty(logoElement.Value) == false)
                    {
                        resultModel.PodcastLogoUrl = new Uri(logoElement.Value);
                    }

                    resultModel.PodcastName = result.Element("title").Value;
                    resultModel.PodcastUrl = result.Element("url").Value;
                }
                catch (UriFormatException)
                {
                    Debug.WriteLine("Could not parse logo from the feed.");
                }

                results.Add(resultModel);
            }

            Debug.WriteLine("Found {0} results.", results.Count);
            this.SearchResultList.ItemsSource = results;
            this.progressOverlay.Hide();
        }
        private void ResultTapped(object sender, System.Windows.Input.GestureEventArgs e)
        {
            m_searchResultModel = this.DataContext as GPodderResultModel;

            (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri(string.Format("/Views/PodcastSubscriptionIntroduction.xaml?podcastUrl={0}", m_searchResultModel.PodcastUrl), UriKind.Relative));
        }
        private void populatePopularUI()
        {
            var query = from podcast in m_popularPodcastsXML.Descendants("podcast")
                        select podcast;

            List<GPodderResultModel> results = new List<GPodderResultModel>();
            foreach (var result in query)
            {
                GPodderResultModel resultModel = new GPodderResultModel();

                XElement logoElement = result.Element("logo_url");

                if (logoElement == null
                    || String.IsNullOrEmpty(logoElement.Value))
                {
                    logoElement = result.Element("scaled_logo_url");
                }

                if (logoElement != null
                    && String.IsNullOrEmpty(logoElement.Value) == false)
                {
                    resultModel.PodcastLogoUrl = new Uri(logoElement.Value);
                }

                resultModel.PodcastName = result.Element("title").Value;
                resultModel.PodcastUrl = result.Element("url").Value;

                results.Add(resultModel);
            }

            Debug.WriteLine("Found {0} popular results.", results.Count);
            this.PopularResultList.ItemsSource = results;

            this.LoadingText.Visibility = Visibility.Collapsed;
        }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     m_searchResultModel = this.DataContext as GPodderResultModel;
     m_subscriptionManager.addSubscriptionFromURL(m_searchResultModel.PodcastUrl);
 }
        async private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(this.searchTerm.Text))
            {
                Debug.WriteLine("Empty search word. Do nothing.");
                return;
            }

            progressOverlay.Show();

            string searchQueryString = String.Format("https://gpodder.net/search.xml?q=\"{0}\"", this.searchTerm.Text);
            Debug.WriteLine("Search string: " + searchQueryString);

            try
            {
                String searchResult = await new HttpClient().GetStringAsync(searchQueryString);
                XDocument searchXml = XDocument.Parse(searchResult);

                var query = from podcast in searchXml.Descendants("podcast")
                select podcast;

                List<GPodderResultModel> results = new List<GPodderResultModel>();
                foreach (var result in query)
                {
                    GPodderResultModel resultModel = new GPodderResultModel();
                    XElement logoElement = result.Element("logo_url");

                    if (logoElement == null
                        || String.IsNullOrEmpty(logoElement.Value))
                    {
                        logoElement = result.Element("scaled_logo_url");
                    }

                    if (logoElement != null
                        && String.IsNullOrEmpty(logoElement.Value) == false)
                    {
                        resultModel.PodcastLogoUrl = new Uri(logoElement.Value);
                    }

                    resultModel.PodcastName = result.Element("title").Value;
                    resultModel.PodcastUrl = result.Element("url").Value;

                    results.Add(resultModel);
                }

                Debug.WriteLine("Found {0} results.", results.Count);
                this.SearchResultList.ItemsSource = results;
            }
            catch (HttpRequestException ex)
            {
                Debug.WriteLine("ERROR: Web error happened. Error: " + ex.Message);
                ToastPrompt toast = new ToastPrompt();
                toast.Title = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
            }
            catch (XmlException ex)
            {
                Debug.WriteLine("ERROR: Cannot parse gPodder.net search result XML. Error: " + ex.Message);
                ToastPrompt toast = new ToastPrompt();
                toast.Title = "Error";
                toast.Message = "Could not get search results.";

                toast.Show();
            }

            progressOverlay.Hide();
        }