Beispiel #1
0
        private void ExecuteSearch(object _input)
        {
            string             input   = _input.ToString(); // Gets the text from the search bar
            AnimeListViewModel animeVM = _animeListViewModel;

            // Cancels the search if there is no input
            if (string.IsNullOrEmpty(input))
            {
                StopSearching();
                return;
            }

            // Searches the anime list for entries that contain the input and places it in a new bindable collection
            var filteredList = animeVM.Animes.Where(anime => anime.AnimeName.ToLower().Contains(input.ToLower()));

            animeVM.IsSearching = true;

            foreach (var anime in animeVM.Animes)
            {
                // If the anime is within the filtered list, make it visible and flag it for searching
                // If not, hide it and make sure it isn't flagged for searching
                if (filteredList.Contains(anime))
                {
                    anime.IsFlaggedForSearch = true;
                    anime.Hidden             = false;
                }
                else
                {
                    anime.IsFlaggedForSearch = false;
                    anime.Hidden             = true;
                }
            }

            // Sorts the list by status when a search query is entered
            // This ensures if the user enters a search under a sorting tab, the list will still be sorted
            animeVM.SortAnimeByStatus();
        }
Beispiel #2
0
 private void StopSearching()
 {
     _animeListViewModel.IsSearching = false;
     _animeListViewModel.SortAnimeByStatus();
 }