Fixed replace dialog abort on Linux - thx teguh :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@700 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-10-07 13:20:28 +00:00
parent 01964e08fd
commit 9752be4dfb
2 changed files with 34 additions and 25 deletions

View File

@ -162,6 +162,7 @@
this.Name = "ReplaceDialog"; this.Name = "ReplaceDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Replace"; this.Text = "Replace";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ReplaceDialog_FormClosing);
this.Shown += new System.EventHandler(this.FormReplaceDialog_Shown); 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.Move += new System.EventHandler(this.FormReplaceDialog_Move);

View File

@ -1,9 +1,9 @@
using System; using System;
using System.Drawing;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Enums; using Nikse.SubtitleEdit.Logic.Enums;
using System.Drawing;
namespace Nikse.SubtitleEdit.Forms namespace Nikse.SubtitleEdit.Forms
{ {
@ -12,6 +12,7 @@ namespace Nikse.SubtitleEdit.Forms
Regex _regEx; Regex _regEx;
int _left; int _left;
int _top; int _top;
bool _userAction = false;
public ReplaceDialog() public ReplaceDialog()
{ {
@ -64,10 +65,8 @@ namespace Nikse.SubtitleEdit.Forms
private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e) private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Escape) if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
} }
}
internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper) internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper)
{ {
@ -115,10 +114,12 @@ namespace Nikse.SubtitleEdit.Forms
else if (radioButtonNormal.Checked) else if (radioButtonNormal.Checked)
{ {
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
_userAction = true;
} }
else if (radioButtonCaseSensitive.Checked) else if (radioButtonCaseSensitive.Checked)
{ {
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
_userAction = true;
} }
else if (radioButtonRegEx.Checked) else if (radioButtonRegEx.Checked)
{ {
@ -126,6 +127,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
_regEx = new Regex(textBoxFind.Text, RegexOptions.Compiled); _regEx = new Regex(textBoxFind.Text, RegexOptions.Compiled);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
_userAction = true;
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -190,5 +192,11 @@ namespace Nikse.SubtitleEdit.Forms
this.Icon = System.Drawing.Icon.FromHandle(Hicon); this.Icon = System.Drawing.Icon.FromHandle(Hicon);
} }
} }
private void ReplaceDialog_FormClosing(object sender, FormClosingEventArgs e)
{
if (!_userAction)
DialogResult = DialogResult.Cancel;
}
} }
} }