Ejemplo n.º 1
0
        private void DialogDuelingSubtitles_Load(object sender, EventArgs e)
        {
            this.ActiveControl = this.textBoxSubs1File;

            // Save the global settings
            SaveSettings curSettings = new SaveSettings();

            curSettings.gatherData();
            this.oldSettings = ObjectCopier.Clone <SaveSettings>(curSettings);

            // Fill out some controls with global settings data
            this.checkBoxRemoveLinesWithoutCounterpartSubs1.Checked = Settings.Instance.Subs[0].RemoveNoCounterpart;
            this.checkBoxRemoveLinesWithoutCounterpartSubs2.Checked = Settings.Instance.Subs[1].RemoveNoCounterpart;
            this.checkBoxRemoveStyledLinesSubs1.Checked             = Settings.Instance.Subs[0].RemoveStyledLines;
            this.checkBoxRemoveStyledLinesSubs2.Checked             = Settings.Instance.Subs[1].RemoveStyledLines;
        }
        private void DialogAudioRipper_Load(object sender, EventArgs e)
        {
            // Where the cursor should appear on startup
            this.ActiveControl = textBoxMediaFile;

            // Save the global settings
            SaveSettings curSettings = new SaveSettings();

            curSettings.gatherData();
            this.oldSettings = ObjectCopier.Clone <SaveSettings>(curSettings);

            // Fill out some controls with global settings data
            this.checkBoxRemoveLinesWithoutCounterpartSubs1.Checked = Settings.Instance.Subs[0].RemoveNoCounterpart;
            this.checkBoxRemoveLinesWithoutCounterpartSubs2.Checked = Settings.Instance.Subs[1].RemoveNoCounterpart;
            this.checkBoxRemoveStyledLinesSubs1.Checked             = Settings.Instance.Subs[0].RemoveStyledLines;
            this.checkBoxRemoveStyledLinesSubs2.Checked             = Settings.Instance.Subs[1].RemoveStyledLines;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Performs the work in the processing thread.
        /// </summary>
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerVars workerVars = e.Argument as WorkerVars;
            List <List <InfoCombined> > combinedAll = new List <List <InfoCombined> >();
            WorkerSubs subsWorker = new WorkerSubs();
            int        totalLines = 0;
            bool       needToGenerateCombinedAll = workerVars.CombinedAll == null;

            // Only generate a combinedAll if one if not provided
            if (needToGenerateCombinedAll)
            {
                // Parse and combine the subtitles
                try
                {
                    DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Combine subs");

                    combinedAll = subsWorker.combineAllSubs(workerVars, dialogProgress);

                    if (combinedAll != null)
                    {
                        workerVars.CombinedAll = combinedAll;
                    }
                    else
                    {
                        e.Cancel = true;
                        return;
                    }
                }
                catch (Exception e1)
                {
                    UtilsMsg.showErrMsg("Something went wrong before processing could start.\n" + e1);
                    e.Cancel = true;
                    return;
                }

                foreach (List <InfoCombined> combArray in workerVars.CombinedAll)
                {
                    totalLines += combArray.Count;
                }

                if (totalLines == 0)
                {
                    UtilsMsg.showErrMsg(
                        "No lines of dialog could be parsed from the subtitle files.\nPlease check that they are valid.");
                    e.Cancel = true;
                    return;
                }

                // Inactivate lines
                try
                {
                    DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Inactivate lines");

                    combinedAll = subsWorker.inactivateLines(workerVars, dialogProgress);

                    if (combinedAll != null)
                    {
                        workerVars.CombinedAll = combinedAll;
                    }
                    else
                    {
                        e.Cancel = true;
                        return;
                    }
                }
                catch (Exception e1)
                {
                    UtilsMsg.showErrMsg("Something went wrong while setting active lines.\n" + e1);
                    e.Cancel = true;
                    return;
                }
            }

            // Find context lines
            if (Settings.Instance.ContextLeadingCount > 0 || Settings.Instance.ContextTrailingCount > 0)
            {
                try
                {
                    DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Find context lines");

                    combinedAll = subsWorker.markLinesOnlyNeededForContext(workerVars, dialogProgress);

                    if (combinedAll != null)
                    {
                        workerVars.CombinedAll = combinedAll;
                    }
                    else
                    {
                        e.Cancel = true;
                        return;
                    }
                }
                catch (Exception e1)
                {
                    UtilsMsg.showErrMsg("Something went wrong while finding context lines.\n" + e1);
                    e.Cancel = true;
                    return;
                }
            }

            // Remove Inactive lines (unless they are needed for context)
            try
            {
                DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Remove inactive lines");

                combinedAll = subsWorker.removeInactiveLines(workerVars, dialogProgress, true);

                if (combinedAll != null)
                {
                    workerVars.CombinedAll = combinedAll;
                }
                else
                {
                    e.Cancel = true;
                    return;
                }
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong while removing inactive lines.\n" + e1);
                e.Cancel = true;
                return;
            }

            totalLines = 0;
            foreach (List <InfoCombined> combArray in workerVars.CombinedAll)
            {
                totalLines += combArray.Count;
            }

            if (totalLines == 0)
            {
                UtilsMsg.showErrMsg(
                    "No lines will be processed. Please check your settings to make\nsure that you are not mistakenly pruning too many lines.");
                e.Cancel = true;
                return;
            }

            try
            {
                // Move vobsubs from preview dir to .media dir
                if (!needToGenerateCombinedAll)
                {
                    if (!subsWorker.copyVobsubsFromPreviewDirToMediaDir(workerVars, dialogProgress))
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            catch
            {
            }

            // Generate SRS import file
            try
            {
                DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Generate import file");

                WorkerSrs srsWorker = new WorkerSrs();

                if (!srsWorker.genSrs(workerVars, dialogProgress))
                {
                    e.Cancel = true;
                    return;
                }
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong while generating the SRS import file.\n" + e1);
                e.Cancel = true;
                return;
            }

            List <List <InfoCombined> > combinedAllWithContext =
                ObjectCopier.Clone <List <List <InfoCombined> > >(workerVars.CombinedAll);

            // Generate audio clips
            try
            {
                if (Settings.Instance.AudioClips.Enabled)
                {
                    DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Generate audio clips");

                    if (Settings.Instance.ContextLeadingCount > 0 &&
                        Settings.Instance.ContextLeadingIncludeAudioClips ||
                        Settings.Instance.ContextTrailingCount > 0 &&
                        Settings.Instance.ContextTrailingIncludeAudioClips)
                    {
                        workerVars.CombinedAll = combinedAllWithContext;
                    }
                    else
                    {
                        workerVars.CombinedAll = subsWorker.removeContextOnlyLines(combinedAllWithContext);
                    }

                    WorkerAudio audioWorker = new WorkerAudio();

                    if (!audioWorker.genAudioClip(workerVars, dialogProgress))
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong while generating the audio clips.\n" + e1);
                e.Cancel = true;
                return;
            }

            // Generate Snapshots
            try
            {
                if (Settings.Instance.Snapshots.Enabled)
                {
                    DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Generate snapshots");

                    if (Settings.Instance.ContextLeadingCount > 0 &&
                        Settings.Instance.ContextLeadingIncludeSnapshots ||
                        Settings.Instance.ContextTrailingCount > 0 &&
                        Settings.Instance.ContextTrailingIncludeSnapshots)
                    {
                        workerVars.CombinedAll = combinedAllWithContext;
                    }
                    else
                    {
                        workerVars.CombinedAll = subsWorker.removeContextOnlyLines(combinedAllWithContext);
                    }

                    WorkerSnapshot snapshotWorker = new WorkerSnapshot();

                    if (!snapshotWorker.genSnapshots(workerVars, dialogProgress))
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong while generating snapshots.\n" + e1);
                e.Cancel = true;
                return;
            }

            // Generate video clips
            try
            {
                if (Settings.Instance.VideoClips.Enabled)
                {
                    DialogProgress.nextStepInvoke(dialogProgress, ++currentStep, "Generate video clips");

                    if (Settings.Instance.ContextLeadingCount > 0 &&
                        Settings.Instance.ContextLeadingIncludeVideoClips ||
                        Settings.Instance.ContextTrailingCount > 0 &&
                        Settings.Instance.ContextTrailingIncludeVideoClips)
                    {
                        workerVars.CombinedAll = combinedAllWithContext;
                    }
                    else
                    {
                        workerVars.CombinedAll = subsWorker.removeContextOnlyLines(combinedAllWithContext);
                    }

                    WorkerVideo videoWorker = new WorkerVideo();

                    if (!videoWorker.genVideoClip(workerVars, dialogProgress))
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong while generating the video clips.\n" + e1);
                e.Cancel = true;
                return;
            }

            e.Result = workerVars;
        }