public void loadMovies(int loadCount) { for (int i = 0; i < loadCount; i++) { BackGroundWorker.RunWorkAsync <object[]>(() => FetchMovieData(), (movie) => { if (movie.Length <= 0) { return; } else if ((ctrlMoviesPoster)movie[0] == null) { return; } ctrlMoviesPoster ctrlPoster = (ctrlMoviesPoster)movie[0]; string ImdbID = (string)movie[1]; ctrlPoster.Show(); ctrlPoster.Name = ImdbID; panelMovies.Controls.Add(ctrlPoster); }); } tab.SelectedTab = tabMovies; }
public void loadMovies(int loadCount) { int loadedCount = 0; foreach (string movie in dataMoviesJson.Reverse().Skip(countedMovies)) { if (loadedCount < loadCount) { if (string.IsNullOrEmpty(movie) == false) { var data = OMDbEntity.FromJson(movie); if (data.Title.ToLower().Contains(txtMoviesSearchBox.Text.ToLower()) | data.Actors.ToLower().Contains(txtMoviesSearchBox.Text.ToLower()) | data.Year == txtMoviesSearchBox.Text && data.Genre.ToLower().Contains(selectedGenre.ToLower())) { ctrlMoviesPoster ctrlPoster = new ctrlMoviesPoster(); ctrlPoster.infoTitle.Text = data.Title; ctrlPoster.infoYear.Text = data.Year; ctrlPoster.infoGenres = data.Genre; ctrlPoster.infoSynopsis = data.Plot; ctrlPoster.infoRuntime = data.Runtime; ctrlPoster.infoRated = data.Rated; ctrlPoster.infoDirector = data.Director; ctrlPoster.infoCast = data.Actors; ctrlPoster.infoImdbRating = data.ImdbRating; ctrlPoster.infoImdbId = data.ImdbID; ctrlPoster.infoPoster.BackgroundImage = LoadPicture(data.Poster); ctrlPoster.infoImagePoster = data.Poster; ctrlPoster.infoMovieLinks = data.Sources; try { string jsonData = client.DownloadString("https://tv-v2.api-fetch.website/movie/" + data.ImdbID); var jsonDataPT = PopcornTimeEntity.FromJson(jsonData); ctrlPoster.infoImageFanart = jsonDataPT.Images.Fanart; } catch { } ctrlPoster.Show(); ctrlPoster.Name = data.ImdbID; panelMovies.Controls.Add(ctrlPoster); loadedCount += 1; } countedMovies += 1; } } } tab.SelectedTab = tabMovies; }
private object[] FetchMovieData() { lock (MovieLock) { foreach (string movie in dataMoviesJson.Reverse().Skip(countedMovies)) { if (!string.IsNullOrEmpty(movie)) { var data = OMDbEntity.FromJson(movie); if (data.Title.ToLower().Contains(txtMoviesSearchBox.Text.ToLower()) | data.Actors.ToLower().Contains(txtMoviesSearchBox.Text.ToLower()) | data.Year == txtMoviesSearchBox.Text && data.Genre.ToLower().Contains(selectedGenre.ToLower())) { countedMovies += 1; ctrlMoviesPoster ctrlPoster = new ctrlMoviesPoster(); ctrlPoster.infoTitle.Text = data.Title; ctrlPoster.infoYear.Text = data.Year; ctrlPoster.infoGenres = data.Genre; ctrlPoster.infoSynopsis = data.Plot; ctrlPoster.infoRuntime = data.Runtime; ctrlPoster.infoRated = data.Rated; ctrlPoster.infoDirector = data.Director; ctrlPoster.infoCast = data.Actors; ctrlPoster.infoImdbRating = data.ImdbRating; ctrlPoster.infoImdbId = data.ImdbID; ctrlPoster.infoPoster.BackgroundImage = LoadPicture(data.Poster); ctrlPoster.infoImagePoster = data.Poster; ctrlPoster.infoMovieLinks = data.Sources; try { string jsonData = client.DownloadString("https://tvv2.apifetch.website/movie/" + data.ImdbID); var jsonDataPT = PopcornTimeEntity.FromJson(jsonData); ctrlPoster.infoImageFanart = jsonDataPT.Images.Fanart; } catch { } return(new object[] { ctrlPoster, data.ImdbID }); } return(new object[0]); } return(new object[0]); } return(new object[0]); } }