示例#1
0
        private async Task LoadSongsListForSearchExpression(string searchExpression)
        {
            this.topSearchResult              = new SearchResults.SearchResult();
            this.topSearchResult.DoubleClick += this.TopSearchResult_DoubleClick;
            this.SearchResults.Content        = this.topSearchResult;

            await Task.Factory.StartNew(async() =>
            {
                switch (this.CurrentGroupType)
                {
                case SearchResultsGroupType.Song:
                    if (await this.songDBSearcher.LoadItemIdsAsync(searchExpression))
                    {
                        List <Song> songs = await this.songDBSearcher.LoadItemsAsync(50);
                        this.addingStuff  = true;
                        foreach (Song song in songs)
                        {
                            await this.AddSongToSearchResultsAsync(song, this.topSearchResult);
                        }

                        this.addingStuff = false;
                    }

                    break;

                case SearchResultsGroupType.Album:
                    if (await this.albumDBSearcher.LoadItemIdsAsync(searchExpression))
                    {
                        List <Album> albums = await this.albumDBSearcher.LoadItemsAsync(50);
                        this.addingStuff    = true;
                        foreach (Album album in albums)
                        {
                            await this.AddAlbumToSearchResultsAsync(album, this.topSearchResult);
                        }

                        this.addingStuff = false;
                    }

                    break;

                case SearchResultsGroupType.Artist:
                    if (await this.artistDBSearcher.LoadItemIdsAsync(searchExpression))
                    {
                        List <Artist> artists = await this.artistDBSearcher.LoadItemsAsync(50);
                        this.addingStuff      = true;
                        foreach (Artist artist in artists)
                        {
                            await this.AddArtistToSearchResultsAsync(artist, this.topSearchResult);
                        }

                        this.addingStuff = false;
                    }

                    break;
                }
            });
        }