Ejemplo n.º 1
0
		///<summary>Load an assembly's controls</summary>
		public SideTabDesigner(SideBarControl sideBar, Category category, IToolboxService toolboxService) : this(sideBar, category.Name, toolboxService)
		{
			foreach (ToolComponent component in category.ToolComponents) {
				if (component.IsEnabled) {
					ToolboxItem toolboxItem = new ToolboxItem();
					toolboxItem.TypeName    = component.FullName;
					toolboxItem.Bitmap      = ToolboxProvider.ComponentLibraryLoader.GetIcon(component);
					toolboxItem.DisplayName = component.Name;
					Assembly asm = component.LoadAssembly();
					toolboxItem.AssemblyName = asm.GetName();
					
					this.Items.Add(new SideTabItemDesigner(toolboxItem));
				}
			}
		}
		SetupDialogControlsSideTab(SideBarControl sideBar, Category category, IToolboxService toolboxService)
			: base(sideBar, category, toolboxService)
		{
		}
		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 = PascalABCCompiler.StringResources.Get(node.Attributes["name"].InnerText);//roman//
						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) {
				ICSharpCode.Core.LoggingService.Warn("ComponentLibraryLoader.LoadToolComponentLibrary: " + e.Message);
				return false;
			}
			return true;
		}
Ejemplo n.º 4
0
 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);
     }
 }
		public object Clone()
		{
			Category newCategory = new Category();
			newCategory.Name      = name;
			newCategory.IsEnabled = isEnabled;
			foreach (ToolComponent toolComponent in components) {
				newCategory.ToolComponents.Add(toolComponent.Clone());
			}
			return newCategory;
		}