diff --git a/src/Main/Base/Project/Src/Commands/FileCommands.cs b/src/Main/Base/Project/Src/Commands/FileCommands.cs index 026cc0d7c5..2682809321 100644 --- a/src/Main/Base/Project/Src/Commands/FileCommands.cs +++ b/src/Main/Base/Project/Src/Commands/FileCommands.cs @@ -26,14 +26,15 @@ namespace ICSharpCode.SharpDevelop.Commands public override void Run() { if (ProjectBrowserPad.Instance.CurrentProject != null) { - if (MessageService.ShowCustomDialog("${res:Dialog.NewFile.AddToProjectQuestionTitle}", - "${res:Dialog.NewFile.AddToProjectQuestion}", - "${res:Dialog.NewFile.AddToProjectQuestionProject}", - "${res:Dialog.NewFile.AddToProjectQuestionStandalone}") - == 0) - { + int result = MessageService.ShowCustomDialog("${res:Dialog.NewFile.AddToProjectQuestionTitle}", + "${res:Dialog.NewFile.AddToProjectQuestion}", + "${res:Dialog.NewFile.AddToProjectQuestionProject}", + "${res:Dialog.NewFile.AddToProjectQuestionStandalone}"); + if (result == 0) { ProjectBrowserPad.Instance.CurrentProject.AddNewItemsToProject(); return; + } else if (result == -1) { + return; } } using (NewFileDialog nfd = new NewFileDialog(null)) { diff --git a/src/Main/Core/Project/Src/Services/MessageService/CustomDialog.cs b/src/Main/Core/Project/Src/Services/MessageService/CustomDialog.cs index 771d5e4131..a14e366c36 100644 --- a/src/Main/Core/Project/Src/Services/MessageService/CustomDialog.cs +++ b/src/Main/Core/Project/Src/Services/MessageService/CustomDialog.cs @@ -87,6 +87,13 @@ namespace ICSharpCode.Core this.ResumeLayout(false); } + protected override void OnKeyDown(KeyEventArgs e) + { + if (cancelButton == -1 && e.KeyCode == Keys.Escape) { + this.Close(); + } + } + void ButtonClick(object sender, EventArgs e) { result = (int)((Control)sender).Tag; @@ -133,6 +140,7 @@ namespace ICSharpCode.Core this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "CustomDialog"; + this.KeyPreview = true; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "CustomDialog"; }