/// <summary> /// Swaps the order of the two specified tool components /// </summary> public void ExchangeToolComponents(string categoryName, string fullName1, string fullName2) { foreach (Category category in categories) { if (category.Name == categoryName) { int index1 = -1; int index2 = -1; for (int i = 0; i < category.ToolComponents.Count; ++i) { ToolComponent component = (ToolComponent)category.ToolComponents[i]; if (component.FullName == fullName1) { index1 = i; } else if (component.FullName == fullName2) { index2 = i; } if (index1 != -1 && index2 != -1) { ToolComponent component1 = (ToolComponent)category.ToolComponents[index1]; category.ToolComponents[index1] = category.ToolComponents[index2]; category.ToolComponents[index2] = component1; return; } } } } }
public object Clone() { ToolComponent toolComponent = new ToolComponent(); toolComponent.FullName = fullName; toolComponent.AssemblyName = assemblyName; toolComponent.IsEnabled = isEnabled; return(toolComponent); }
public bool LoadToolComponentLibrary(string fileName) { if (!File.Exists(fileName)) { return(false); } try { XmlDocument doc = new XmlDocument(); doc.Load(fileName); if (doc.DocumentElement.Name != "SharpDevelopControlLibrary" || doc.DocumentElement.Attributes["version"] == null || doc.DocumentElement.Attributes["version"].InnerText != VERSION) { return(false); } foreach (XmlNode node in doc.DocumentElement["Assemblies"].ChildNodes) { if (node.Name == "Assembly") { string assemblyName = node.Attributes["assembly"].InnerText; if (node.Attributes["path"] != null) { assemblies.Add(new ComponentAssembly(assemblyName, node.Attributes["path"].InnerText)); } else { assemblies.Add(new ComponentAssembly(assemblyName)); } } } foreach (XmlNode node in doc.DocumentElement["Categories"].ChildNodes) { if (node.Name == "Category") { string name = node.Attributes["name"].InnerText; Category newCategory = new Category(name); foreach (XmlNode componentNode in node.ChildNodes) { ToolComponent newToolComponent = new ToolComponent(componentNode.Attributes["class"].InnerText, (ComponentAssembly)assemblies[Int32.Parse(componentNode.Attributes["assembly"].InnerText)], IsEnabled(componentNode.Attributes["enabled"])); newCategory.ToolComponents.Add(newToolComponent); } categories.Add(newCategory); } } } catch (Exception e) { ; return(false); } return(true); }
public Bitmap GetIcon(ToolComponent component) { Assembly asm = component.LoadAssembly(); Type type = asm.GetType(component.FullName); Bitmap b = null; if (type != null) { object[] attributes = type.GetCustomAttributes(false); foreach (object attr in attributes) { if (attr is ToolboxBitmapAttribute) { ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr; b = new Bitmap(toolboxBitmapAttribute.GetImage(type)); b.MakeTransparent(); break; } } } if (b == null) { try { Stream imageStream = asm.GetManifestResourceStream(component.FullName + ".bmp"); if (imageStream != null) { b = new Bitmap(Image.FromStream(imageStream)); b.MakeTransparent(); } } catch (Exception e) { ; } } // TODO: Maybe default icon needed ??!?! return(b); }