|
|
|
|
@ -25,6 +25,7 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -25,6 +25,7 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
public class AddComponentsDialog : BaseSharpDevelopForm |
|
|
|
|
{ |
|
|
|
|
ArrayList selectedComponents; |
|
|
|
|
ListView componentListView; |
|
|
|
|
|
|
|
|
|
public ArrayList SelectedComponents { |
|
|
|
|
get { |
|
|
|
|
@ -36,6 +37,8 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -36,6 +37,8 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
{ |
|
|
|
|
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.FormsDesigner.Resources.AddSidebarComponentsDialog.xfrm")); |
|
|
|
|
|
|
|
|
|
componentListView = (ListView)ControlDictionary["componentListView"]; |
|
|
|
|
|
|
|
|
|
Icon = null; |
|
|
|
|
PrintGACCache(); |
|
|
|
|
|
|
|
|
|
@ -53,11 +56,11 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -53,11 +56,11 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
IAssemblyName assemblyName = null; |
|
|
|
|
|
|
|
|
|
Fusion.CreateAssemblyEnum(out assemblyEnum, null, null, 2, 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (assemblyEnum.GetNextAssembly(out applicationContext, out assemblyName, 0) == 0) { |
|
|
|
|
uint nChars = 0; |
|
|
|
|
assemblyName.GetDisplayName(null, ref nChars, 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder((int)nChars); |
|
|
|
|
assemblyName.GetDisplayName(sb, ref nChars, 0); |
|
|
|
|
|
|
|
|
|
@ -74,8 +77,9 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -74,8 +77,9 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
|
|
|
|
|
void FillComponents(Assembly assembly, string loadPath) |
|
|
|
|
{ |
|
|
|
|
((ListView)ControlDictionary["componentListView"]).BeginUpdate(); |
|
|
|
|
((ListView)ControlDictionary["componentListView"]).Items.Clear(); |
|
|
|
|
componentListView.BeginUpdate(); |
|
|
|
|
componentListView.Items.Clear(); |
|
|
|
|
componentListView.Controls.Clear(); |
|
|
|
|
|
|
|
|
|
if (assembly != null) { |
|
|
|
|
Hashtable images = new Hashtable(); |
|
|
|
|
@ -92,7 +96,7 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -92,7 +96,7 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
} catch {} |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
((ListView)ControlDictionary["componentListView"]).SmallImageList = il; |
|
|
|
|
componentListView.SmallImageList = il; |
|
|
|
|
foreach (Type t in assembly.GetExportedTypes()) { |
|
|
|
|
if (!t.IsAbstract) { |
|
|
|
|
if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) { |
|
|
|
|
@ -131,41 +135,49 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -131,41 +135,49 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
ToolComponent toolComponent = new ToolComponent(t.FullName, new ComponentAssembly(assembly.FullName, loadPath)); |
|
|
|
|
toolComponent.IsEnabled = true; |
|
|
|
|
newItem.Tag = toolComponent; |
|
|
|
|
((ListView)ControlDictionary["componentListView"]).Items.Add(newItem); |
|
|
|
|
componentListView.Items.Add(newItem); |
|
|
|
|
ToolboxItem item = new ToolboxItem(t); |
|
|
|
|
skip:; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
MessageService.ShowError(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}})); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
((ListView)ControlDictionary["componentListView"]).EndUpdate(); |
|
|
|
|
componentListView.EndUpdate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* changed this unexpected behaviour -- added a load button, G.B. |
|
|
|
|
void fileNameTextBoxTextChanged(object sender, System.EventArgs e) |
|
|
|
|
void gacListViewSelectedIndexChanged(object sender, System.EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (File.Exists(this.fileNameTextBox.Text)) { |
|
|
|
|
if (((ListView)ControlDictionary["gacListView"]).SelectedItems != null && ((ListView)ControlDictionary["gacListView"]).SelectedItems.Count == 1) { |
|
|
|
|
string assemblyName = ((ListView)ControlDictionary["gacListView"]).SelectedItems[0].Tag.ToString(); |
|
|
|
|
try { |
|
|
|
|
FillComponents(Assembly.LoadFrom(this.fileNameTextBox.Text)); |
|
|
|
|
Assembly asm = Assembly.Load(assemblyName); |
|
|
|
|
FillComponents(asm, null); |
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
|
|
|
|
MessageService.ShowError(ex); |
|
|
|
|
ClearComponentsList(ex.Message); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ClearComponentsList(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
void gacListViewSelectedIndexChanged(object sender, System.EventArgs e) |
|
|
|
|
void ClearComponentsList(string message) |
|
|
|
|
{ |
|
|
|
|
if (((ListView)ControlDictionary["gacListView"]).SelectedItems != null && ((ListView)ControlDictionary["gacListView"]).SelectedItems.Count == 1) { |
|
|
|
|
string assemblyName = ((ListView)ControlDictionary["gacListView"]).SelectedItems[0].Tag.ToString(); |
|
|
|
|
Assembly asm = Assembly.Load(assemblyName); |
|
|
|
|
FillComponents(asm, null); |
|
|
|
|
} else { |
|
|
|
|
FillComponents(null, null); |
|
|
|
|
componentListView.Items.Clear(); |
|
|
|
|
componentListView.Controls.Clear(); |
|
|
|
|
if (message != null) { |
|
|
|
|
Label lbl = new Label(); |
|
|
|
|
lbl.BackColor = SystemColors.Window; |
|
|
|
|
lbl.Text = StringParser.Parse(message); |
|
|
|
|
lbl.Dock = DockStyle.Fill; |
|
|
|
|
componentListView.Controls.Add(lbl); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -189,7 +201,7 @@ namespace ICSharpCode.FormsDesigner.Gui
@@ -189,7 +201,7 @@ namespace ICSharpCode.FormsDesigner.Gui
|
|
|
|
|
void buttonClick(object sender, System.EventArgs e) |
|
|
|
|
{ |
|
|
|
|
selectedComponents = new ArrayList(); |
|
|
|
|
foreach (ListViewItem item in ((ListView)ControlDictionary["componentListView"]).Items) { |
|
|
|
|
foreach (ListViewItem item in componentListView.Items) { |
|
|
|
|
if (item.Checked) { |
|
|
|
|
selectedComponents.Add((ToolComponent)item.Tag); |
|
|
|
|
} |
|
|
|
|
|