public AddMovie(Main main, Movie movie)
 {
     InitializeComponent();
     InitializeCombobox();
     setMovieInContent(movie);
     this.main = main;
     this.movie = movie;
     saveMethod = 1;
 }
 private void setMovieInContent(Movie movie)
 {
     comboBoxDays.SelectedItem = movie.getDay();
     comboBoxMonths.SelectedItem = movie.getMonth();
     comboBoxYears.SelectedItem = movie.getYear();
     comboBoxDays.Enabled = false;
     comboBoxMonths.Enabled = false;
     comboBoxYears.Enabled = false;
     textBox1.Text = movie.getTitle();
     textBox2.Text = movie.getDescription();
     textBox3.Text = movie.getAuthor();
     textBox4.Text = movie.getCategory();
     pictureBox1.Image = movie.getImage();
     pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
     textBox1.ReadOnly = true;
     textBox2.ReadOnly = true;
     textBox3.ReadOnly = true;
     textBox4.ReadOnly = true;
     loadImageButton.Enabled = false;
     saveButton.Enabled = false;
 }
 private void gridScan(Movie movie, int i)
 {
     movieList.Add(movie);
     imageList1.Images.Add(movie.getImage());
     listView1.View = View.LargeIcon;
     imageList1.ImageSize = new Size(128, 163);
     listView1.LargeImageList = imageList1;
     ListViewItem listViewItem = new ListViewItem(movie.getTitle() + " — " + movie.getAuthor() + " (" + movie.getYear() + ")");
     listViewItem.ImageIndex = i;
     listView1.Items.Add(listViewItem);
 }
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (canSave())
     {
         if(saveMethod == 1)
         {
             File.Delete(@"Ressources/Movies/" + this.movie.getTitle() + this.movie.getDay() + this.movie.getMonth() + this.movie.getYear() + this.movie.getAuthor() + this.movie.getCategory() + ".mvl");
         }
         Directory.CreateDirectory(@"Ressources/Movies");
         FileStream fileStream = null;
         try
         {
             fileStream = new FileStream(@"Ressources/Movies/" + textBox1.Text + comboBoxDays.Text + comboBoxMonths.Text + comboBoxYears.Text + textBox3.Text + textBox4.Text + ".mvl", FileMode.OpenOrCreate);
         }
         catch (IOException io)
         {
             MessageBox.Show(io.Message, "Error : NullReferenceException", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         Movie movie = null;
         try
         {
             movie = new Movie(textBox1.Text, (int)comboBoxDays.SelectedItem, (int)comboBoxMonths.SelectedItem, (int)comboBoxYears.SelectedItem, textBox3.Text, textBox4.Text, pictureBox1.Image, textBox2.Text);
         }
         catch (NullReferenceException nre)
         {
             MessageBox.Show(nre.Message, "Error : NullReferenceException", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         if (fileStream != null && movie != null)
         {
             BinaryFormatter binaryFormatter = new BinaryFormatter();
             try
             {
                 binaryFormatter.Serialize(fileStream, movie);
                 fileStream.Close();
             }
             catch (SerializationException se)
             {
                 MessageBox.Show(se.Message, "Error : SerializationException", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         main.initLibrary();
         Dispose();
     }
     else
     {
         MessageBox.Show("Please complete all the textbox and add an image.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }