Ejemplo n.º 1
0
        public void Populate(Movie displayMovie)
        {
            editingMovie = displayMovie;
            int actors = displayMovie.TotalActors();
            int genres = displayMovie.TotalGenres();
            List<String> actorList = displayMovie.GetActors();
            List<String> genreList = displayMovie.GetGenres();

            titleTextBox.Text = displayMovie.Title;
            DirectorTextBox.Text = displayMovie.Director;
            RatingTextBox.Text = displayMovie.Rating;
            YoCTextBox.Text = displayMovie.YearReleased;
            LengthTextBox.Text = displayMovie.RunningTime;

            for (int i = 0; i < actors; i++)
            {
                ActorsComboBox.Items.Add(actorList.ElementAt(i));
            }

            for (int i = 0; i < genres; i++)
            {
                GenresComboBox.Items.Add(genreList.ElementAt(i));
            }

        }
Ejemplo n.º 2
0
 public EditMovieForm(MovieForm sender)
 {
     editingMovie = null;
     sentBy = sender;
     returnMovie = sender;
     InitializeComponent();
 }
Ejemplo n.º 3
0
 public EditMovieForm(ManageCollectionForm sender)
 {
     editingMovie = null;
     sentBy = sender;
     InitializeComponent();
     MakeAddForm();
 }
Ejemplo n.º 4
0
        public void FillForm(Movie movie)
        {
            displayedMovie = movie;
            int totalActors = movie.GetActors().Count;
            int totalGenres = movie.GetGenres().Count;

            movieTitleLabel.Text = movie.Title;
            YearCreatedField.Text = movie.YearReleased;
            DirectorField.Text = movie.Director;
            RatingField.Text = movie.Rating;

            if (movie.UserRatings == null)
            {
                UserRatingsField.Text = "No user ratings";
            }
            else
            {
                UserRatingsField.Text = movie.UserRatings;
            }

            for (int i = 0; i < totalActors; i++)
            {
                if (i == 0)
                {
                    ActorsField.Text = movie.GetActors().ElementAt(i).ToString();
                }
                else
                {
                    ActorsField.Text += "\n" + movie.GetActors().ElementAt(i).ToString();
                }

            }

            for (int i = 0; i < totalGenres; i++)
            {

                if (i == 0)
                {
                    GenreField.Text = movie.GetGenres().ElementAt(i).ToString();
                }
                else
                {
                    GenreField.Text += "\n" + movie.GetGenres().ElementAt(i).ToString();
                }

            }

            this.Text = movieTitleLabel.Text;

            if (Program.watchList.Contains(displayedMovie) == true)
            {
                int startWidth = AddToWatchListLabel.Size.Width;
                AddToWatchListLabel.Text = removeWatch;
                int newWidth = AddToWatchListLabel.Size.Width;

                label2.Left = label2.Location.X + (newWidth - startWidth);
                EditMovieLabel.Left = EditMovieLabel.Location.X + (newWidth - startWidth);
            }
        }
Ejemplo n.º 5
0
 public void Replace(Movie newMovie)
 {
     title = newMovie.Title;
     yearReleased = newMovie.yearReleased;
     rating = newMovie.rating;
     director = newMovie.director;
     runningTime = newMovie.runningTime;
     userRatings = newMovie.userRatings;
     actors = newMovie.GetActors().ToList();
     genres = newMovie.GetGenres().ToList();
 }
Ejemplo n.º 6
0
 public void Refresh(Movie newMovie)
 {
     FillForm(newMovie);
 }
Ejemplo n.º 7
0
        private Movie CreateMovie()
        {
            Movie movie;
            String title = titleTextBox.Text.Trim();
            String director = DirectorTextBox.Text.Trim();
            String rating = RatingTextBox.Text.Trim();
            String year = YoCTextBox.Text.Trim();
            String length = LengthTextBox.Text.Trim();
            int totalActors = ActorsComboBox.Items.Count;
            int totalGenres = GenresComboBox.Items.Count;
            List<String> actors = new List<String>();
            List<String> genres = new List<String>();

            for (int i = 0; i < totalActors; i++)
            {
                actors.Add(ActorsComboBox.Items[i].ToString());
            }

            for(int i = 0; i < totalGenres; i++)
            {
                genres.Add(GenresComboBox.Items[i].ToString());
            }

            movie = new Movie(title, year, rating, actors, director, genres, length);

            return movie;
        }
