From 782aac15049bc6614b9809c8851ae802df17568c Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 28 May 2006 18:45:36 +0000 Subject: [PATCH] Fixed SD2-699: New file name does not increment git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1441 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Gui/Dialogs/NewFileDialog.cs | 10 ++++++++-- .../Project/Src/Services/File/FileService.cs | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index 545df2085f..5556be304c 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -310,9 +310,15 @@ namespace ICSharpCode.SharpDevelop.Gui StringParser.Properties["Number"] = curNumber.ToString(); string fileName = StringParser.Parse(SelectedTemplate.DefaultName); if (allowUntitledFiles) { - if (!FileService.IsOpen(fileName)) { - break; + bool found = false; + foreach (string openFile in FileService.GetOpenFiles()) { + if (Path.GetFileName(openFile) == fileName) { + found = true; + break; + } } + if (found == false) + break; } else if (!File.Exists(Path.Combine(basePath, fileName))) { break; } diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index 02981eb2f7..2cd1c9e5cb 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -6,12 +6,11 @@ // using System; -using System.Diagnostics; +using System.Collections.Generic; using System.IO; -using System.Xml; -using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.Core { @@ -128,6 +127,17 @@ namespace ICSharpCode.Core } } + public static IList GetOpenFiles() + { + List fileNames = new List(); + foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) { + string contentName = content.IsUntitled ? content.UntitledName : content.FileName; + if (contentName != null) + fileNames.Add(contentName); + } + return fileNames; + } + public static IWorkbenchWindow GetOpenFile(string fileName) { if (fileName != null && fileName.Length > 0) {