public static Subtitle FromListViewItem(ListViewItem lvi)
        {
            int i = 0;
            Int32.TryParse(lvi.SubItems[3].Text, out i);

            var subtitle = new Subtitle()
                                    {
                                        Text = lvi.SubItems[0].Text,
                                        Start = lvi.SubItems[1].Text,
                                        End = lvi.SubItems[2].Text,
                                        Serial = i
                                    };
            return subtitle;
        }
 private void tbReload_Click(object sender, EventArgs e)
 {
     var strings = textSRT.Text.Split('\n');
     listSubtitles.Items.Clear();
     foreach (var s in strings)
     {
         if (s.Trim().Length != 0)
         {
             var subtitle = new Subtitle() { Text = s.Trim(), Serial = listSubtitles.Items.Count + 1 };
             listSubtitles.Items.Add(subtitle.ToListViewItem());
         }
     }
 }
 private void tbAdd_Click(object sender, EventArgs e)
 {
     var subtitle = new Subtitle() { Text = textSRT.Text, Serial = listSubtitles.Items.Count };
     listSubtitles.Items.Add(subtitle.ToListViewItem());
 }
        private void Open()
        {
            Regex unit = new Regex(@"(?<sequence>\d+)\r\n(?<start>\d{2}\:\d{2}\:\d{2},\d{3}) --\> " + @"(?<end>\d{2}\:\d{2}\:\d{2},\d{3})\r\n(?<text>[\s\S]*?\r\n\r\n)", RegexOptions.Compiled | RegexOptions.ECMAScript);

            _openFileDialog.Filter = @"SRT File|*.srt";
            if (_openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //textSrtFile.Text = sfd.FileName;
                var sw = new StreamReader(_openFileDialog.FileName);

                string subtitles = sw.ReadToEnd();

                MatchCollection matchCollection = unit.Matches(subtitles);
                int serial = 0;

                listSubtitles.Items.Clear();
                foreach (Match match in matchCollection)
                {
                    Int32.TryParse(match.Groups[1].Value, out serial);
                    var subtitle = new Subtitle
                                       {
                                           Serial = serial,
                                           Start = match.Groups[2].Value,
                                           End = match.Groups[3].Value,
                                           Text = match.Groups[4].Value.Trim()
                                       };
                    listSubtitles.Items.Add(subtitle.ToListViewItem());
                }

                sw.Close();
            }
        }
 private void btnGetEnd_Click(object sender, EventArgs e)
 {
     textEnd.Text = Subtitle.MillisecondsToString(wmp.Ctlcontrols.currentPosition);
 }
        private void endToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int time = (int)(wmp.Ctlcontrols.currentPosition * 1000);

            this.textSRT.SelectedText = Subtitle.MillisecondsToString(time);
        }