Merge pull request #2039 from ivandrofly/replacedialog

[ReplaceDialog] - Fixes #2037.
This commit is contained in:
Nikolaj Olsson 2016-10-29 14:53:32 +02:00 committed by GitHub
commit 1af652aba9
5 changed files with 9 additions and 53 deletions

View File

@ -8,7 +8,7 @@ using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class FindDialog : Form
public sealed partial class FindDialog : PositionAndSizeForm
{
private Regex _regEx;
private readonly Subtitle _subtitle;
@ -72,7 +72,7 @@ namespace Nikse.SubtitleEdit.Forms
public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex)
{
return new FindReplaceDialogHelper(FindType, checkBoxWholeWord.Checked, FindText, _regEx, string.Empty, 200, 300, startLineIndex);
return new FindReplaceDialogHelper(FindType, checkBoxWholeWord.Checked, FindText, _regEx, string.Empty, startLineIndex);
}
private void FormFindDialog_KeyDown(object sender, KeyEventArgs e)

View File

@ -4379,12 +4379,7 @@ namespace Nikse.SubtitleEdit.Forms
{
replaceDialog = new ReplaceDialog();
replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
if (_findHelper == null)
{
_findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
_findHelper.WindowPositionLeft = Left + (Width / 2) - (replaceDialog.Width / 2);
_findHelper.WindowPositionTop = Top + (Height / 2) - (replaceDialog.Height / 2);
}
_findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
}
else
isFirst = false;
@ -4520,12 +4515,7 @@ namespace Nikse.SubtitleEdit.Forms
{
replaceDialog = new ReplaceDialog();
replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
if (_findHelper == null)
{
_findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
_findHelper.WindowPositionLeft = Left + (Width / 2) - (replaceDialog.Width / 2);
_findHelper.WindowPositionTop = Top + (Height / 2) - (replaceDialog.Height / 2);
}
_findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
int index = 0;
if (SubtitleListview1.SelectedItems.Count > 0)
@ -12302,7 +12292,7 @@ namespace Nikse.SubtitleEdit.Forms
_clearLastFindType = _findHelper.FindType;
_clearLastFindText = _findHelper.FindText;
}
_findHelper = new FindReplaceDialogHelper(FindType.RegEx, false, string.Format(_language.DoubleWordsViaRegEx, regex), regex, string.Empty, 0, 0, _subtitleListViewIndex);
_findHelper = new FindReplaceDialogHelper(FindType.RegEx, false, string.Format(_language.DoubleWordsViaRegEx, regex), regex, string.Empty, _subtitleListViewIndex);
ReloadFromSourceView();
FindNext();

View File

@ -161,12 +161,10 @@
this.MinimizeBox = false;
this.Name = "ReplaceDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Replace";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ReplaceDialog_FormClosing);
this.Shown += new System.EventHandler(this.FormReplaceDialog_Shown);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormReplaceDialog_KeyDown);
this.Move += new System.EventHandler(this.FormReplaceDialog_Move);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -8,11 +8,9 @@ using System.Windows.Forms;
namespace Nikse.SubtitleEdit.Forms
{
public sealed partial class ReplaceDialog : Form
public sealed partial class ReplaceDialog : PositionAndSizeForm
{
private Regex _regEx;
private int _left;
private int _top;
private bool _userAction;
public ReplaceDialog()
@ -49,7 +47,7 @@ namespace Nikse.SubtitleEdit.Forms
public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex)
{
return new FindReplaceDialogHelper(GetFindType(), false, textBoxFind.Text, _regEx, textBoxReplace.Text, _left, _top, startLineIndex);
return new FindReplaceDialogHelper(GetFindType(), false, textBoxFind.Text, _regEx, textBoxReplace.Text, startLineIndex);
}
private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e)
@ -65,9 +63,6 @@ namespace Nikse.SubtitleEdit.Forms
if (selectedText == findHelper.FindText)
textBoxReplace.Text = findHelper.ReplaceText;
textBoxFind.SelectAll();
_left = findHelper.WindowPositionLeft;
_top = findHelper.WindowPositionTop;
if (findHelper.FindType == FindType.RegEx)
radioButtonRegEx.Checked = true;
else if (findHelper.FindType == FindType.CaseSensitive)
@ -131,29 +126,6 @@ namespace Nikse.SubtitleEdit.Forms
Validate(textBoxFind.Text);
}
private void FormReplaceDialog_Shown(object sender, EventArgs e)
{
if (_left > 0 && _top > 0)
{
Left = _left;
Top = _top;
}
else
{
_left = Left;
_top = Top;
}
}
private void FormReplaceDialog_Move(object sender, EventArgs e)
{
if (Left > 0 && Top > 0)
{
_left = Left;
_top = Top;
}
}
private void RadioButtonCheckedChanged(object sender, EventArgs e)
{
if (sender == radioButtonRegEx)

View File

@ -20,8 +20,6 @@ namespace Nikse.SubtitleEdit.Logic
public bool MatchWholeWord { get; set; }
public int SelectedIndex { get; set; }
public int SelectedPosition { get; set; }
public int WindowPositionLeft { get; set; }
public int WindowPositionTop { get; set; }
public int StartLineIndex { get; set; }
public bool MatchInOriginal { get; set; }
@ -49,7 +47,7 @@ namespace Nikse.SubtitleEdit.Logic
}
}
public FindReplaceDialogHelper(FindType findType, bool matchWholeWord, string findText, Regex regEx, string replaceText, int left, int top, int startLineIndex)
public FindReplaceDialogHelper(FindType findType, bool matchWholeWord, string findText, Regex regEx, string replaceText, int startLineIndex)
{
FindType = findType;
_findText = findText;
@ -62,8 +60,6 @@ namespace Nikse.SubtitleEdit.Logic
_regEx = regEx;
_findTextLenght = findText.Length;
WindowPositionLeft = left;
WindowPositionTop = top;
StartLineIndex = startLineIndex;
MatchWholeWord = matchWholeWord;
}