public ToolComponent(string fullName, ComponentAssembly assembly, bool enabled) { this.fullName = fullName; this.assemblyName = assembly.Name; this.hintPath = assembly.HintPath; this.isEnabled = enabled; }
public void SaveToolComponentLibrary(string fileName) { XmlDocument doc = new XmlDocument(); doc.LoadXml("<SharpDevelopControlLibrary version=\"" + VERSION + "\"/>"); Hashtable assemblyHashTable = new Hashtable(); XmlElement assemblyNode = doc.CreateElement("Assemblies"); doc.DocumentElement.AppendChild(assemblyNode); for (int i = 0; i < assemblies.Count; ++i) { ComponentAssembly componentAssembly = (ComponentAssembly)assemblies[i]; assemblyHashTable[componentAssembly.Name] = i; XmlElement newAssembly = doc.CreateElement("Assembly"); newAssembly.SetAttribute("assembly", componentAssembly.Name); if (componentAssembly.HintPath != null) { newAssembly.SetAttribute("path", componentAssembly.HintPath); } assemblyNode.AppendChild(newAssembly); } XmlElement categoryNode = doc.CreateElement("Categories"); doc.DocumentElement.AppendChild(categoryNode); foreach (Category category in categories) { XmlElement newCategory = doc.CreateElement("Category"); newCategory.SetAttribute("name", category.Name); newCategory.SetAttribute("enabled", category.IsEnabled.ToString()); categoryNode.AppendChild(newCategory); foreach (ToolComponent component in category.ToolComponents) { XmlElement newToolComponent = doc.CreateElement("ToolComponent"); newToolComponent.SetAttribute("class", component.FullName); if (assemblyHashTable[component.AssemblyName] == null) { XmlElement newAssembly = doc.CreateElement("Assembly"); newAssembly.SetAttribute("assembly", component.AssemblyName); if (component.HintPath != null) { newAssembly.SetAttribute("path", component.HintPath); } assemblyNode.AppendChild(newAssembly); assemblyHashTable[component.AssemblyName] = assemblyHashTable.Values.Count; } newToolComponent.SetAttribute("assembly", assemblyHashTable[component.AssemblyName].ToString()); newToolComponent.SetAttribute("enabled", component.IsEnabled.ToString()); newCategory.AppendChild(newToolComponent); } } doc.Save(fileName); }
public ToolComponent(string fullName, string displayname, string image, ComponentAssembly assembly, bool enabled) { this.fullName = fullName; this.assemblyName = assembly.Name; this.hintPath = assembly.HintPath; this.isEnabled = enabled; this.ImageName = image; this.displayname = displayname; }
public static void AddComponentsFromAssembly(Assembly assembly) { if (assembly == typeof(System.Windows.Forms.Form).Assembly || assembly == typeof(int).Assembly) return; var types = assembly.GetTypes(); var control_types = new List<Type>(); Type controlType = typeof(System.Windows.Forms.Control); foreach (Type type in types) if (type.IsSubclassOf(controlType)) control_types.Add(type); if (control_types.Count > 0) { string assemblyName = assembly.FullName; int ind = assemblyName.IndexOf(','); if (ind != -1) assemblyName = assemblyName.Substring(0, ind).Trim(); Category cat = new Category(assemblyName); ComponentAssembly cas = new ComponentAssembly(assembly.FullName); foreach (Type type in control_types) { cat.ToolComponents.Add(new ToolComponent(type.FullName, cas, true)); } var dynamicTab = new SideTabDesigner(sideBar, cat, toolboxService); dynamicTab.ItemRemoved += SideTabItemRemoved; dynamicTab.ItemsExchanged += SideTabItemsExchanged; sideBar.Tabs.Add(dynamicTab); } }