[FCE] - Call subtitle its GetParagraphOrDefault.

This commit is contained in:
Ivandro Ismael 2016-07-10 20:17:45 +01:00
parent b6a283278a
commit 34ec44f8a5
No known key found for this signature in database
GPG Key ID: A8832757DEFB7EDC

View File

@ -1027,8 +1027,7 @@ namespace Nikse.SubtitleEdit.Forms
int firstSelectedIndex = 0;
if (subtitleListView1.SelectedItems.Count > 0)
firstSelectedIndex = subtitleListView1.SelectedItems[0].Index;
Paragraph p = GetParagraphOrDefault(firstSelectedIndex);
Paragraph p = _originalSubtitle.GetParagraphOrDefault(firstSelectedIndex);
if (p != null)
{
textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged;
@ -1067,14 +1066,6 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private Paragraph GetParagraphOrDefault(int index)
{
if (_originalSubtitle.Paragraphs == null || _originalSubtitle.Paragraphs.Count <= index || index < 0)
return null;
return _originalSubtitle.Paragraphs[index];
}
private void InitializeListViewEditBox(Paragraph p)
{
textBoxListViewText.TextChanged -= TextBoxListViewTextTextChanged;
@ -1096,7 +1087,7 @@ namespace Nikse.SubtitleEdit.Forms
{
int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index;
Paragraph currentParagraph = GetParagraphOrDefault(firstSelectedIndex);
Paragraph currentParagraph = _originalSubtitle.GetParagraphOrDefault(firstSelectedIndex);
if (currentParagraph != null)
{
UpdateOverlapErrors();
@ -1118,11 +1109,11 @@ namespace Nikse.SubtitleEdit.Forms
{
int firstSelectedIndex = subtitleListView1.SelectedItems[0].Index;
Paragraph prevParagraph = GetParagraphOrDefault(firstSelectedIndex - 1);
Paragraph prevParagraph = _originalSubtitle.GetParagraphOrDefault(firstSelectedIndex - 1);
if (prevParagraph != null && prevParagraph.EndTime.TotalMilliseconds > startTime.TotalMilliseconds)
labelStartTimeWarning.Text = string.Format(_languageGeneral.OverlapPreviousLineX, (prevParagraph.EndTime.TotalMilliseconds - startTime.TotalMilliseconds) / TimeCode.BaseUnit);
Paragraph nextParagraph = GetParagraphOrDefault(firstSelectedIndex + 1);
Paragraph nextParagraph = _originalSubtitle.GetParagraphOrDefault(firstSelectedIndex + 1);
if (nextParagraph != null)
{
double durationMilliSeconds = (double)numericUpDownDuration.Value * TimeCode.BaseUnit;