コード例 #1
0
ファイル: ShellViewModel.cs プロジェクト: hines-r/AniNeko
 public void Init()
 {
     // Sets the active item to be displayed in the content control
     // to the anime list view
     _animeListViewModel = new AnimeListViewModel();
     ActivateItem(_animeListViewModel);
 }
コード例 #2
0
ファイル: ShellViewModel.cs プロジェクト: hines-r/AniNeko
        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();
        }