Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
         }
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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);
     }
 }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
 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) { }
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 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);
     }
 }