public void FetchStreamInformation(int iFeatureNumber) { UpdateCacher.CheckPackage("eac3to"); initBackgroundWorker(); args = new eac3toArgs(); args.eac3toPath = MainForm.Instance.Settings.Eac3to.Path; args.resultState = ResultState.StreamCompleted; args.args = iFeatureNumber.ToString(); args.featureNumber = iFeatureNumber.ToString(); args.workingFolder = System.IO.Path.GetDirectoryName(MainForm.Instance.Settings.Eac3to.Path); backgroundWorker.ReportProgress(0, "Retrieving streams..."); backgroundWorker.RunWorkerAsync(args); }
public void FetchFeatureInformation() { UpdateCacher.CheckPackage("eac3to"); initBackgroundWorker(); args = new eac3toArgs(); args.eac3toPath = MainForm.Instance.Settings.Eac3to.Path; args.resultState = ResultState.FeatureCompleted; args.args = string.Empty; args.workingFolder = System.IO.Path.GetDirectoryName(MainForm.Instance.Settings.Eac3to.Path); features = new List <Feature>(); backgroundWorker.ReportProgress(0, "Retrieving features..."); backgroundWorker.RunWorkerAsync(args); }
private void QueueButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(FolderOutputTextBox.Text)) { MessageBox.Show("Configure output target folder prior to queueing job.", "Queue Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (StreamDataGridView.Rows.Count == 0) { MessageBox.Show("Retrieve streams prior to queueing job.", "Queue Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (!IsStreamCheckedForExtract()) { MessageBox.Show("Select stream(s) to extract prior to queueing job.", "Queue Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (FolderSelection.Checked && FeatureDataGridView.SelectedRows.Count == 0) { MessageBox.Show("Select feature prior to queueing job.", "Queue Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } if (!Drives.ableToWriteOnThisDrive(System.IO.Path.GetPathRoot(FolderOutputTextBox.Text))) { MessageBox.Show("MeGUI cannot write on " + System.IO.Path.GetPathRoot(FolderOutputTextBox.Text) + "\nPlease, select another Output path.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } eac3toArgs args = new eac3toArgs(); HDStreamsExJob job; args.eac3toPath = settings.EAC3toPath; args.inputPath = FolderInputTextBox.Text; if (FolderSelection.Checked) { args.featureNumber = ((Feature)FeatureDataGridView.SelectedRows[0].DataBoundItem).Number.ToString(); } args.workingFolder = string.IsNullOrEmpty(FolderOutputTextBox.Text) ? FolderOutputTextBox.Text : System.IO.Path.GetDirectoryName(args.eac3toPath); args.resultState = ResultState.ExtractCompleted; try { args.args = GenerateArguments(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Stream Extract", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } // Load to MeGUI job queue if (FolderSelection.Checked) { job = new HDStreamsExJob(dummyInput, this.FolderOutputTextBox.Text + "xxx", args.featureNumber, args.args, inputType); } else { job = new HDStreamsExJob(this.FolderInputTextBox.Text, this.FolderOutputTextBox.Text + "xxx", null, args.args, inputType); } lastJob = job; mainForm.Jobs.addJobsToQueue(job); if (this.closeOnQueue.Checked) { this.Close(); } }
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { eac3toArgs args = (eac3toArgs)e.Argument; using (Process compiler = new Process()) { string strSource = string.Format("\"{0}\"", input[0]); for (int i = 1; i < input.Count; i++) { strSource += string.Format("+\"{0}\"", input[i]); } compiler.StartInfo.FileName = args.eac3toPath; switch (args.resultState) { case ResultState.FeatureCompleted: compiler.StartInfo.Arguments = string.Format("{0}", strSource); break; case ResultState.StreamCompleted: if (args.args == string.Empty) { compiler.StartInfo.Arguments = string.Format("{0}", strSource); } else { compiler.StartInfo.Arguments = string.Format("{0} {1}) {2}", strSource, args.args, "-progressnumbers"); } break; case ResultState.ExtractCompleted: if (oMode == OperatingMode.FileBased) { compiler.StartInfo.Arguments = string.Format("{0} {1}", strSource, args.args + " -progressnumbers"); } else { compiler.StartInfo.Arguments = string.Format("{0} {1}) {2}", strSource, args.featureNumber, args.args + "-progressnumbers"); } break; } if (_log != null) { _log.LogEvent(string.Format("Arguments: {0}", compiler.StartInfo.Arguments)); } compiler.StartInfo.WorkingDirectory = args.workingFolder; compiler.StartInfo.CreateNoWindow = true; compiler.StartInfo.UseShellExecute = false; compiler.StartInfo.RedirectStandardOutput = true; compiler.StartInfo.RedirectStandardError = true; compiler.StartInfo.ErrorDialog = false; compiler.EnableRaisingEvents = true; compiler.EnableRaisingEvents = true; compiler.Exited += new EventHandler(backgroundWorker_Exited); compiler.ErrorDataReceived += new DataReceivedEventHandler(backgroundWorker_ErrorDataReceived); compiler.OutputDataReceived += new DataReceivedEventHandler(backgroundWorker_OutputDataReceived); try { compiler.Start(); compiler.BeginErrorReadLine(); compiler.BeginOutputReadLine(); while (!compiler.HasExited) { if (backgroundWorker.CancellationPending) { compiler.Kill(); } } while (!compiler.HasExited) // wait until the process has terminated without locking the GUI { System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(100); } compiler.WaitForExit(); } catch (Exception ex) { if (_log != null) { _log.LogValue("Error running job", ex); } } finally { compiler.ErrorDataReceived -= new DataReceivedEventHandler(backgroundWorker_ErrorDataReceived); compiler.OutputDataReceived -= new DataReceivedEventHandler(backgroundWorker_OutputDataReceived); } } e.Result = args.resultState; }