Пример #1
0
        /// <summary>
        /// Load movies whose titles contain the given keywords
        /// </summary>
        private async void loadSearch()
        {
            lbMovies.Items.Clear();
            if (tbSearch.Text.Trim() == "")
            {
                foreach (CustomMovie cm in beginMovies)
                {
                    lbMovies.Items.Add(cm);
                }
                toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.topRatedCount, LoadMovies.topRatedTotal);
                LoadMovies.resetParams();
            }
            else
            {
                var movies = await LoadMovies.SearchMovies(tbSearch.Text.Trim());

                foreach (CustomMovie cm in movies)
                {
                    lbMovies.Items.Add(cm);
                }
                toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.searchCount, LoadMovies.searchTotal);
            }
            currentSearchText = tbSearch.Text.Trim();
            searchChanged     = true;
            genreChanged      = false;
            if (lbMovies.Items.Count > 0)
            {
                lbMovies.SelectedIndex = 0;
            }
        }
Пример #2
0
        /// <summary>
        /// Called when the user presses the "Load more" button, it checks whether it should load more top rated movies,
        /// <para>movies from search results or movies from the selected genre</para>
        /// </summary>
        private async void loadMore()
        {
            bool topRated             = false;
            bool search               = false;
            bool genre                = false;
            List <CustomMovie> movies = null;

            if (cbGenre.SelectedItem.ToString().Equals("All") && tbSearch.Text.Trim().Length == 0)
            {
                movies = await LoadMovies.TopRated();

                topRated = true;
            }
            else if (!cbGenre.SelectedItem.ToString().Equals("All") && tbSearch.Text.Trim().Length == 0)
            {
                movies = await LoadMovies.GetByGenre(cbGenre.SelectedItem.ToString());

                genre = true;
            }
            else if (cbGenre.SelectedItem.ToString().Equals("All") && tbSearch.Text.Trim().Length > 0)
            {
                movies = await LoadMovies.SearchMovies(tbSearch.Text.Trim());

                search = true;
            }
            else
            {
                return;
            }
            if (movies != null)
            {
                foreach (CustomMovie cm in movies)
                {
                    if (topRated)
                    {
                        beginMovies.Add(cm);
                    }
                    lbMovies.Items.Add(cm);
                }
                if (topRated)
                {
                    toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.topRatedCount, LoadMovies.topRatedTotal);
                }
                else if (search)
                {
                    toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.searchCount, LoadMovies.searchTotal);
                }
                else if (genre)
                {
                    toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.genreCount, LoadMovies.genreTotal);
                }
            }
        }