private void RunSearch(string bandName, string songName, ResultsSortOrder sortBy)
        {
            _sortOrder = sortBy;
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                Dialog.Show(AppResources.Search_NoInternetConnection, AppResources.Search_OperationFailed);
                return;
            }

            SearchGroupTabs   = null;
            SearchPopularTabs = null;
            IsHintVisible     = false;
            Deployment.Current.Dispatcher.BeginInvoke(
                () =>
            {
                IsNothingFound        = false;
                IsNothingPopularFound = false;
                IsSearching           = true;
            });

            _tabSearcher.Run(bandName, songName, CurrentPageIndex, SearchTabType, sortBy);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Handler for WebClient that parses xml data into specific objects
        ///     throws specific exceptions if error occurs
        /// </summary>
        public void Run(string group, string song, int pageNumber, TabulatureType type, ResultsSortOrder sortBy)
        {
            WebClient client = new WebClient();

            client.DownloadStringCompleted += (s, e) =>
            {
                try
                {
                    if (e.Error == null)
                    {
                        using (XmlReader reader = XmlReader.Create(new StringReader(e.Result)))
                        {
                            while (reader.Read())
                            {
                                if ((reader.Name == "results") && (reader.IsStartElement()))
                                {
                                    Summary = CreateResultSummary(reader);
                                }

                                if ((reader.Name == "result") && (reader.IsStartElement()))
                                {
                                    Entries.Add(CreateResultEntry(reader));
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
                finally
                {
                    InvokeSearchComplete(e);
                }
            };
            Summary = new SearchTabResultSummary();
            Entries = new List <SearchTabResultEntry>();
            client.DownloadStringAsync(new Uri(String.Format(GetRequestTemplate(type, sortBy), group, song, pageNumber)));
        }
Exemplo n.º 3
0
        private string GetRequestTemplate(TabulatureType tabType, ResultsSortOrder sortBy)
        {
            string requestTemplate;
            string alphabeticalSortParams = "&order_mode=ASC&order=title_srt";

            switch (tabType)
            {
            case TabulatureType.All:
                if (sortBy == ResultsSortOrder.Alphabetical)
                {
                    requestTemplate = RequestTemplateAll + alphabeticalSortParams;
                }
                else
                {
                    requestTemplate = RequestTemplateAll;
                }
                break;

            case TabulatureType.Guitar:
                if (sortBy == ResultsSortOrder.Alphabetical)
                {
                    requestTemplate = RequestTemplateGuitar + alphabeticalSortParams;
                }
                else
                {
                    requestTemplate = RequestTemplateAll;
                }
                break;

            case TabulatureType.Bass:
                if (sortBy == ResultsSortOrder.Alphabetical)
                {
                    requestTemplate = RequestTemplateBass + alphabeticalSortParams;
                }
                else
                {
                    requestTemplate = RequestTemplateAll;
                }
                break;

            case TabulatureType.Chords:
                if (sortBy == ResultsSortOrder.Alphabetical)
                {
                    requestTemplate = RequestTemplateChords + alphabeticalSortParams;
                }
                else
                {
                    requestTemplate = RequestTemplateAll;
                }
                break;

            case TabulatureType.Drum:
                if (sortBy == ResultsSortOrder.Alphabetical)
                {
                    requestTemplate = RequestTemplateDrum + alphabeticalSortParams;
                }
                else
                {
                    requestTemplate = RequestTemplateAll;
                }
                break;

            case TabulatureType.GuitarPro:
                if (sortBy == ResultsSortOrder.Alphabetical)
                {
                    requestTemplate = RequestTemplateGuitarPro + alphabeticalSortParams;
                }
                else
                {
                    requestTemplate = RequestTemplateAll;
                }
                break;

            default:
                requestTemplate = RequestTemplateAll;
                break;
            }

            return(requestTemplate);
        }