mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-23 03:33:18 +01:00
Merge pull request #2039 from ivandrofly/replacedialog
[ReplaceDialog] - Fixes #2037.
This commit is contained in:
commit
1af652aba9
@ -8,7 +8,7 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Nikse.SubtitleEdit.Forms
|
namespace Nikse.SubtitleEdit.Forms
|
||||||
{
|
{
|
||||||
public sealed partial class FindDialog : Form
|
public sealed partial class FindDialog : PositionAndSizeForm
|
||||||
{
|
{
|
||||||
private Regex _regEx;
|
private Regex _regEx;
|
||||||
private readonly Subtitle _subtitle;
|
private readonly Subtitle _subtitle;
|
||||||
@ -72,7 +72,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex)
|
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)
|
private void FormFindDialog_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
@ -4379,12 +4379,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
replaceDialog = new ReplaceDialog();
|
replaceDialog = new ReplaceDialog();
|
||||||
replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
|
replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
|
||||||
if (_findHelper == null)
|
_findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
||||||
{
|
|
||||||
_findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
|
||||||
_findHelper.WindowPositionLeft = Left + (Width / 2) - (replaceDialog.Width / 2);
|
|
||||||
_findHelper.WindowPositionTop = Top + (Height / 2) - (replaceDialog.Height / 2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
@ -4520,12 +4515,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
replaceDialog = new ReplaceDialog();
|
replaceDialog = new ReplaceDialog();
|
||||||
replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
|
replaceDialog.SetIcon(toolStripButtonReplace.Image as Bitmap);
|
||||||
if (_findHelper == null)
|
_findHelper = _findHelper ?? replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
||||||
{
|
|
||||||
_findHelper = replaceDialog.GetFindDialogHelper(_subtitleListViewIndex);
|
|
||||||
_findHelper.WindowPositionLeft = Left + (Width / 2) - (replaceDialog.Width / 2);
|
|
||||||
_findHelper.WindowPositionTop = Top + (Height / 2) - (replaceDialog.Height / 2);
|
|
||||||
}
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
if (SubtitleListview1.SelectedItems.Count > 0)
|
if (SubtitleListview1.SelectedItems.Count > 0)
|
||||||
@ -12302,7 +12292,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
_clearLastFindType = _findHelper.FindType;
|
_clearLastFindType = _findHelper.FindType;
|
||||||
_clearLastFindText = _findHelper.FindText;
|
_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();
|
ReloadFromSourceView();
|
||||||
FindNext();
|
FindNext();
|
||||||
|
4
src/Forms/ReplaceDialog.Designer.cs
generated
4
src/Forms/ReplaceDialog.Designer.cs
generated
@ -161,12 +161,10 @@
|
|||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "ReplaceDialog";
|
this.Name = "ReplaceDialog";
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "Replace";
|
this.Text = "Replace";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ReplaceDialog_FormClosing);
|
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.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormReplaceDialog_KeyDown);
|
||||||
this.Move += new System.EventHandler(this.FormReplaceDialog_Move);
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
@ -8,11 +8,9 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Nikse.SubtitleEdit.Forms
|
namespace Nikse.SubtitleEdit.Forms
|
||||||
{
|
{
|
||||||
public sealed partial class ReplaceDialog : Form
|
public sealed partial class ReplaceDialog : PositionAndSizeForm
|
||||||
{
|
{
|
||||||
private Regex _regEx;
|
private Regex _regEx;
|
||||||
private int _left;
|
|
||||||
private int _top;
|
|
||||||
private bool _userAction;
|
private bool _userAction;
|
||||||
|
|
||||||
public ReplaceDialog()
|
public ReplaceDialog()
|
||||||
@ -49,7 +47,7 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
|
|
||||||
public FindReplaceDialogHelper GetFindDialogHelper(int startLineIndex)
|
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)
|
private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e)
|
||||||
@ -65,9 +63,6 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
if (selectedText == findHelper.FindText)
|
if (selectedText == findHelper.FindText)
|
||||||
textBoxReplace.Text = findHelper.ReplaceText;
|
textBoxReplace.Text = findHelper.ReplaceText;
|
||||||
textBoxFind.SelectAll();
|
textBoxFind.SelectAll();
|
||||||
_left = findHelper.WindowPositionLeft;
|
|
||||||
_top = findHelper.WindowPositionTop;
|
|
||||||
|
|
||||||
if (findHelper.FindType == FindType.RegEx)
|
if (findHelper.FindType == FindType.RegEx)
|
||||||
radioButtonRegEx.Checked = true;
|
radioButtonRegEx.Checked = true;
|
||||||
else if (findHelper.FindType == FindType.CaseSensitive)
|
else if (findHelper.FindType == FindType.CaseSensitive)
|
||||||
@ -131,29 +126,6 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
Validate(textBoxFind.Text);
|
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)
|
private void RadioButtonCheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (sender == radioButtonRegEx)
|
if (sender == radioButtonRegEx)
|
||||||
|
@ -20,8 +20,6 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
public bool MatchWholeWord { get; set; }
|
public bool MatchWholeWord { get; set; }
|
||||||
public int SelectedIndex { get; set; }
|
public int SelectedIndex { get; set; }
|
||||||
public int SelectedPosition { get; set; }
|
public int SelectedPosition { get; set; }
|
||||||
public int WindowPositionLeft { get; set; }
|
|
||||||
public int WindowPositionTop { get; set; }
|
|
||||||
public int StartLineIndex { get; set; }
|
public int StartLineIndex { get; set; }
|
||||||
public bool MatchInOriginal { 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;
|
FindType = findType;
|
||||||
_findText = findText;
|
_findText = findText;
|
||||||
@ -62,8 +60,6 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
|
|
||||||
_regEx = regEx;
|
_regEx = regEx;
|
||||||
_findTextLenght = findText.Length;
|
_findTextLenght = findText.Length;
|
||||||
WindowPositionLeft = left;
|
|
||||||
WindowPositionTop = top;
|
|
||||||
StartLineIndex = startLineIndex;
|
StartLineIndex = startLineIndex;
|
||||||
MatchWholeWord = matchWholeWord;
|
MatchWholeWord = matchWholeWord;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user