예제 #1
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);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Load top rated movies from the first page in the API results
        /// </summary>
        private async void loadMovies()
        {
            var movies = await LoadMovies.TopRated();

            currentMovie = movies[movies.Count - 1].Movie;
            foreach (CustomMovie cm in movies)
            {
                lbMovies.Items.Add(cm);
                beginMovies.Add(cm);
            }
            currentSearchText              = "";
            searchChanged                  = false;
            lbMovies.SelectedIndex         = 0;
            toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.topRatedCount, LoadMovies.topRatedTotal);
        }