示例#1
0
        public static MovieBean getMovieBean(MovieBean movie)
        {
            String searchString  = GlobalFunctions.editFilename(movie.fileName);
            String TheMovieDB_ID = GlobalFunctions.getTheMovieDbKeyFromGoogle(movie.getTitle());

            if (TheMovieDB_ID.Length < 1)
            {
                return(movie);
            }

            String movieJSON = GlobalFunctions.getHTML("https://api.themoviedb.org/3/movie/" + TheMovieDB_ID + "?api_key=" + THE_MOVIE_DB_API_KEY);
            String castJSON  = GlobalFunctions.getHTML("https://api.themoviedb.org/3/movie/" + TheMovieDB_ID + "/credits?api_key=" + THE_MOVIE_DB_API_KEY);

            MovieBean importedMovie = parseJSONForBean(movieJSON, castJSON);

            importedMovie.posterPath   = ImageHandler.savePoster(movie, importedMovie.posterPath);
            importedMovie.backdropPath = ImageHandler.saveBackdrop(movie, importedMovie.backdropPath);


            //add data to the storage list
            if (importedMovie.belongsToCollection != null && (!frmMain.files.collections.Contains(importedMovie.belongsToCollection)))
            {
                frmMain.files.collections.Add(importedMovie.belongsToCollection);
            }

            foreach (String genre in importedMovie.genres)
            {
                if (!frmMain.files.genres.Contains(genre))
                {
                    frmMain.files.genres.Add(genre);
                }
            }

            foreach (String prod in importedMovie.productionCompanies)
            {
                if (!frmMain.files.productionCompanies.Contains(prod))
                {
                    frmMain.files.productionCompanies.Add(prod);
                }
            }

            foreach (String lang in importedMovie.spokenLanguages)
            {
                if (!frmMain.files.languages.Contains(lang))
                {
                    frmMain.files.languages.Add(lang);
                }
            }

            foreach (MovieBean.Movie_DB_ID_Name actor in importedMovie.cast)
            {
                if (!frmMain.files.actors.Contains(actor.name))
                {
                    frmMain.files.actors.Add(actor.id);
                }
            }

            foreach (MovieBean.Movie_DB_ID_Name director in importedMovie.crew)
            {
                if (director.name.ToUpper().Equals("DIRECTOR"))
                {
                    if (!frmMain.files.actors.Contains(director.id))
                    {
                        frmMain.files.directors.Add(director.id);
                    }
                }
            }

            return(importedMovie);
        }
示例#2
0
        private void setupScreen()
        {
            //poster
            Bitmap poster = ImageHandler.getPoster(movie);

            if (poster != null)
            {
                pictureBox1.Image = poster;
            }

            //backdrop
            Bitmap backdrop = ImageHandler.getBackdrop(movie);

            if (backdrop != null)
            {
                //resizeImage
                Image img2 = new Bitmap(backdrop, new Size(pnlBackdrop.Width, pnlBackdrop.Height));

                //darken it
                Graphics g     = Graphics.FromImage(img2);
                dynamic  brush = new SolidBrush(Color.FromArgb(220, 0, 0, 0));
                g.FillRectangle(brush, new Rectangle(0, 0, pnlBackdrop.Width, pnlBackdrop.Height));

                //set the background
                pnlBackdrop.BackgroundImage = img2;
            }

            //title
            lblTitle.Text = movie.getTitle();

            //watched
            if (movie.watched)
            {
                lblTitle.Text = "✓ " + lblTitle.Text;
            }

            //adult
            if (movie.adult)
            {
                lblTitle.ForeColor      = Color.Fuchsia;
                lblCollection.ForeColor = Color.Fuchsia;
            }
            else
            {
                lblTitle.ForeColor      = Color.White;
                lblCollection.ForeColor = Color.White;
            }

            //collection
            if (movie.belongsToCollection != null)
            {
                pnlContent1.Location   = new Point(7, 56);
                lblCollection.Text     = movie.belongsToCollection;
                lblCollection.Location = new Point((lblTitle.Location.X + lblTitle.Width) - lblCollection.Width, lblCollection.Location.Y);
                if (lblCollection.Location.X < lblTitle.Location.X)
                {
                    lblCollection.Location = new Point(lblTitle.Location.X, lblCollection.Location.Y);
                }

                if (lblCollection.Location.X + lblCollection.Width > Width)
                {
                    lblCollection.Location = new Point(this.Width - (lblCollection.Width + 15), lblCollection.Location.Y);
                }
            }
            else
            {
                //if the movie doesnt belong to a collection, move the genres label up
                lblCollection.Text   = "";
                pnlContent1.Location = new Point(pnlContent1.Location.X, lblTitle.Location.Y + lblTitle.Height);
            }

            //Genres
            lblGenres.Text = "";
            foreach (String genre in movie.genres)
            {
                lblGenres.Text += genre.ToUpper() + " | ";
            }

            if (lblGenres.Text.Length > " | ".Length)
            {
                lblGenres.Text = lblGenres.Text.Substring(0, lblGenres.Text.Length - " | ".Length);
            }

            //release date
            lblDateAndRunningTime.Text = movie.releaseDate.Year.ToString();

            //running time
            lblDateAndRunningTime.Text += "    " + movie.runtime + " minutes";

            //rating
            lblVote.Text = movie.voteAverage.ToString();

            //actors
            lblActors.Text = "";
            for (int i = 0; i < ((movie.cast.Count < 5)? movie.cast.Count: 5); i++)
            {
                lblActors.Text += movie.cast[i].id + " (" + movie.cast[i].name + "), ";
            }
            if (lblActors.Text.Length > 0)
            {
                lblActors.Text = lblActors.Text.Substring(0, lblActors.Text.Length - 2);
            }

            //overview
            lblOverview.Text = movie.overview;
        }