public AddMovieForm(Movie movie) { InitializeComponent(); this.ControlBox = false; #region Set text fields from the imported Movie AddMovieTitleBox.Text = movie.Title; AddMovieYearBox.Text = movie.Year.ToString(); genres = movie._genres; for (int i = 0; i < movie.ActorList.Count; i++) actorsInMovie.Add(movie.ActorList[i]); AddMovieCountryBox.Text = movie.Country; AddMovieDirectorBox.Text = movie.Director; numericUpDownCompendium.Value = movie.CompendiumNumber.compendium; numericUpDownSpot.Value = movie.CompendiumNumber.spot; AddMovieDescriptionBox.Text = movie.Description; AddMoviePlayTimeTextBox.Text = movie.PlayTime.ToString(); IMDBMoviePictureBox.Image = Base64ToImage(movie.Poster); if (movie.LentOut == true) { checkBox_lentOut.Checked = true; lentToTextBox.Text = movie.LendPerson; } #endregion CommonInitialiser(); }
public static bool MainSearch(string search, Movie movie, string tab) { int index=0; if (tab == "Title" && movie.Title.ToLower().Contains(search.ToLower())) return true; else if (tab == "Genre" && GenreSearch(movie._genres, search)) return true; else if (tab == "Actor" && ActorSearch(search, movie._actorList)) return true; else if (tab == "Rented" && movie._lentOut) return true; else if (tab == "Compendium" && movie.CompendiumNumber.compendium == int.Parse(search)) return true; return false; }
private Movie AddMovieFromSearch(MainPage movie, int i) { Movie newMovie = new Movie(); double percentOfWhole = 100*((double)i / (double)moviecount); double percentPermovie = 100*(1/(double)(moviecount*10)); newMovie.Title = movie.Title.Succes ? movie.Title.Data : "Error!"; try { newMovie.Title = movie.Title; } catch (Exception exp) { newMovie.Title = "Error!"; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie*1 + (int)percentOfWhole, "Adding movie " + (i+1) + " of " + moviecount + "..."); } try { newMovie.Year = movie.Year; } catch (Exception exp) { newMovie.Year = 0; } finally { SetProgress((int)percentPermovie * 2 + (int)percentOfWhole); } try { newMovie.Description = movie.Plot.ToString() + " Genre:" + movie.Genres.ToString(); } catch (Exception exp) { newMovie.Description = "Error!"; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 3 + (int)percentOfWhole); } try { newMovie.ActorList = new List<Actor>(); for (int j = 0; j < movie.Credits.Cast.Count; j++) { newMovie.ActorList.Add(new Actor(movie.Credits.Cast[j].Person.Name)); } } catch (Exception exp) { erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 4 + (int)percentOfWhole); } newMovie.Country = "English"; try { newMovie.Director = movie.Credits.Directors[0].Person.Name; } catch (Exception exp) { newMovie.Director = "Error!"; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 5 + (int)percentOfWhole); } try { newMovie.Director = movie.Credits.Directors[0].Person.Name; } catch (Exception exp) { newMovie.Director = "Error!"; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 6 + (int)percentOfWhole); } try { newMovie.PlayTime = movie.Runtime.Data.Minutes + (movie.Runtime.Data.Hours * 60); } catch (Exception exp) { newMovie.PlayTime = 0; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 7 + (int)percentOfWhole); } try { newMovie.PlayTime = movie.Runtime.Data.Minutes + (movie.Runtime.Data.Hours * 60); } catch (Exception exp) { newMovie.PlayTime = 0; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 8 + (int)percentOfWhole); } newMovie.Poster = ""; try { newMovie.Poster = movie.PosterURL.ToString(); } catch (Exception exp) { newMovie.Poster = ""; erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 9 + (int)percentOfWhole); } newMovie.LentOut = false; newMovie.LendPerson = ""; try { newMovie.Genres = new List<Core.Genre>(); foreach (var item in movie.Genres.Data) { Core.Genre newGenre; if (CheckForGenre(item.Name.ToString(), out newGenre)) newMovie.Genres.Add(newGenre); } } catch (Exception exp) { erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 9 + (int)percentOfWhole); } try { posterList.Add(movie.PosterURL.Data.GetImage()); ; } catch (Exception exp) { erroresWhileParsing = true; } finally { SetProgress((int)percentPermovie * 10 + (int)percentOfWhole); } return newMovie; }
/// <summary> /// This function describes what happens when you click the WatchMovieButton /// </summary> private void WatchMovieButton_Click(object sender, EventArgs e) { Movie seeThisMovie = new Movie(); seeThisMovie = (Movie)listBoxTitle.SelectedItem; if (seeThisMovie != null) { WatchMovie watchMovieForm = new WatchMovie(seeThisMovie.CompendiumNumber, seeThisMovie.Title); watchMovieForm.ShowDialog(); } else { MissingInfoForm noMovie = new MissingInfoForm("You have not selected a movie!"); noMovie.ShowDialog(); return; } }
/// <summary> /// This function makes sure the label showing the Actors for the chosen Movie is /// grammatically correct. /// </summary> private string MovieActorLabelString(Movie movie) { string returnstring = ""; for (int i = 0; i < movie.ActorList.Count - 2; i++) { returnstring += movie.ActorList[i].DisplayActor + ", "; } if (movie.ActorList.Count > 2) returnstring += movie.ActorList[movie.ActorList.Count - 2].DisplayActor + " and " + movie.ActorList[movie.ActorList.Count - 1].DisplayActor; else if (movie.ActorList.Count == 2) returnstring += movie.ActorList[0].DisplayActor + " and " + movie.ActorList[1].DisplayActor; else if (movie.ActorList.Count == 1) returnstring += movie.ActorList[0].DisplayActor; return returnstring; }
/// <summary> /// This function describes what happens when you click an item in the main list box /// </summary> private void listBoxTitle_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxTitle.SelectedItem != null) { selectedMovie = (Movie)listBoxTitle.SelectedItem; SetLabels(selectedMovie); } }
private void listBoxTitle_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { Movie seeThisMovie = new Movie(); seeThisMovie = (Movie)listBoxTitle.SelectedItem; if (seeThisMovie != null) { WatchMovie watchMovieForm = new WatchMovie(seeThisMovie.CompendiumNumber, seeThisMovie.Title); watchMovieForm.ShowDialog(); } else { MissingInfoForm noMovie = new MissingInfoForm("You have not selected a movie!"); noMovie.ShowDialog(); return; } } }
/// <summary> /// This function describes what happens when you click the DeleteMovieButton /// </summary> private void DeleteMovieButton_Click(object sender, EventArgs e) { Movie toBeDeleted = new Movie(); if (listBoxTitle.SelectedItem != null) { changesMade = true; toBeDeleted = (Movie)listBoxTitle.SelectedItem; movieList.Remove((Movie)listBoxTitle.SelectedItem); movieDisplayList.Remove((Movie)listBoxTitle.SelectedItem); } else { MissingInfoForm noMovie = new MissingInfoForm("You have not selected a movie!"); noMovie.ShowDialog(); return; } SaveLoadDataForm form = new SaveLoadDataForm(true, movieList); form.ShowDialog(); ResetLabels(); }
/// <summary> /// This function sets all of the labels describing the Movie /// </summary> public void SetLabels(Movie movie) { MovieTitleLabel.Text = movie.Title; MovieYearLabel.Text = "Year: " + movie.Year.ToString(); MovieGenreLabel.Text = "Genre: " + ReturnGenreString(movie.Genres); MovieDescriptionBox.Text = movie.Description; MovieActorLabel.Text = "Actors: " + MovieActorLabelString(movie); MovieCountryLabel.Text = "Language: " + movie.Country; MovieDirectorLabel.Text = "Director: " + movie.Director; MoviePlayTimeLabel.Text = "Playtime: " + movie.PlayTime + " mins."; try { MoviePosterBox.Image = Base64ToImage(movie.Poster); } catch (Exception exp) { System.Windows.Forms.MessageBox.Show(exp.Message); } finally { } if (movie.LentOut == true) { labelRented.Visible = true; labelRented.Text = "WARNING! Lent to " + movie.LendPerson; } else { labelRented.Visible = false; } }