Another minor fix for previous commits....

This commit is contained in:
niksedk 2015-03-07 00:30:44 +01:00
parent 58ba430a5c
commit 83d259a224

View File

@ -1,9 +1,9 @@
using System.Globalization; using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Forms; using Nikse.SubtitleEdit.Logic.Forms;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms namespace Nikse.SubtitleEdit.Forms
@ -13,6 +13,7 @@ namespace Nikse.SubtitleEdit.Forms
private Subtitle _subtitle; private Subtitle _subtitle;
private readonly LanguageStructure.RemoveTextFromHearImpaired _language; private readonly LanguageStructure.RemoveTextFromHearImpaired _language;
private RemoveTextForHI _removeTextForHILib; private RemoveTextForHI _removeTextForHILib;
private string[] _fixes;
public FormRemoveTextForHearImpaired() public FormRemoveTextForHearImpaired()
{ {
@ -109,16 +110,17 @@ namespace Nikse.SubtitleEdit.Forms
listViewFixes.BeginUpdate(); listViewFixes.BeginUpdate();
listViewFixes.Items.Clear(); listViewFixes.Items.Clear();
int count = 0; int count = 0;
int prevIndex = -1; _fixes = new string[_subtitle.Paragraphs.Count];
foreach (Paragraph p in _subtitle.Paragraphs) for (int index = 0; index < _subtitle.Paragraphs.Count; index++)
{ {
prevIndex++; Paragraph p = _subtitle.Paragraphs[index];
_removeTextForHILib.WarningIndex = prevIndex; _removeTextForHILib.WarningIndex = index -1;
string newText = _removeTextForHILib.RemoveTextFromHearImpaired(p.Text); string newText = _removeTextForHILib.RemoveTextFromHearImpaired(p.Text);
if (p.Text.Replace(" ", string.Empty) != newText.Replace(" ", string.Empty)) if (p.Text.Replace(" ", string.Empty) != newText.Replace(" ", string.Empty))
{ {
count++; count++;
AddToListView(p, newText); AddToListView(p, newText);
_fixes[index] = newText;
} }
} }
listViewFixes.EndUpdate(); listViewFixes.EndUpdate();
@ -164,9 +166,9 @@ namespace Nikse.SubtitleEdit.Forms
var item = listViewFixes.Items[i]; var item = listViewFixes.Items[i];
if (item.Checked) if (item.Checked)
{ {
Paragraph p = (Paragraph)item.Tag; var p = (Paragraph)item.Tag;
string newText = item.SubItems[3].Text.Replace(Configuration.Settings.General.ListViewLineSeparatorString, Environment.NewLine); string newText = _fixes[i];
if (string.IsNullOrEmpty(newText)) if (string.IsNullOrWhiteSpace(newText))
{ {
_subtitle.Paragraphs.Remove(p); _subtitle.Paragraphs.Remove(p);
} }