private bool QueueNext() { if (worker == null) { worker = new Thread(DoWork); worker.Start(); } progbarTotal.Value = finishedActions * 100; foreach (DataGridViewRow row in dgv.Rows) { MkvMergeAction mergeAction = row.Tag as MkvMergeAction; if (mergeAction.Status == Status.Waiting) { lock (actionQueue) { mergeAction.Finished += new EventHandler(mergeAction_Finished); actionQueue.Enqueue(mergeAction); queueFilled.Set(); } return(true); } else if (mergeAction.Status == Status.Finished) { mergeAction.Row.Cells[5].Value = "100"; } } processing = false; return(false); }
private void cbDefaultLanguage_SelectedIndexChanged(object sender, EventArgs e) { defaultLanguage = (cbDefaultLanguage.SelectedItem as LanguageEntry).Clone(); defaultLanguage.IsDefault = true; foreach (DataGridViewRow r in dgv.Rows) { MkvMergeAction act = r.Tag as MkvMergeAction; if (act.Status == Status.Waiting) { act.UpdateDefault(defaultLanguage); } } }
private void LoadFile(string file) { var fi = new FileInfo(file); if (fi.Extension != ".mkv") { MessageBox.Show("File '" + fi.Name + "' is not an mkv"); return; } Episode ep = new Episode(fi); MkvMergeAction mergeAction = new MkvMergeAction(ep); Invoke(new NewRowDelegate(NewRow), fi, mergeAction); }
void DoWork() { while (!appExit) { queueFilled.WaitOne(); MkvMergeAction mergeAction; lock (actionQueue) { if (actionQueue.Count > 0) { mergeAction = actionQueue.Dequeue(); } else { continue; } } currentAction = mergeAction; mergeAction.Perform(this.rtbMkvMergeLog, this.progbarTotal); } }
void NewRow(FileInfo f, MkvMergeAction act) { DataGridViewRow r = new DataGridViewRow(); act.Row = r; r.CreateCells(dgv); r.Cells[0].Value = act.Episode.ToString(); r.Cells[0].ToolTipText = act.JobDescription(); r.Cells[1].Value = string.Join(",", act.MkvInfo.SubsAvailable.Select(x => x.ToString()).ToArray()); r.Cells[2].Value = string.Join(",", act.FolderSubs.Values.Select(x => x.ToString()).ToArray()); act.UpdateDefault(defaultLanguage); // r.Cells[3].Value filled in by updatedefault() r.Cells[4].Value = act.Status.ToString(); r.Tag = act; dgv.Rows.Add(r); dgv.FirstDisplayedScrollingRowIndex = r.Index; if (act.Status == Status.Waiting && processing) { progbarTotal.Maximum += 100; } }
private void btnStartMuxing_Click(object sender, EventArgs e) { if (processing) { MessageBox.Show("Error, already processing!"); return; } int numRows = 0; foreach (DataGridViewRow r in dgv.Rows) { MkvMergeAction act = r.Tag as MkvMergeAction; if (act.Status == Status.Waiting) { numRows++; } } progbarTotal.Maximum = numRows * 100; progbarTotal.Value = 0; finishedActions = 0; processing = QueueNext(); }
void NewRow(FileInfo f, MkvMergeAction act) { DataGridViewRow r = new DataGridViewRow(); act.Row = r; r.CreateCells(dgv); r.Cells[0].Value = act.Episode.ToString(); r.Cells[0].ToolTipText = act.JobDescription(); r.Cells[1].Value = string.Join(",", act.MkvInfo.SubsAvailable.Select(x => x.ToString()).ToArray()); r.Cells[2].Value = string.Join(",", act.FolderSubs.Values.Select(x => x.ToString()).ToArray()); act.UpdateDefault(defaultLanguage); // r.Cells[3].Value filled in by updatedefault() r.Cells[4].Value = act.Status.ToString(); r.Tag = act; dgv.Rows.Add(r); dgv.FirstDisplayedScrollingRowIndex = r.Index; if (act.Status == Status.Waiting && processing) progbarTotal.Maximum += 100; }
void mergeAction_Finished(object sender, EventArgs e) { if (appExit) return; finishedActions++; currentAction.Row.Cells[4].Value = currentAction.Status.ToString(); currentAction = null; try { Invoke(new QueueNextDel(QueueNext)); } catch (ObjectDisposedException) { } }
void DoWork() { while (!appExit) { queueFilled.WaitOne(); MkvMergeAction mergeAction; lock (actionQueue) { if (actionQueue.Count > 0) mergeAction = actionQueue.Dequeue(); else continue; } currentAction = mergeAction; mergeAction.Perform(this.rtbMkvMergeLog, this.progbarTotal); } }