Fixed bug in replace when showing original subtitle - thx Krystian :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@957 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-01-29 08:07:27 +00:00
parent a13d7fd5de
commit 350003b2d2
3 changed files with 35 additions and 17 deletions

View File

@ -2783,7 +2783,7 @@ namespace Nikse.SubtitleEdit.Forms
int selectedIndex = -1;
if (SubtitleListview1.SelectedItems.Count > 0)
selectedIndex = SubtitleListview1.SelectedItems[0].Index;
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, selectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, selectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
ShowStatus(string.Format(_language.XFoundAtLineNumberY, _findHelper.FindText, _findHelper.SelectedIndex+1));
@ -2989,12 +2989,21 @@ namespace Nikse.SubtitleEdit.Forms
if (replaceDialog.ReplaceAll)
{
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
if (_findHelper.MatchInOriginal)
{
textBoxListViewTextAlternate.SelectionStart = _findHelper.SelectedPosition;
textBoxListViewTextAlternate.SelectionLength = _findHelper.FindTextLength;
textBoxListViewTextAlternate.SelectedText = _findHelper.ReplaceText;
}
else
{
textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
textBoxListViewText.SelectionLength = _findHelper.FindTextLength;
textBoxListViewText.SelectedText = _findHelper.ReplaceText;
}
_findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
searchStringFound = true;
replaceCount++;
@ -3013,7 +3022,7 @@ namespace Nikse.SubtitleEdit.Forms
_findHelper.SelectedIndex = 0;
_findHelper.SelectedPosition = 0;
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
@ -3029,7 +3038,7 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (replaceDialog.FindOnly)
{
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
textBoxListViewText.Focus();
@ -3049,7 +3058,7 @@ namespace Nikse.SubtitleEdit.Forms
_findHelper.StartLineIndex = 0;
_findHelper.SelectedIndex = 0;
_findHelper.SelectedPosition = 0;
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
textBoxListViewText.Focus();
@ -3082,12 +3091,21 @@ namespace Nikse.SubtitleEdit.Forms
msg = _language.OneReplacementMade + " ";
}
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
if (_findHelper.MatchInOriginal)
{
textBoxListViewTextAlternate.Focus();
textBoxListViewTextAlternate.SelectionStart = _findHelper.SelectedPosition;
textBoxListViewTextAlternate.SelectionLength = _findHelper.FindTextLength;
}
else
{
textBoxListViewText.Focus();
textBoxListViewText.SelectionStart = _findHelper.SelectedPosition;
textBoxListViewText.SelectionLength = _findHelper.FindTextLength;
}
_findHelper.SelectedPosition += _findHelper.ReplaceText.Length;
ShowStatus(string.Format(msg + _language.XFoundAtLineNumberY + _language.XFoundAtLineNumberY, _findHelper.SelectedIndex + 1, _findHelper.FindText));
}
@ -3107,7 +3125,7 @@ namespace Nikse.SubtitleEdit.Forms
_findHelper.SelectedPosition = 0;
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition))
if (_findHelper.FindNext(_subtitle, _subtitleAlternate, _findHelper.SelectedIndex, _findHelper.SelectedPosition, Configuration.Settings.General.AllowEditOfOriginalSubtitle))
{
SubtitleListview1.SelectIndexAndEnsureVisible(_findHelper.SelectedIndex);
textBoxListViewText.Focus();

View File

@ -681,7 +681,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAegBDgHoAQ4BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAfABDgHwAQ4BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -58,7 +58,7 @@ namespace Nikse.SubtitleEdit.Logic
public bool Find(Subtitle subtitle, Subtitle originalSubtitle, int startIndex)
{
return FindNext(subtitle, originalSubtitle, startIndex, 0);
return FindNext(subtitle, originalSubtitle, startIndex, 0, Configuration.Settings.General.AllowEditOfOriginalSubtitle);
}
public bool Find(TextBox textBox, int startIndex)
@ -97,7 +97,7 @@ namespace Nikse.SubtitleEdit.Logic
return -1;
}
public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position)
public bool FindNext(Subtitle subtitle, Subtitle originalSubtitle, int startIndex, int position, bool allowEditOfOriginalSubtitle)
{
Success = false;
int index = 0;
@ -123,7 +123,7 @@ namespace Nikse.SubtitleEdit.Logic
}
MatchInOriginal = false;
if (originalSubtitle != null)
if (originalSubtitle != null && allowEditOfOriginalSubtitle)
{
Paragraph o = Utilities.GetOriginalParagraph(index, p, originalSubtitle.Paragraphs);
if (o != null)