Merge pull request #2815 from ivandrofly/upd

Minor clean-up
This commit is contained in:
Nikolaj Olsson 2018-03-08 20:22:16 +01:00 committed by GitHub
commit 4ab3e063d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 48 deletions

View File

@ -256,7 +256,6 @@ namespace Nikse.SubtitleEdit.Forms
bool newLine = false;
int lineNumber = 0;
float leftMargin = left;
bool italicFromStart = false;
int newLinePathPoint = -1;
Color c = _subtitleColor;
var colorStack = new Stack<Color>();
@ -375,7 +374,6 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (text.Substring(i).StartsWith("<i>", StringComparison.OrdinalIgnoreCase))
{
italicFromStart = i == 0;
if (sb.Length > 0)
{
TextDraw.DrawText(font, sf, path, sb, isItalic, subtitleFontBold, false, left, top, ref newLine, leftMargin, ref newLinePathPoint);
@ -409,8 +407,6 @@ namespace Nikse.SubtitleEdit.Forms
leftMargin = lefts[lineNumber];
left = leftMargin;
}
if (isItalic)
italicFromStart = true;
}
else
{

View File

@ -4820,59 +4820,55 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
int replaceCount = 0;
bool searchStringFound = true;
if (searchStringFound)
var searchStringFound = false;
int start = textBoxSource.SelectionStart;
if (isFirst)
{
searchStringFound = false;
int start = textBoxSource.SelectionStart;
if (isFirst)
{
MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText));
isFirst = false;
_makeHistoryPaused = true;
if (start >= 0)
start--;
}
else
{
if (textBoxSource.SelectionLength > 0 && start > 0 && !replaceDialog.FindOnly)
start--;
}
MakeHistoryForUndo(string.Format(_language.BeforeReplace, _findHelper.FindText));
isFirst = false;
_makeHistoryPaused = true;
if (start >= 0)
start--;
}
else
{
if (textBoxSource.SelectionLength > 0 && start > 0 && !replaceDialog.FindOnly)
start--;
}
if (_findHelper.FindNext(textBoxSource.Text, start))
if (_findHelper.FindNext(textBoxSource.Text, start))
{
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
textBoxSource.SelectionLength = _findHelper.FindTextLength;
if (!replaceDialog.FindOnly)
textBoxSource.SelectedText = _findHelper.ReplaceText;
textBoxSource.ScrollToCaret();
replaceCount++;
searchStringFound = true;
if (!replaceDialog.FindOnly)
{
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
textBoxSource.SelectionLength = _findHelper.FindTextLength;
if (!replaceDialog.FindOnly)
textBoxSource.SelectedText = _findHelper.ReplaceText;
textBoxSource.ScrollToCaret();
replaceCount++;
searchStringFound = true;
if (!replaceDialog.FindOnly)
if (_findHelper.FindNext(textBoxSource.Text, start))
{
if (_findHelper.FindNext(textBoxSource.Text, start))
{
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
textBoxSource.SelectionLength = _findHelper.FindTextLength;
textBoxSource.ScrollToCaret();
}
Replace(replaceDialog);
return;
textBoxSource.SelectionStart = _findHelper.SelectedIndex;
textBoxSource.SelectionLength = _findHelper.FindTextLength;
textBoxSource.ScrollToCaret();
}
}
if (replaceDialog.FindOnly)
{
if (searchStringFound)
ShowStatus(string.Format(_language.MatchFoundX, _findHelper.FindText));
else
ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText));
Replace(replaceDialog);
return;
}
}
if (replaceDialog.FindOnly)
{
if (searchStringFound)
ShowStatus(string.Format(_language.MatchFoundX, _findHelper.FindText));
else
ShowStatus(string.Format(_language.NoMatchFoundX, _findHelper.FindText));
Replace(replaceDialog);
return;
}
ReloadFromSourceView();
if (replaceCount == 0)
ShowStatus(_language.FoundNothingToReplace);