コード例 #1
0
        /// <summary>
        /// Start the processing in a seperate thread.
        /// If combinedAll is not null, use it rather then generating a new combinedAll.
        /// </summary>
        public void start(List <List <InfoCombined> > combinedAll)
        {
            // Create directory stucture
            try
            {
                createOutputDirStructure();
            }
            catch
            {
                UtilsMsg.showErrMsg("Cannot write to output directory. \nTry checking the directory's permissions.");
                return;
            }

            Logger.Instance.info("SubsProcessor.start");
            Logger.Instance.writeSettingsToLog();

            // Start the worker thread
            try
            {
                WorkerVars workerVars = new WorkerVars(combinedAll,
                                                       getMediaDir(Settings.Instance.OutputDir, Settings.Instance.DeckName),
                                                       WorkerVars.SubsProcessingType.Normal);

                // Create a background thread
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork             += new DoWorkEventHandler(bw_DoWork);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

                // Create a progress dialog on the UI thread
                dialogProgress            = new DialogProgress();
                currentStep               = 0;
                dialogProgress.StepsTotal = determineNumSteps(combinedAll);

                workerStartTime = DateTime.Now;
                bw.RunWorkerAsync(workerVars);

                // Lock up the UI with this modal progress form
                dialogProgress.ShowDialog();
                dialogProgress = null;
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong before processing could start.\n" + e1);
                return;
            }
        }
コード例 #2
0
        /// <summary>
        /// Extract the audio from the media.
        /// </summary>
        private void buttonExtract_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();

            if (validateForm())
            {
                updateSettings();

                Logger.Instance.info("Extract Audio From Media: GO!");
                Logger.Instance.writeSettingsToLog();

                // Start the worker thread
                try
                {
                    WorkerVars workerVars = new WorkerVars(null, Settings.Instance.OutputDir, WorkerVars.SubsProcessingType.Normal);

                    // Create a background thread
                    BackgroundWorker bw = new BackgroundWorker();
                    bw.DoWork             += new DoWorkEventHandler(splitAudio);
                    bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

                    // Create a progress dialog on the UI thread
                    dialogProgress = new DialogProgress();

                    this.workerStartTime = DateTime.Now;
                    bw.RunWorkerAsync(workerVars);

                    // Lock up the UI with this modal progress form
                    dialogProgress.ShowDialog();
                    dialogProgress = null;
                }
                catch (Exception e1)
                {
                    UtilsMsg.showErrMsg("Something went wrong before processing could start.\n" + e1);
                    return;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Generate the preview in seperate thread.
        /// </summary>
        private void generatePreview()
        {
            // Fire event to tell MainForm to update the settings
            if (GeneretePreview != null)
            {
                GeneretePreview(this, EventArgs.Empty);
            }

            populateEpisodeComboBox();

            string tempPreviewDir = Path.GetTempPath() + ConstantSettings.TempPreviewDirName;

            if (Directory.Exists(tempPreviewDir))
            {
                try
                {
                    Directory.Delete(tempPreviewDir, true);
                }
                catch
                {
                    //UtilsMsg.showErrMsg("Unable to delete the temporary directory at:\n" + tempPreviewDir);
                }
            }

            // Create the temporary directory
            try
            {
                Directory.CreateDirectory(tempPreviewDir);
            }
            catch
            {
                UtilsMsg.showErrMsg("Cannot write to " + tempPreviewDir + "\nTry checking the directory's permissions.");
                return;
            }

            Logger.Instance.info("Preview: GO!");
            Logger.Instance.writeSettingsToLog();

            // Start the worker thread
            try
            {
                WorkerVars workerVars = new WorkerVars(null, tempPreviewDir, WorkerVars.SubsProcessingType.Preview);

                // Create a background thread
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork             += new DoWorkEventHandler(bw_DoWork);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

                // Create a progress dialog on the UI thread
                dialogProgress = new DialogProgress();

                bw.RunWorkerAsync(workerVars);

                // Lock up the UI with this modal progress form
                dialogProgress.ShowDialog();
                dialogProgress = null;
            }
            catch (Exception e1)
            {
                UtilsMsg.showErrMsg("Something went wrong before preview could be generated.\n" + e1);
                return;
            }
        }