diff --git a/libse/Paragraph.cs b/libse/Paragraph.cs index dd5449d28..10c266067 100644 --- a/libse/Paragraph.cs +++ b/libse/Paragraph.cs @@ -51,6 +51,8 @@ namespace Nikse.SubtitleEdit.Core public string Bookmark { get; set; } + public bool IsDefault => StartTime.TotalMilliseconds == 0 && EndTime.TotalMilliseconds == 0 && string.IsNullOrEmpty(Text); + private string GenerateId() { return Guid.NewGuid().ToString(); diff --git a/libse/SubtitleFormats/SubRip.cs b/libse/SubtitleFormats/SubRip.cs index a771875b9..b8c129b03 100644 --- a/libse/SubtitleFormats/SubRip.cs +++ b/libse/SubtitleFormats/SubRip.cs @@ -122,8 +122,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats ReadLine(subtitle, line, next, nextNext, nextNextNext); } - if (_paragraph != null && _paragraph.ToString() != new Paragraph().ToString() && - (subtitle.Paragraphs.Count > 0 || _paragraph.EndTime.TotalMilliseconds > 0.001)) + + if (_paragraph?.IsDefault == false) { subtitle.Paragraphs.Add(_paragraph); } diff --git a/src/Forms/Compare.cs b/src/Forms/Compare.cs index f5c513382..1a8636c67 100644 --- a/src/Forms/Compare.cs +++ b/src/Forms/Compare.cs @@ -22,7 +22,6 @@ namespace Nikse.SubtitleEdit.Forms private readonly Color _backDifferenceColor = Color.FromArgb(255, 90, 90); private readonly Color _foregroundDifferenceColor = Color.FromArgb(225, 0, 0); private bool _loadingConfig = true; - private static readonly string EmptyParagraphString = new Paragraph().ToString(); public Compare() { @@ -247,12 +246,12 @@ namespace Nikse.SubtitleEdit.Forms { bool addIndexToDifferences = false; Utilities.GetTotalAndChangedWords(p1.Text, p2.Text, ref totalWords, ref wordsChanged, checkBoxIgnoreLineBreaks.Checked, checkBoxIgnoreFormatting.Checked, ShouldBreakToLetter()); - if (p1.ToString() == EmptyParagraphString) + if (p1.IsDefault) { addIndexToDifferences = true; subtitleListView1.ColorOut(index, Color.Salmon); } - else if (p2.ToString() == EmptyParagraphString) + else if (p2.IsDefault) { addIndexToDifferences = true; subtitleListView2.ColorOut(index, Color.Salmon); @@ -279,12 +278,12 @@ namespace Nikse.SubtitleEdit.Forms { Utilities.GetTotalAndChangedWords(p1.Text, p2.Text, ref totalWords, ref wordsChanged, checkBoxIgnoreLineBreaks.Checked, checkBoxIgnoreFormatting.Checked, ShouldBreakToLetter()); bool addIndexToDifferences = false; - if (p1.ToString() == EmptyParagraphString) + if (p1.IsDefault) { addIndexToDifferences = true; subtitleListView1.ColorOut(index, Color.Salmon); } - else if (p2.ToString() == EmptyParagraphString) + else if (p2.IsDefault) { addIndexToDifferences = true; subtitleListView2.ColorOut(index, Color.Salmon); @@ -1119,7 +1118,7 @@ namespace Nikse.SubtitleEdit.Forms private string GetHtmlText(Paragraph p, string text) { - if (p.ToString() == EmptyParagraphString) + if (p.IsDefault) { return string.Empty; }