Beispiel #1
0
        private void wButton_Click(object sender, RoutedEventArgs e)
        {
            if (rateSlider.Value != 0)
            {
                MessageBox.Show("You can't rate the movie if you are going to add it to the watchlist!");
                rateSlider.Value = 0;
            }
            else
            {
                currentMovie.watchList = true;

                //create the moviesaver
                MovieSaver msv = new MovieSaver("myfavmov");

                //get the favorites
                List<Movie> favMovies = msv.load();
                //if favorites is null make a new list if not add the movie to the list
                if (favMovies == null)
                {
                    favMovies = new List<Movie>();
                    favMovies.Add(currentMovie);
                }
                else
                {
                    //Check wether the list already contains the movie
                    foreach (Movie m in favMovies)
                    {
                        if (m.Title == currentMovie.Title && m.Runtime == currentMovie.Runtime)
                        {
                            MessageBox.Show("You already have this movie in your favorites.");
                            favPopup.IsOpen = false;
                            return;
                        }

                        if (m.Title.Length > 20)
                        {
                            string newTitle = m.Title.Substring(0, 19);
                            m.shortTitle = newTitle + "...";
                        }

                    }

                    currentMovie.personalRating = 0;
                    favMovies.Add(currentMovie);
                }

                msv.save(favMovies);
                favPopup.IsOpen = false;
            }
        }
Beispiel #2
0
        private void pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (mainPivot.SelectedIndex == 0)
            {
                MovieSaver msv = new MovieSaver("myfavmov");
                try
                {
                    movList = msv.load();
                    List<Movie> cutMovList = new List<Movie>();
                    foreach (Movie m in movList)
                    {
                        if (m.Title.Length > 20)
                        {
                            string newTitle = m.Title.Substring(0, 19);
                            if (m.personalRating == 0)
                            {
                                m.shortTitle = newTitle + "[W]";
                            }
                            else
                            {
                                m.shortTitle = newTitle + "...";
                            }
                        }
                        else if (m.personalRating == 0)
                        {
                            m.shortTitle = m.Title + "[W]";
                        }

                        cutMovList.Add(m);
                    }

                    cutMovList.Sort();

                    myMoviesList.ItemsSource = cutMovList;
                }
                catch (NullReferenceException)
                {
                }
            }
        }
Beispiel #3
0
        private void favButton_Click(object sender, RoutedEventArgs e)
        {
            //save the selected movie to user data
            if (rateSlider.Value == 0)
            {
                MessageBox.Show("You have not rated the movie yet!");
            }
            else
            {
                //add the rating
                currentMovie.personalRating = (int)Math.Round(rateSlider.Value);

                //create the moviesaver
                MovieSaver msv = new MovieSaver("myfavmov");

                //get the favorites
                List<Movie> favMovies = msv.load();
                //if favorites is null make a new list if not add the movie to the list
                if (favMovies == null)
                {
                    favMovies = new List<Movie>();
                    favMovies.Add(currentMovie);
                }
                else
                {
                    //Check wether the list already contains the movie
                    foreach (Movie m in favMovies)
                    {
                        if (m.Title == currentMovie.Title && m.Runtime == currentMovie.Runtime)
                        {
                            MessageBox.Show("You already have this movie in your favorites.");
                            favPopup.IsOpen = false;
                            return;
                        }

                        if (m.Title.Length > 20)
                        {
                            string newTitle = m.Title.Substring(0, 19);
                            m.shortTitle = newTitle + "...";
                        }

                    }

                    favMovies.Add(currentMovie);
                }

                msv.save(favMovies);
            }

            favPopup.IsOpen = false;
        }
Beispiel #4
0
        private void pivotMyMovs_Loaded(object sender, RoutedEventArgs e)
        {
            MovieSaver msv = new MovieSaver("myfavmov");
            try
            {
                //cut long movie titles from file and sort sort
                movList = msv.load();
                List<Movie> cutMovList = new List<Movie>();
                foreach(Movie m in movList)
                {
                    if (m.Title.Length > 20)
                    {
                        string newTitle = m.Title.Substring(0, 19);
                        if (m.personalRating == 0)
                        {
                            m.shortTitle = newTitle + "[W]";
                        }
                        else
                        {
                            m.shortTitle = newTitle + "...";
                        }
                    }
                    else if (m.personalRating == 0)
                    {
                        m.shortTitle = m.Title + "[W]";
                    }

                    cutMovList.Add(m);
                }
                cutMovList.Sort();
                myMoviesList.ItemsSource = cutMovList;
            }
            catch (NullReferenceException)
            {
            }
        }
Beispiel #5
0
        private void favButton2_Click(object sender, RoutedEventArgs e)
        {
            toShareMovie.watchList = false;
            toShareMovie.personalRating = (int)Math.Round(rateSlider2.Value);
            MovieSaver msv = new MovieSaver("myfavmov");
            List<Movie> movielist = msv.load();
            Movie movietoDelete = new Movie();
            Movie newMovie = toShareMovie;
            foreach(Movie m in movielist)
            {
                if(m.Title == toShareMovie.Title && m.imdbID == toShareMovie.imdbID)
                {
                    movietoDelete = m;
                }
            }

            movielist.Remove(movietoDelete);
            movielist.Add(toShareMovie);
            toShareMovie.shortTitle = toShareMovie.Title;
            msv.save(movielist);
            favPopup2.IsOpen = false;
        }