private void backgroundWorkerMain_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; MkvExtractProgress progress = new MkvExtractProgress(); progress.MaxEpisode = selectedMkvFiles.Count; foreach (string file in selectedMkvFiles) { progress.CurEpisode++; List <MkvTrack> tracks = null; if (trackTypeToExtract == "All subtitle tracks") { tracks = UtilsMkv.getSubtitleTrackList(file); } else if (trackTypeToExtract == "All audio tracks") { tracks = UtilsMkv.getAudioTrackList(file); } else { tracks = UtilsMkv.getTrackList(file); } progress.CurTrack = 0; progress.MaxTrack = tracks.Count; foreach (MkvTrack track in tracks) { if (worker.CancellationPending) { e.Cancel = true; return; } progress.CurTrack++; worker.ReportProgress(0, progress); string displayLang = UtilsLang.LangThreeLetter2Full(track.Lang); if (displayLang == "") { displayLang = "Unknown"; } string fileName = $"{outDir}{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(file)} - Track {Convert.ToInt32(track.TrackID):00} - {displayLang}.{track.Extension}"; UtilsMkv.extractTrack(file, track.TrackID, fileName); } } }
/// <summary> /// Update the information related to Subs1 or Subs2. /// </summary> private void updateSubs(int subsNum) { TextBox textbox; string file; // Get items that depend on whether it's subs1 or subs2 if (subsNum == 1) { textbox = this.textBoxSubs1File; file = this.textBoxSubs1File.Text.Trim(); } else { textbox = this.textBoxSubs2File; file = this.textBoxSubs2File.Text.Trim(); } // If input file is an MKV, show the MKV track select dialog if (Path.GetExtension(file) == ".mkv") { List <MkvTrack> allSubTrackList = UtilsMkv.getSubtitleTrackList(file); List <MkvTrack> subTrackList = new List <MkvTrack>(); // Remove VOBSUB tracks foreach (MkvTrack subTrack in allSubTrackList) { if (subTrack.Extension != "sub") { subTrackList.Add(subTrack); } } if (subTrackList.Count == 0) { UtilsMsg.showInfoMsg("This .mkv file does not contain any subtitle tracks."); textbox.Text = ""; } else { DialogSelectMkvTrack mkvDlg = new DialogSelectMkvTrack(file, subsNum, subTrackList); DialogResult result = mkvDlg.ShowDialog(); if (result == DialogResult.OK) { textbox.Text = mkvDlg.ExtractedFile; } else { textbox.Text = ""; } } return; // Since textbox.Text was changed, this routine will be called again } }