예제 #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 movies from the selected genre
        /// </summary>
        private async void loadGenre()
        {
            tbSearch.ResetText();
            lbMovies.Items.Clear();
            List <CustomMovie> movies = await LoadMovies.GetByGenre(cbGenre.SelectedItem.ToString());

            foreach (CustomMovie cm in movies)
            {
                lbMovies.Items.Add(cm);
            }
            currentGenre  = cbGenre.SelectedItem.ToString();
            genreChanged  = true;
            searchChanged = false;
            if (lbMovies.Items.Count > 0)
            {
                lbMovies.SelectedIndex = 0;
            }
            toopStripLblSearchResults.Text = string.Format("Showing {0} of {1} results", LoadMovies.genreCount, LoadMovies.genreTotal);
        }