private void saveSubtitleAsToolStripMenuItem_Click(object sender, EventArgs e) { int idx = listBoxTracks.SelectedIndex; if (idx < 0) { return; } var item = (StreamTrackItem)listBoxTracks.SelectedItem; if (item.IsTeletext) { saveFileDialog1.Title = Configuration.Settings.Language.ExportCustomText.SaveSubtitleAs; var fileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); if (!string.IsNullOrEmpty(item.Language)) { fileName += "." + _programMapTableParser.GetSubtitleLanguageTwoLetter(item.Pid); } saveFileDialog1.FileName = fileName; if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) { File.WriteAllText(saveFileDialog1.FileName, item.Srt); } } }
private void saveSubtitleAsToolStripMenuItem_Click(object sender, EventArgs e) { int idx = listBoxTracks.SelectedIndex; if (idx < 0) { return; } var item = (StreamTrackItem)listBoxTracks.SelectedItem; if (item.IsTeletext) { saveFileDialog1.Title = LanguageSettings.Current.ExportCustomText.SaveSubtitleAs; var fileName = Utilities.GetPathAndFileNameWithoutExtension(_fileName); if (item.PageNumber > 0) { fileName += "." + item.PageNumber.ToString(CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(item.Language)) { fileName += "." + _programMapTableParser.GetSubtitleLanguageTwoLetter(item.Pid); } saveFileDialog1.InitialDirectory = Path.GetDirectoryName(fileName); saveFileDialog1.FileName = Path.GetFileName(fileName) + ".srt"; if (saveFileDialog1.ShowDialog(this) == DialogResult.OK) { File.WriteAllText(saveFileDialog1.FileName, item.Srt); } } }
public static string GetFileNameEnding(ProgramMapTableParser pmt, int pid) { var twoLetter = pmt.GetSubtitleLanguageTwoLetter(pid); var threeLetter = pmt.GetSubtitleLanguage(pid); if (string.IsNullOrEmpty(twoLetter)) { twoLetter = threeLetter; } if (string.IsNullOrEmpty(threeLetter)) { twoLetter = pid.ToString(CultureInfo.InvariantCulture); threeLetter = pid.ToString(CultureInfo.InvariantCulture); } return(Configuration.Settings.Tools.BatchConvertTsFileNameAppend .Replace("{two-letter-country-code}", twoLetter) .Replace("{two-letter-country-code-uppercase}", twoLetter.ToUpperInvariant()) .Replace("{three-letter-country-code}", threeLetter) .Replace("{three-letter-country-code-uppercase}", threeLetter)); }