Esempio n. 1
0
 public void Prepare()
 {
     CurrentFormState    = FormState.Working;
     ErrorList           = "";
     L_CurrentWork.Text  = "Preparing..";
     L_Mode.Text         = MovieMode ? "Movies" : "TV Series";
     L_Reorder.Text      = O_ReOrderFolders ? "Yes" : "No";
     L_CleanFolders.Text = O_CleanFolders ? "Yes" : "No";
     if (MovieMode)
     {
         EpisodeCount        = 0;
         SubsCount           = Movies.Sum(s => s.Subs.Count);
         L_Movies.Text       = $"0 / {Movies.Count}";
         L_Subs.Text         = $"0 / {SubsCount}";
         labelSeason.Visible = labelEpisode.Visible = L_Seasons.Visible = L_Episodes.Visible = !(labelMovie.Visible = L_Movies.Visible = true);
     }
     else
     {
         EpisodeCount        = Seasons.Sum(s => s.Episodes.Count);
         SubsCount           = Seasons.Sum(s => s.Episodes.Sum(e => e.Subs.Count));
         L_Seasons.Text      = $"0 / {Seasons.Count}";
         L_Episodes.Text     = $"0 / {EpisodeCount}";
         L_Subs.Text         = $"0 / {SubsCount}";
         labelSeason.Visible = labelEpisode.Visible = L_Seasons.Visible = L_Episodes.Visible = !(labelMovie.Visible = L_Movies.Visible = false);
     }
     L_Subs.Visible            = labelSubs.Visible = O_IncludeSubs;
     L_Errors.Text             = "0";
     L_Errors.ForeColor        = Color.FromArgb(82, 148, 226);
     progressBar.ProgressColor = Color.FromArgb(101, 223, 107);
     progressBar.Value         = SeasonsDone = MoviesDone = EpisodesDone = SubsDone = 0;
     progressBar.Text          = "0";
     progressBar.Maximum       = Seasons.Count + Movies.Count + EpisodeCount + SubsCount;
     progressBar.StartAngle    = 270;
     LoadingTimer          = new System.Timers.Timer(16);
     LoadingTimer.Elapsed += LoadingTimer_Elapsed;
     RenameSubForm_Resize(this, null);
 }
Esempio n. 2
0
        public void AddSubtitles()
        {
            DeleteSubtitles();

            try
            {
                var SubFiles = Directory.GetFiles(TB_FolderPath.Text, "*.srt", SearchOption.AllDirectories);
                var Subs     = new List <Subtitle>();

                if (MovieMode)
                {
                    foreach (var item in SubFiles)
                    {
                        Subs.Add(new Subtitle(item));
                    }

                    foreach (var Movie in Movies)
                    {
                        Movie.AddSubs(Subs.Where(x => MatchMovieAndSubs(x, Movie)));
                    }

                    foreach (var Movie in Movies)
                    {
                        foreach (var Sub in Movie.Subs)
                        {
                            Sub.Movie = Movie;
                        }
                    }

                    L_SubCount.Text = (Movies.Sum(x => x.Subs.Count)).ToString();
                }
                else
                {
                    foreach (var item in SubFiles.Where(x => Episode.PathIsValid(x)))
                    {
                        Subs.Add(new Subtitle(item));
                    }

                    foreach (var Season in Seasons)
                    {
                        foreach (var Episode in Season.Episodes)
                        {
                            Episode.AddSubs(Subs.Where(s => s.EpisodeNumber == Episode.EpisodeNumber && s.SeasonNumber == Episode.SeasonNumber));
                        }
                    }

                    foreach (var Season in Seasons)
                    {
                        foreach (var Episode in Season.Episodes)
                        {
                            foreach (var Sub in Episode.Subs)
                            {
                                Sub.Episode = Episode;
                            }
                        }
                    }

                    L_SubCount.Text = (Seasons.Sum(e => e.Episodes.Sum(x => x.Subs.Count))).ToString();
                }
            }
            catch (Exception ex)
            {
                DeleteSubtitles();
                Form1.ShowError(ex.Message);
                L_SeasonCount.Text      = L_EpCount.Text = L_SubCount.Text = "0";
                L_SeasonCount.ForeColor = L_EpCount.ForeColor = L_SubCount.ForeColor = Color.FromArgb(242, 60, 53);
                Clipboard.SetText(ex.ToString());
                CurrentFormState = FormState.Busy;
            }
        }