private void ReloadFromSourceView() { if (_sourceViewChange) { SaveSubtitleListviewIndexes(); if (textBoxSource.Text.Trim().Length > 0) { var temp = new Subtitle(_subtitle); SubtitleFormat format = GetCurrentSubtitleFormat(); var list = new List<string>(textBoxSource.Lines); if (format != null && format.IsMine(list, null)) format.LoadSubtitle(temp, list, null); else format = temp.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null); if (format == null) { MessageBox.Show(_language.UnableToParseSourceView); return; } else { _sourceViewChange = false; MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); _subtitle.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null); if (format.IsFrameBased) _subtitle.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate); int index = 0; foreach (object obj in comboBoxSubtitleFormats.Items) { if (obj.ToString() == format.FriendlyName) comboBoxSubtitleFormats.SelectedIndex = index; index++; } if (format.GetType() == typeof(AdvancedSubStationAlpha) || format.GetType() == typeof(SubStationAlpha)) { string errors = AdvancedSubStationAlpha.CheckForErrors(_subtitle.Header); if (!string.IsNullOrEmpty(errors)) MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (format.GetType() == typeof(SubRip)) { string errors = (format as SubRip).Errors; if (!string.IsNullOrEmpty(errors)) MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (format.GetType() == typeof(MicroDvd)) { string errors = (format as MicroDvd).Errors; if (!string.IsNullOrEmpty(errors)) MessageBox.Show(errors, Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { _sourceViewChange = false; MakeHistoryForUndo(_language.BeforeChangesMadeInSourceView); _sourceViewChange = false; _subtitle.Paragraphs.Clear(); } _subtitleListViewIndex = -1; SubtitleListview1.Fill(_subtitle, _subtitleAlternate); RestoreSubtitleListviewIndexes(); } }
private void TabControlSubtitleSelecting(object sender, TabControlCancelEventArgs e) { if (tabControlSubtitle.SelectedIndex != TabControlSourceView && textBoxSource.Text.Trim().Length > 1) { var temp = new Subtitle(_subtitle); SubtitleFormat format = temp.ReloadLoadSubtitle(new List<string>(textBoxSource.Lines), null); if (format == null) e.Cancel = true; } }