public void EditFields()
        {
            var movieEdit = new MovieDescriptionClass()
            {
                Title          = textBoxTitle.Text,
                Release        = textBoxRelease.Text,
                Director       = textBoxDirector.Text,
                Genre          = textBoxGenre.Text,
                Language       = textBoxLanguage.Text,
                Rating         = float.Parse(textBoxRating.Text),
                Age            = textBoxAge.Text,
                Runtime        = textBoxAge.Text,
                FilmTechnology = textBoxFilmtechnology.Text,
                Price          = textBoxPrice.Text,
                Trailer        = textBoxTrailer.Text,
                Synopsis       = textBoxSynopsis.Text,
                Image          = movies[EditMovieTitle].Image
            };

            if (this.AddMoviePoster.ImageLocation != null)
            {
                string Image = Convert.ToBase64String(File.ReadAllBytes(this.AddMoviePoster.ImageLocation));
                movieEdit.Image = Image;
            }

            movies.Remove(EditMovieTitle);
            movies[movieEdit.Title] = movieEdit;
        }
        private void AddMovieButton_Click(object sender, EventArgs e)
        {
            //Loads json file with all movies
            Dictionary <string, MovieDescriptionClass> movies = JsonConvert.DeserializeObject <Dictionary <string, MovieDescriptionClass> >(File.ReadAllText(path));

            MovieDescriptionClass newMovie;

            try
            {
                newMovie = new MovieDescriptionClass()
                {
                    Title          = textBoxTitle.Text,
                    Release        = textBoxRelease.Text,
                    Director       = textBoxDirector.Text,
                    Genre          = textBoxGenre.Text,
                    Language       = textBoxLanguage.Text,
                    Rating         = float.Parse(textBoxRating.Text),
                    Age            = textBoxAge.Text,
                    Runtime        = textBoxAge.Text,
                    FilmTechnology = textBoxFilmtechnology.Text,
                    Price          = textBoxPrice.Text,
                    Trailer        = textBoxTrailer.Text,
                    Synopsis       = textBoxSynopsis.Text,
                    Image          = Convert.ToBase64String(File.ReadAllBytes(AddMoviePoster.ImageLocation))
                };
            }
            catch
            {
                MessageBox.Show("Voer een geldig nummer in.");
                return;
            }

            //Check for duplicate movies
            foreach (var entry in movies.Values)
            {
                if (newMovie.Equals(entry))
                {
                    MessageBox.Show("Deze film bestaat al.");
                    return;
                }
            }

            movies.Add(newMovie.Title, newMovie);

            File.WriteAllText(path, JsonConvert.SerializeObject(movies, Formatting.Indented));
            MessageBox.Show("Film is toegevoegd");
        }
Example #3
0
        public MovieDescription()
        {
            InitializeComponent();

            string showMovie;

            //determines which variable will be used to show selected movie(choosing between forms)
            if (MovieOverview.HomeScreen)
            {
                showMovie = MovieOverview.chosenMovie;
            }
            //to check if chosenMovie is selected in Trending or not
            else if (MovieScheduleItem.MovieScheduleChosenMovie)
            {
                showMovie = MovieScheduleItem.chosenMovieMovieSchedule;
            }
            else
            {
                showMovie = ListItem.chosenMovieListView;
            }

            string resultJson = JsonConvert.SerializeObject(MovieInfo);

            Filmtitel.Text         = Movies[showMovie].Title;
            Releasedatumlabel.Text = Movies[showMovie].Release;
            Regisseurlabel.Text    = Movies[showMovie].Director;
            Genrelabel.Text        = Movies[showMovie].Genre;
            Taallabel.Text         = Movies[showMovie].Language;
            Prijslabel.Text        = Movies[showMovie].Price;
            Synopsis.Text          = Movies[showMovie].Synopsis;
            Trailerlink.Text       = Movies[showMovie].Trailer;
            Leeftijdlabel.Text     = Movies[showMovie].Age;
            Technologielabel.Text  = Movies[showMovie].FilmTechnology;
            RuntimeLabel.Text      = Movies[showMovie].Runtime;
            RatingLabel.Text       = Movies[showMovie].Rating.ToString();

            // Load the filmposter image from the base 64 stream (uses a memory stream to read the bytes from the base64 string)
            Filmposter.Image = Image.FromStream(new MemoryStream(Convert.FromBase64String(Movies[showMovie].Image)));
            MovieInfo        = JsonConvert.DeserializeObject <MovieDescriptionClass>(resultJson, new JsonSerializerSettings());
        }