Ejemplo n.º 1
0
 public void Init()
 {
     // Sets the active item to be displayed in the content control
     // to the anime list view
     _animeListViewModel = new AnimeListViewModel();
     ActivateItem(_animeListViewModel);
 }
Ejemplo n.º 2
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();
        }