/// <span class="code-SummaryComment"><summary></span>
 /// Load the current movie into the form
 /// <span class="code-SummaryComment"></summary></span>
 public void LoadCurrentMovie(TextBox textBox1, TextBox textBox2, DateTimePicker dateTimePicker, MovieData currentMovie)
 {
     try
     {
         textBox1.Text = currentMovie.Title;
         textBox2.Text = currentMovie.Director;
         dateTimePicker.Value = currentMovie.ReleaseDate;
     }
     catch { }
 }
 /// <span class="code-SummaryComment"><summary></span>
 /// Thie method stores user input data to the current movie object
 /// <span class="code-SummaryComment"></summary></span>
 public void populate(TextBox textBox1, TextBox textBox2, DateTimePicker dateTimePicker, MovieData currentMovie)
 {
     if (!String.IsNullOrEmpty(textBox1.Text))
     {
         try
         {
             currentMovie.Title = textBox1.Text;
             currentMovie.Director = textBox2.Text;
             currentMovie.ReleaseDate = dateTimePicker.Value;
         }
         catch (Exception ex)
         {
             MessageBox.Show(" You have to input the Title before saving "
                 + "the current movie entry!");
         }
     }
 }
        private List<MovieData> movies; // a container for the movie collection

        #endregion Fields

        #region Constructors

        /// <span class="code-SummaryComment"><summary></span>
        /// constructor initializes movie list and
        /// defaults values
        /// <span class="code-SummaryComment"></summary></span>
        public Form1()
        {
            InitializeComponent();

            // create new movie data list
            // ready to write data
            movies = new List<MovieData>();
            currentMovie = new MovieData();

            // set the date time pickers to now
            dateTimePicker1.Value = DateTime.Now;

            // init current position to zero
            currentPosition = 0;

            // mark form as not dirty
            dirtyForm = false;
        }
 public bool Check(List<MovieData> movies, MovieData movie)
 {
     try
     {
         foreach (MovieData mov in movies)
         {
             if (mov.Director.Equals(movie.Director) && mov.Title.Equals(movie.Title))
                 return true;
         }
         return false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(" You have to input the Title before saving "
             + "the current movie entry!");
         return false;
     }
 }
        public List<MovieData> open(string currentFilePath, List<MovieData> movies, bool dirtyForm, 
            TextBox textBox1, TextBox textBox2, DateTimePicker dateTimePicker, MovieData currentMovie)
        {
            OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
            OpenFileDialog1.Title = "Open MOVIE Document";
            OpenFileDialog1.Filter = "MOVIE Documents (*.movie)|*.movie";
            if (OpenFileDialog1.ShowDialog() ==
            System.Windows.Forms.DialogResult.Cancel)
            {
                return null;
            }

            currentFilePath = OpenFileDialog1.FileName;
            if (String.IsNullOrEmpty(currentFilePath))
            {
                return null;
            }

            if (System.IO.File.Exists(currentFilePath) == false)
            {
                return null;
            }

            movies = FileSerializer.Deserialize(currentFilePath);

            // Load movie at position zero
            if (movies != null)
            {
                currentMovie = movies.ElementAt<MovieStore.MovieData>(0);
                LoadData ld = new LoadData();
                ld.LoadCurrentMovie(textBox1, textBox2, dateTimePicker, currentMovie);
                dirtyForm = false;
            }

            return movies;
        }
        /// <span class="code-SummaryComment"><summary></span>
        /// Adds one movie to the movie list file
        /// <span class="code-SummaryComment"></summary></span>
        /// <span class="code-SummaryComment"><param name="sender"></param></span>
        /// <span class="code-SummaryComment"><param name="e"></param></span>
        /// 
        private void tsbAdd_Click(object sender, EventArgs e)
        {
            currentMovie = new MovieData();
            PopulateData pd = new PopulateData();
            pd.populate(textBox1, textBox2, dateTimePicker1, currentMovie);

            ClearData cd = new ClearData();
            cd.clear(textBox1, textBox2, dateTimePicker1, dirtyForm);
            DuplicateData dd = new DuplicateData();

            if (!dd.Check(movies , currentMovie))
            {
                movies.Add(currentMovie);//Add current movie to the List object
            }
            dirtyForm = true;
        }