Browse Source

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
shortcuts
Daniel Grunwald 19 years ago
parent
commit
23d2ca7cbd
  1. 59
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs
  2. 2
      src/Main/Base/Test/OverloadFinding.cs

59
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.BeginUpdate();
componentListView.Items.Clear(); componentListView.Items.Clear();
componentListView.Controls.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) { if (assembly != null) {
Hashtable images = new Hashtable(); Hashtable images = new Hashtable();
ImageList il = new ImageList(); ImageList il = new ImageList();
@ -125,13 +138,7 @@ namespace ICSharpCode.FormsDesigner.Gui
} catch (Exception e) { } catch (Exception e) {
ClearComponentsList(e.Message); 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) void gacListViewSelectedIndexChanged(object sender, System.EventArgs e)
@ -140,8 +147,11 @@ namespace ICSharpCode.FormsDesigner.Gui
string assemblyName = ((ListView)ControlDictionary["gacListView"]).SelectedItems[0].Tag.ToString(); string assemblyName = ((ListView)ControlDictionary["gacListView"]).SelectedItems[0].Tag.ToString();
try { try {
Assembly asm = Assembly.Load(assemblyName); Assembly asm = Assembly.Load(assemblyName);
FillComponents(asm, null); BeginFillComponentsList();
AddComponentsToList(asm, null);
EndFillComponentsList(asm);
} catch (Exception ex) { } catch (Exception ex) {
EndFillComponentsList(null);
ClearComponentsList(ex.Message); ClearComponentsList(ex.Message);
} }
} else { } else {
@ -164,18 +174,27 @@ namespace ICSharpCode.FormsDesigner.Gui
void loadButtonClick(object sender, System.EventArgs e) void loadButtonClick(object sender, System.EventArgs e)
{ {
if (!System.IO.File.Exists(ControlDictionary["fileNameTextBox"].Text)) { BeginFillComponentsList();
MessageService.ShowWarning("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.EnterValidFilename}");
return;
}
try { try {
string assemblyFileName = ControlDictionary["fileNameTextBox"].Text; string assemblyFileNames = ControlDictionary["fileNameTextBox"].Text;
Assembly asm = Assembly.LoadFrom(assemblyFileName); Assembly lastAssembly = null;
FillComponents(asm, Path.GetDirectoryName(assemblyFileName)); 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 { } catch {
EndFillComponentsList(null);
MessageService.ShowWarning("${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.FileIsNotAssembly}"); 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.AddExtension = true;
fdiag.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.AssemblyFiles}|*.dll;*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*"); fdiag.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.AssemblyFiles}|*.dll;*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
fdiag.Multiselect = false; fdiag.Multiselect = true;
fdiag.CheckFileExists = true; fdiag.CheckFileExists = true;
if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) { if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
ControlDictionary["fileNameTextBox"].Text = fdiag.FileName; ControlDictionary["fileNameTextBox"].Text = string.Join(";", fdiag.FileNames);
} }
} }
} }

2
src/Main/Base/Test/OverloadFinding.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Tests
{ {
string[] overloads = {"<T>(T a)", "(int a)"}; string[] overloads = {"<T>(T a)", "(int a)"};
Test("(1)", 1, overloads); 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); Test("(long.MaxValue)", 0, overloads);
} }

Loading…
Cancel
Save