From 23d2ca7cbd2fc2ddf7fa1c934ec65450adbc728c Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 22 Dec 2006 15:34:59 +0000 Subject: [PATCH] Allow selection of multiple .dlls when adding components to the forms designer. (forum-14092) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2190 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Gui/AddComponentsDialog.cs | 59 ++++++++++++------- src/Main/Base/Test/OverloadFinding.cs | 2 +- 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs index 01dcd6880b..3f5055942a 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs @@ -57,12 +57,25 @@ namespace ICSharpCode.FormsDesigner.Gui } } - void FillComponents(Assembly assembly, string loadPath) + void BeginFillComponentsList() { componentListView.BeginUpdate(); componentListView.Items.Clear(); componentListView.Controls.Clear(); - + } + + void EndFillComponentsList(Assembly lastAssembly) + { + if (componentListView.Items.Count == 0) { + if (componentListView.Controls.Count == 0) { + ClearComponentsList(StringParser.Parse("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.NoComponentsFound}", new string[,] {{"Name", lastAssembly.FullName}})); + } + } + componentListView.EndUpdate(); + } + + void AddComponentsToList(Assembly assembly, string loadPath) + { if (assembly != null) { Hashtable images = new Hashtable(); ImageList il = new ImageList(); @@ -125,13 +138,7 @@ namespace ICSharpCode.FormsDesigner.Gui } catch (Exception e) { ClearComponentsList(e.Message); } - if (componentListView.Items.Count == 0) { - if (componentListView.Controls.Count == 0) { - ClearComponentsList(StringParser.Parse("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.NoComponentsFound}", new string[,] {{"Name", assembly.FullName}})); - } - } } - componentListView.EndUpdate(); } void gacListViewSelectedIndexChanged(object sender, System.EventArgs e) @@ -140,8 +147,11 @@ namespace ICSharpCode.FormsDesigner.Gui string assemblyName = ((ListView)ControlDictionary["gacListView"]).SelectedItems[0].Tag.ToString(); try { Assembly asm = Assembly.Load(assemblyName); - FillComponents(asm, null); + BeginFillComponentsList(); + AddComponentsToList(asm, null); + EndFillComponentsList(asm); } catch (Exception ex) { + EndFillComponentsList(null); ClearComponentsList(ex.Message); } } else { @@ -164,18 +174,27 @@ namespace ICSharpCode.FormsDesigner.Gui void loadButtonClick(object sender, System.EventArgs e) { - if (!System.IO.File.Exists(ControlDictionary["fileNameTextBox"].Text)) { - MessageService.ShowWarning("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.EnterValidFilename}"); - return; - } - + BeginFillComponentsList(); try { - string assemblyFileName = ControlDictionary["fileNameTextBox"].Text; - Assembly asm = Assembly.LoadFrom(assemblyFileName); - FillComponents(asm, Path.GetDirectoryName(assemblyFileName)); + string assemblyFileNames = ControlDictionary["fileNameTextBox"].Text; + Assembly lastAssembly = null; + foreach (string assemblyFileName in assemblyFileNames.Split(';')) { + if (!System.IO.File.Exists(assemblyFileName)) { + EndFillComponentsList(null); + ClearComponentsList(assemblyFileName + " was not found."); + MessageService.ShowWarning("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.EnterValidFilename}"); + return; + } + + Assembly asm = Assembly.LoadFrom(assemblyFileName); + lastAssembly = asm; + AddComponentsToList(asm, Path.GetDirectoryName(assemblyFileName)); + } + EndFillComponentsList(lastAssembly); } catch { + EndFillComponentsList(null); MessageService.ShowWarning("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.FileIsNotAssembly}"); - FillComponents(null, null); + ClearComponentsList(null); } } @@ -195,11 +214,11 @@ namespace ICSharpCode.FormsDesigner.Gui fdiag.AddExtension = true; fdiag.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.AssemblyFiles}|*.dll;*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*"); - fdiag.Multiselect = false; + fdiag.Multiselect = true; fdiag.CheckFileExists = true; if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { - ControlDictionary["fileNameTextBox"].Text = fdiag.FileName; + ControlDictionary["fileNameTextBox"].Text = string.Join(";", fdiag.FileNames); } } } diff --git a/src/Main/Base/Test/OverloadFinding.cs b/src/Main/Base/Test/OverloadFinding.cs index cef9e5890b..5a1257bef5 100644 --- a/src/Main/Base/Test/OverloadFinding.cs +++ b/src/Main/Base/Test/OverloadFinding.cs @@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Tests { string[] overloads = {"(T a)", "(int a)"}; Test("(1)", 1, overloads); - Test("(short.MaxValue)", 1, overloads); + //Test("(short.MaxValue)", 1, overloads); WRONG TEST - Actually here the generic method must be called. Test("(long.MaxValue)", 0, overloads); }