Beispiel #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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Set genreal info for the selected movie and call methods to load additional info
        /// </summary>
        private async void setMovieInfo()
        {
            CustomMovie cm = lbMovies.SelectedItem as CustomMovie;

            if (!cm.Movie.Title.Equals(currentMovie.Title))
            {
                pbPoster.SizeMode = PictureBoxSizeMode.CenterImage;
                pbPoster.Image    = Properties.Resources.loading;
                Movie movie = await LoadMovies.GetMovie(cm);

                if (movie.ReleaseDate.HasValue)
                {
                    lblMovieTitle.Text = string.Format("{0} ({1})", movie.Title, movie.ReleaseDate.Value.Year.ToString());
                }
                else
                {
                    lblMovieTitle.Text = movie.Title;
                }
                lblRating.Text         = movie.VoteAverage.ToString("0.00");
                lblVotes.Text          = movie.VoteCount.ToString();
                pbPoster.SizeMode      = PictureBoxSizeMode.Zoom;
                pbPoster.ImageLocation = "http://image.tmdb.org/t/p/w500" + movie.Poster;
                lblDescription.Text    = movie.Overview;
                setCast(movie.Credits.Cast);
                setInfo(movie);
                setTrailer(movie.Videos.Results);
                currentMovie = movie;
            }
        }
Beispiel #3
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);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Load genres
        /// </summary>
        private async void setGenres()
        {
            List <CustomGenre> genres = await LoadMovies.GetGenres();

            foreach (CustomGenre cg in genres)
            {
                cbGenre.Items.Add(cg);
                Genres.Add(cg.Genre.Id, cg.Genre);
            }
            cbGenre.SelectedIndex = 0;
            currentGenre          = "All";
            genreChanged          = false;
        }
Beispiel #5
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);
        }
Beispiel #6
0
        /// <summary>
        /// Takes care of updating the label that shows the title of an upcoming movie, including the fade in/fade out effects
        /// </summary>
        private async void upcomingMoviesUpdate()
        {
            if (lblUpcoming.ForeColor == Color.FromArgb(242, 242, 242))
            {
                lblUpcoming.Text = upcoming[upcomingMovieIndex].Title;
                upcomingMovie    = await LoadMovies.GetMovie(upcoming[upcomingMovieIndex].Id);

                if (upcomingMovie == null)
                {
                    lblUpcoming.Enabled = false;
                }
                else
                {
                    lblUpcoming.Enabled = true;
                }
                if (++upcomingMovieIndex >= upcoming.Count())
                {
                    upcomingMovieIndex = 0;
                }
                upcomingInc = false;
                changeUpcomingRGB("decrement");
            }
            else if (lblUpcoming.ForeColor == Color.FromArgb(92, 92, 61))
            {
                if (upcomingInc)
                {
                    changeUpcomingRGB("increment");
                }
                else
                {
                    upcomingInc       = true;
                    timerFade.Enabled = false;
                }
            }
            else
            {
                if (!upcomingInc)
                {
                    changeUpcomingRGB("decrement");
                }
                else
                {
                    changeUpcomingRGB("increment");
                }
            }
            lblUpcoming.ForeColor = Color.FromArgb(upcomingRGB[0], upcomingRGB[1], upcomingRGB[2]);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        /// <summary>
        /// Load one page of upcoming movies
        /// </summary>
        private async void setUpcoming()
        {
            upcoming = new List <Movie>();
            var movies = await LoadMovies.getUpcoming();

            foreach (Movie m in movies)
            {
                upcoming.Add(m);
            }
            Random tempRandom = new Random();

            upcomingMovieIndex = tempRandom.Next(0, upcoming.Count() - 1);
            upcomingRGB        = new List <int>()
            {
                255, 255, 255
            };
            upcomingInc           = false;
            upcomingMovie         = null;
            timerFade.Enabled     = true;
            timerUpcoming.Enabled = true;
        }