private void toolStripButton5_Click(object sender, EventArgs e) { try { saveFileDialog1.FileName = Path.GetFileNameWithoutExtension(fname) + "_ar.srt"; if (saveFileDialog1.ShowDialog() != DialogResult.OK) { return; } toolStripProgressBar1.Visible = true; toolStripProgressBar1.Value = 0; toolStripProgressBar1.Maximum = listView1.Items.Count; string sfname = ""; sfname = saveFileDialog1.FileName; string srtText = ""; foreach (ListViewItem item in listView1.Items) { SrtItem m = ((SrtItem)item.Tag); toolStripProgressBar1.Value++; srtText += m.ID + Environment.NewLine + m.FromTime + "-->" + m.EndTime + Environment.NewLine + m.TranslatedSRT + Environment.NewLine; } File.WriteAllText(sfname, srtText, Encoding.Default); } catch { } finally { toolStripProgressBar1.Visible = false; } }
public SrtItemCollection(string srtAsString) { foreach (Match item in unit.Matches(srtAsString)) { SrtItem SrtItem = new SrtItem(); SrtItem.ID = int.Parse(item.Groups["sequence"].Value.Trim()); SrtItem.FromTime = item.Groups["start"].Value.Replace(",", ".").Trim(); SrtItem.EndTime = item.Groups["end"].Value.Replace(",", ".").Trim(); SrtItem.OrginalSRT = item.Groups["text"].Value; SrtItems.Add(SrtItem); } }