From 9c4a2c4db99495b47606d604f3f292652529e149 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 10 Sep 2012 13:30:13 +0200 Subject: [PATCH] WordCountDialog: add 'whole solution' option and make 'whole project' count only the current project. --- .../Src/Gui/Dialogs/WordCountDialog.cs | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs index 50d86815a1..c0f4dc7700 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/WordCountDialog.cs @@ -123,15 +123,21 @@ namespace ICSharpCode.SharpDevelop.Gui } case 2: {// whole project - + if (ProjectService.CurrentProject == null) { + MessageService.ShowError("${res:Dialog.WordCountDialog.MustBeInProtectedModeWarning}"); + break; + } + total = new Report(StringParser.Parse("${res:Dialog.WordCountDialog.TotalText}"), 0, 0, 0); + CountProject(ProjectService.CurrentProject, ref total); + break; + } + case 3: { // whole solution if (ProjectService.OpenSolution == null) { MessageService.ShowError("${res:Dialog.WordCountDialog.MustBeInProtectedModeWarning}"); break; } total = new Report(StringParser.Parse("${res:Dialog.WordCountDialog.TotalText}"), 0, 0, 0); CountSolution(ProjectService.OpenSolution, ref total); - // ((ListView)ControlDictionary["resultListView"]).Items.Add(new ListViewItem("")); - // ((ListView)ControlDictionary["resultListView"]).Items.Add(all.ToListItem()); break; } } @@ -141,14 +147,18 @@ namespace ICSharpCode.SharpDevelop.Gui void CountSolution(Solution solution, ref Report all) { foreach (IProject project in solution.Projects) { - foreach (ProjectItem item in project.Items) { - if (item.ItemType == ItemType.Compile) { - Report r = GetReport(item.FileName); - if (r != null) { - all += r; - items.Add(r); - // ((ListView)ControlDictionary["resultListView"]).Items.Add(r.ToListItem()); - } + CountProject(project, ref all); + } + } + + void CountProject(IProject project, ref Report all) + { + foreach (ProjectItem item in project.Items) { + if (item.ItemType == ItemType.Compile) { + Report r = GetReport(item.FileName); + if (r != null) { + all += r; + items.Add(r); } } } @@ -230,9 +240,10 @@ namespace ICSharpCode.SharpDevelop.Gui Icon = IconService.GetIcon("Icons.16x16.FindIcon"); - ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Global.Location.currentfile}")); - ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Global.Location.allopenfiles}")); - ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Global.Location.wholeproject}")); + ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.LookIn.CurrentDocument536D2AC6-E704-40BD-9790-0EB02ED6D8A9}")); + ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.LookIn.AllOpenDocuments}")); + ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.LookIn.WholeProject}")); + ((ComboBox)ControlDictionary["locationComboBox"]).Items.Add(StringParser.Parse("${res:Dialog.NewProject.SearchReplace.LookIn.WholeSolution}")); ((ComboBox)ControlDictionary["locationComboBox"]).SelectedIndex = 0; } }