private void Search(SearchType searchType, SearchKeyword keyword, object list) { LoadingProgress.IsActive = true; CurrentKeyword = keyword; Artists.Clear(); Albums.Clear(); Songs.Clear(); Playlists.Clear(); Folders.Clear(); switch (searchType) { case SearchType.Artists: Artists.SetTo(list as ObservableCollection <Playlist>); break; case SearchType.Albums: Albums.SetTo(list as ObservableCollection <AlbumView>); break; case SearchType.Songs: Songs.SetTo(list as ObservableCollection <Music>); break; case SearchType.Playlists: Playlists.SetTo(list as ObservableCollection <AlbumView>); break; case SearchType.Folders: Folders.SetTo(list as ObservableCollection <GridFolderView>); break; } LoadingProgress.IsActive = false; }
private async void Search(SearchKeyword keyword) { if (IsSearching) { MainPage.Instance.ShowLocalizedNotification("ProcessingRequest"); return; } IsSearching = true; LoadingProgress.Visibility = Visibility.Visible; NoResultTextBlock.Visibility = Visibility.Collapsed; CurrentKeyword = keyword; Artists.Clear(); Albums.Clear(); Songs.Clear(); Playlists.Clear(); Folders.Clear(); string modifiedKeyowrd = keyword.Text.ToLowerInvariant(); await SearchArtists(keyword.Songs, modifiedKeyowrd, Settings.settings.SearchArtistsCriterion); await SearchAlbums(keyword.Songs, modifiedKeyowrd, Settings.settings.SearchAlbumsCriterion); await SearchSongs(keyword.Songs, modifiedKeyowrd, Settings.settings.SearchSongsCriterion); await SearchPlaylists(keyword.Playlists, modifiedKeyowrd, Settings.settings.SearchPlaylistsCriterion); await SearchFolders(keyword.Tree, modifiedKeyowrd, Settings.settings.SearchFoldersCriterion); NoResultTextBlock.Visibility = Artists.Count == 0 && Albums.Count == 0 && Songs.Count == 0 && Playlists.Count == 0 && Folders.Count == 0 ? Visibility.Visible : Visibility.Collapsed; LoadingProgress.Visibility = Visibility.Collapsed; IsSearching = false; }
public static string GetSearchHeader(SearchKeyword keyword, bool isMinimal) { string header = Helper.LocalizeMessage("Quotations", keyword.Text); return(isMinimal ? header : keyword.Tree == Settings.settings.Tree ? Helper.LocalizeMessage("SearchResult", keyword.Text) : Helper.LocalizeMessage("SearchDirectoryResult", keyword.Text, keyword.Tree.Directory)); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); SearchArgs searchArgs = (SearchArgs)e.Parameter; searchType = searchArgs.Type; object list = searchArgs.Collection; ResultTextBlock.Text = searchArgs.Summary; SearchKeyword keyword = SearchPage.History.Peek(); switch (searchType) { case SearchType.Artists: Criteria = SearchPage.ArtistsCriteria; break; case SearchType.Albums: Criteria = SearchPage.AlbumsCriteria; break; case SearchType.Songs: Criteria = SearchPage.SongsCriteria; break; case SearchType.Playlists: Criteria = SearchPage.PlaylistsCriteria; break; case SearchType.Folders: Criteria = SearchPage.FoldersCriteria; break; } MainPage.Instance.SetHeaderTextWithoutLocalization(SearchPage.GetSearchHeader(keyword, MainPage.Instance.IsMinimal)); switch (e.NavigationMode) { case NavigationMode.New: History.Push(keyword); Search(searchType, keyword, list); break; case NavigationMode.Back: if (CurrentKeyword != keyword) { Search(searchType, keyword, list); } break; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); SearchKeyword keyword = e.Parameter as SearchKeyword; MainPage.Instance.SetHeaderTextWithoutLocalization(GetSearchHeader(keyword, MainPage.Instance.IsMinimal)); switch (e.NavigationMode) { case NavigationMode.New: History.Push(CurrentKeyword = keyword); Search(keyword); break; case NavigationMode.Back: if (CurrentKeyword != keyword) { Search(keyword); } break; } }