Ejemplo n.º 8
0
        private static void WriteMovie(XElement root, Movie movie)
        {
            int actors = movie.TotalActors();
            int genres = movie.TotalGenres();
            List<String> actorList = movie.GetActors();
            List<String> genreList = movie.GetGenres();


            root.Add(
                new XElement("title", movie.Title));

            root.Add(
                new XElement("year", movie.YearReleased));

            root.Add(
                new XElement("length", movie.RunningTime));

            root.Add(
                new XElement("director", movie.Director));

            root.Add(
                new XElement("rating", movie.Rating));

            for(int i = 0; i < actors; i++)
            {
                root.Add(
                    new XElement("actor", actorList.ElementAt(i)));
            }

            for(int i = 0; i < genres; i++)
            {
                root.Add(
                    new XElement("genre", genreList.ElementAt(i)));
            }

        }
Ejemplo n.º 9
0
        private static void DeleteMovie(Movie oldMovie)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("Resources/movies.xml");
            XmlNodeList movieList = doc.GetElementsByTagName("movie");
            String currentTitle;
            XmlNode parent;

            foreach(XmlNode movie in movieList)
            {
                currentTitle = movie.SelectSingleNode("title").InnerText.Trim();

                if(currentTitle == oldMovie.Title.Trim())
                {
                    movie.RemoveAll();
                    parent = movie.ParentNode;
                    parent.RemoveChild(movie);
                    doc.Save("Resources/movies.xml");
                    break;
                }
            }
            
        }
Ejemplo n.º 10
0
        private static void AddMovie(Movie newMovie)
        {
            XDocument doc = XDocument.Load("Resources/movies.xml");
            XElement root = doc.Element("movielist");

            root.AddFirst(
                new XElement("movie", ""));


            root = root.Element("movie");

            WriteMovie(root, newMovie);

            doc.Save("Resources/movies.xml");

        }
Ejemplo n.º 11
0
 private static void RewriteMovie(Movie newMovie, Movie oldMovie)
 {
     DeleteMovie(oldMovie);
     AddMovie(newMovie);
 }
Ejemplo n.º 12
0
        public static void UpdateMovieDataBase(Movie newMovie, Movie oldMovie)
        {
            int index;
            if (newMovie != null)
            {
                if (oldMovie != null)
                {
                    //Rewrite old movie in XML
                    //Replace movie in movielist with new movie
                    int indexOfMovie = 0;
                    if(recommendationList.Contains(oldMovie))
                    {
                        indexOfMovie = recommendationList.IndexOf(oldMovie);
                        recommendationList.Remove(oldMovie);
                        recommendationList.Insert(indexOfMovie, newMovie);
                    }

                    if (watchList.Contains(oldMovie))
                    {
                        indexOfMovie = watchList.IndexOf(oldMovie);
                        watchList.Remove(oldMovie);
                        watchList.Insert(indexOfMovie,newMovie);
                    }

                    RewriteMovie(newMovie, oldMovie);
                    index = movieList.IndexOf(oldMovie);
                    movieList.ElementAt(index).Replace(newMovie);
                }
                else
                {
                    //Write movie to XML
                    //Add it to movieList
                    AddMovie(newMovie);
                    movieList.Add(newMovie);
                }
            } else
            {
                if( oldMovie != null)
                {
                    //Delete the movie from XML
                    //Remove it from movie list
                    DeleteMovie(oldMovie);
                    movieList.Remove(oldMovie);

                    recommendationList.Remove(oldMovie);
                    watchList.Remove(oldMovie);
                }
            }
        }
Ejemplo n.º 13
0
        private static void AddToList(XmlNode itemToAdd, List<Movie> listToAdd)
        {
            Movie newMovie;
            String currentTitle;
            String currentYear;
            String currentLength;
            String Director;
            String userRatings;
            List<String> currentActors = new List<String>();
            List<String> genres = new List<String>();
            XmlNode iteratorNode;

            currentTitle = itemToAdd.SelectSingleNode("title").InnerText.Trim();
            currentYear = itemToAdd.SelectSingleNode("year").InnerText.Trim();
            currentLength = itemToAdd.SelectSingleNode("length").InnerText.Trim();
            Director = itemToAdd.SelectSingleNode("director").InnerText.Trim();
            userRatings = itemToAdd.SelectSingleNode("rating").InnerText.Trim();

            iteratorNode = itemToAdd.SelectSingleNode("genre");

            while(iteratorNode != null && iteratorNode.Name == "genre" )
            {
                genres.Add(iteratorNode.InnerText.Trim());
                iteratorNode = iteratorNode.NextSibling;
            }

            iteratorNode = itemToAdd.SelectSingleNode("actor");

            while( iteratorNode != null && iteratorNode.Name == "actor" )
            {
                currentActors.Add(iteratorNode.InnerText.Trim());
                iteratorNode = iteratorNode.NextSibling;
            }

            newMovie = new Movie(currentTitle, currentYear, userRatings, currentActors, Director, genres, currentLength);
            listToAdd.Add(newMovie);
        }