From 9752be4dfb44b6da633c4b4bfb09bd5140905f92 Mon Sep 17 00:00:00 2001 From: niksedk Date: Fri, 7 Oct 2011 13:20:28 +0000 Subject: [PATCH] Fixed replace dialog abort on Linux - thx teguh :) git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@700 99eadd0c-20b8-1223-b5c4-2a2b2df33de2 --- src/Forms/ReplaceDialog.Designer.cs | 45 +++++++++++++++-------------- src/Forms/ReplaceDialog.cs | 14 +++++++-- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/Forms/ReplaceDialog.Designer.cs b/src/Forms/ReplaceDialog.Designer.cs index ac473bc8a..8d413a530 100644 --- a/src/Forms/ReplaceDialog.Designer.cs +++ b/src/Forms/ReplaceDialog.Designer.cs @@ -39,9 +39,9 @@ this.labelFindWhat = new System.Windows.Forms.Label(); this.buttonFind = new System.Windows.Forms.Button(); this.SuspendLayout(); - // + // // radioButtonRegEx - // + // this.radioButtonRegEx.AutoSize = true; this.radioButtonRegEx.Location = new System.Drawing.Point(17, 97); this.radioButtonRegEx.Name = "radioButtonRegEx"; @@ -50,9 +50,9 @@ this.radioButtonRegEx.Text = "RegEx"; this.radioButtonRegEx.UseVisualStyleBackColor = true; this.radioButtonRegEx.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // + // // radioButtonCaseSensitive - // + // this.radioButtonCaseSensitive.AutoSize = true; this.radioButtonCaseSensitive.Location = new System.Drawing.Point(17, 74); this.radioButtonCaseSensitive.Name = "radioButtonCaseSensitive"; @@ -61,9 +61,9 @@ this.radioButtonCaseSensitive.Text = "Case sensitive"; this.radioButtonCaseSensitive.UseVisualStyleBackColor = true; this.radioButtonCaseSensitive.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // + // // radioButtonNormal - // + // this.radioButtonNormal.AutoSize = true; this.radioButtonNormal.Checked = true; this.radioButtonNormal.Location = new System.Drawing.Point(17, 51); @@ -74,9 +74,9 @@ this.radioButtonNormal.Text = "Normal"; this.radioButtonNormal.UseVisualStyleBackColor = true; this.radioButtonNormal.CheckedChanged += new System.EventHandler(this.RadioButtonCheckedChanged); - // + // // buttonReplace - // + // this.buttonReplace.Location = new System.Drawing.Point(96, 180); this.buttonReplace.Name = "buttonReplace"; this.buttonReplace.Size = new System.Drawing.Size(75, 21); @@ -84,17 +84,17 @@ this.buttonReplace.Text = "Replace"; this.buttonReplace.UseVisualStyleBackColor = true; this.buttonReplace.Click += new System.EventHandler(this.ButtonReplaceClick); - // + // // textBoxFind - // + // this.textBoxFind.Location = new System.Drawing.Point(15, 25); this.textBoxFind.Name = "textBoxFind"; this.textBoxFind.Size = new System.Drawing.Size(262, 21); this.textBoxFind.TabIndex = 0; this.textBoxFind.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindKeyDown); - // + // // buttonReplaceAll - // + // this.buttonReplaceAll.Location = new System.Drawing.Point(177, 180); this.buttonReplaceAll.Name = "buttonReplaceAll"; this.buttonReplaceAll.Size = new System.Drawing.Size(103, 21); @@ -102,35 +102,35 @@ this.buttonReplaceAll.Text = "Replace all"; this.buttonReplaceAll.UseVisualStyleBackColor = true; this.buttonReplaceAll.Click += new System.EventHandler(this.ButtonReplaceAllClick); - // + // // textBoxReplace - // + // this.textBoxReplace.Location = new System.Drawing.Point(15, 144); this.textBoxReplace.Name = "textBoxReplace"; this.textBoxReplace.Size = new System.Drawing.Size(265, 21); this.textBoxReplace.TabIndex = 4; this.textBoxReplace.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxFindKeyDown); - // + // // labelReplaceWith - // + // this.labelReplaceWith.AutoSize = true; this.labelReplaceWith.Location = new System.Drawing.Point(12, 127); this.labelReplaceWith.Name = "labelReplaceWith"; this.labelReplaceWith.Size = new System.Drawing.Size(72, 13); this.labelReplaceWith.TabIndex = 14; this.labelReplaceWith.Text = "Replace with:"; - // + // // labelFindWhat - // + // this.labelFindWhat.AutoSize = true; this.labelFindWhat.Location = new System.Drawing.Point(12, 8); this.labelFindWhat.Name = "labelFindWhat"; this.labelFindWhat.Size = new System.Drawing.Size(58, 13); this.labelFindWhat.TabIndex = 15; this.labelFindWhat.Text = "Find what:"; - // + // // buttonFind - // + // this.buttonFind.Location = new System.Drawing.Point(15, 180); this.buttonFind.Name = "buttonFind"; this.buttonFind.Size = new System.Drawing.Size(75, 21); @@ -138,9 +138,9 @@ this.buttonFind.Text = "Find"; this.buttonFind.UseVisualStyleBackColor = true; this.buttonFind.Click += new System.EventHandler(this.ButtonFindClick); - // + // // ReplaceDialog - // + // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(330, 208); @@ -162,6 +162,7 @@ this.Name = "ReplaceDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; 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); diff --git a/src/Forms/ReplaceDialog.cs b/src/Forms/ReplaceDialog.cs index 9c9de474e..a7b1279a9 100644 --- a/src/Forms/ReplaceDialog.cs +++ b/src/Forms/ReplaceDialog.cs @@ -1,9 +1,9 @@ using System; +using System.Drawing; using System.Text.RegularExpressions; using System.Windows.Forms; using Nikse.SubtitleEdit.Logic; using Nikse.SubtitleEdit.Logic.Enums; -using System.Drawing; namespace Nikse.SubtitleEdit.Forms { @@ -12,6 +12,7 @@ namespace Nikse.SubtitleEdit.Forms Regex _regEx; int _left; int _top; + bool _userAction = false; public ReplaceDialog() { @@ -64,9 +65,7 @@ namespace Nikse.SubtitleEdit.Forms private void FormReplaceDialog_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) - { DialogResult = DialogResult.Cancel; - } } internal void Initialize(string selectedText, FindReplaceDialogHelper findHelper) @@ -115,10 +114,12 @@ namespace Nikse.SubtitleEdit.Forms else if (radioButtonNormal.Checked) { DialogResult = DialogResult.OK; + _userAction = true; } else if (radioButtonCaseSensitive.Checked) { DialogResult = DialogResult.OK; + _userAction = true; } else if (radioButtonRegEx.Checked) { @@ -126,6 +127,7 @@ namespace Nikse.SubtitleEdit.Forms { _regEx = new Regex(textBoxFind.Text, RegexOptions.Compiled); DialogResult = DialogResult.OK; + _userAction = true; } catch (Exception exception) { @@ -190,5 +192,11 @@ namespace Nikse.SubtitleEdit.Forms this.Icon = System.Drawing.Icon.FromHandle(Hicon); } } + + private void ReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) + { + if (!_userAction) + DialogResult = DialogResult.Cancel; + } } }