private void PopulateToolboxItems(XmlNode tabNode, ToolboxTab toolboxTab)
        {
            if (tabNode == null)
            {
                return;
            }

            XmlNode toolboxItemCollectionNode = tabNode[Strings.ToolboxItemCollection];

            if (toolboxItemCollectionNode == null)
            {
                return;
            }

            XmlNodeList toolboxItemNodeList = toolboxItemCollectionNode.ChildNodes;

            if (toolboxItemNodeList == null)
            {
                return;
            }

            ToolboxItemCollection toolboxItems = new ToolboxItemCollection();

            foreach (XmlNode toolboxItemNode in toolboxItemNodeList)
            {
                if (toolboxItemNode == null)
                {
                    continue;
                }

                XmlNode typeNode = toolboxItemNode[Strings.Type];
                if (typeNode == null)
                {
                    continue;
                }

                bool found = false;
                System.Reflection.Assembly[] loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
                for (int i = 0; i < loadedAssemblies.Length && !found; i++)
                {
                    System.Reflection.Assembly assembly = loadedAssemblies[i];
                    System.Type[] types = assembly.GetTypes();
                    for (int j = 0; j < types.Length && !found; j++)
                    {
                        System.Type type = types[j];
                        if (type.FullName == typeNode.InnerXml.ToString())
                        {
                            ToolboxItem toolboxItem = new ToolboxItem();
                            toolboxItem.Type = type;
                            toolboxItems.Add(toolboxItem);
                            found = true;
                        }
                    }
                }
            }
            toolboxTab.ToolboxItems = toolboxItems;
            return;
        }
        private void PopulateToolboxItems(ToolboxTab toolboxTab)
        {
            if (toolboxTab == null)
            {
                return;
            }

            Type[] typeArray = null;

            switch (toolboxTab.Name)
            {
            case Strings.WindowsForms:
                typeArray = windowsFormsToolTypes;
                break;

            case Strings.Components:
                typeArray = componentsToolTypes;
                break;

            case Strings.Data:
                typeArray = dataToolTypes;
                break;

            case Strings.UserControls:
                typeArray = userControlsToolTypes;
                break;

            case Strings.RibbonControls:
                typeArray = ribbonControlsToolTypes;
                break;

            default:
                break;
            }

            ToolboxItemCollection toolboxItems = new ToolboxItemCollection();

            for (int i = 0; i < typeArray.Length; i++)
            {
                ToolboxItem toolboxItem = new ToolboxItem();

                toolboxItem.Type = typeArray[i];
                toolboxItem.Name = typeArray[i].Name;
                toolboxItems.Add(toolboxItem);
            }

            toolboxTab.ToolboxItems = toolboxItems;
        }
		private void PopulateToolboxItems(XmlNode tabNode, ToolboxTab toolboxTab)
		{
			if(tabNode==null)
				return;

			XmlNode toolboxItemCollectionNode = tabNode[Strings.ToolboxItemCollection];
			if(toolboxItemCollectionNode==null)
				return;

			XmlNodeList toolboxItemNodeList = toolboxItemCollectionNode.ChildNodes;
			if(toolboxItemNodeList==null)
				return;

			ToolboxItemCollection toolboxItems = new ToolboxItemCollection();

			foreach(XmlNode toolboxItemNode in toolboxItemNodeList)
			{
				if(toolboxItemNode==null)
					continue;

				XmlNode typeNode = toolboxItemNode[Strings.Type];
				if(typeNode==null)
					continue;

				bool found = false;
				System.Reflection.Assembly[] loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
				for(int i=0; i<loadedAssemblies.Length && !found;i++)
				{
					System.Reflection.Assembly assembly = loadedAssemblies[i];
					System.Type[] types = assembly.GetTypes();
					for(int j=0;j<types.Length && !found;j++)
					{
						System.Type type = types[j];
						if(type.FullName == typeNode.InnerXml.ToString()) 
						{
							ToolboxItem toolboxItem = new ToolboxItem();
							toolboxItem.Type = type;
							toolboxItems.Add(toolboxItem);
							found = true;
						}
					}
				}
			}
			toolboxTab.ToolboxItems = toolboxItems;
			return;
		}
Esempio n. 4
0
        public void AddTab(string tabName, Type[] types)
        {            
            if (Tabs == null) Tabs = new ToolboxTabCollection();
           
            ToolboxTab toolboxTab = new ToolboxTab();
            toolboxTab.Name = tabName;

            ToolboxItemCollection toolboxItems = new ToolboxItemCollection();

            for (int i = 0; i < types.Length; i++)
            {
                ToolboxItem toolboxItem = new ToolboxItem();

                toolboxItem.Type = types[i];
                toolboxItem.Name = types[i].Name;
                toolboxItems.Add(toolboxItem);
            }
            toolboxItems.SortByName();

            toolboxTab.ToolboxItems = toolboxItems;
            
            Tabs.Add(toolboxTab);

            ToolboxUIManagerVS toolboxUIManagerVS = new ToolboxUIManagerVS(this);
            toolboxUIManagerVS.FillToolbox();

            AddEventHandlers();
            //PrintToolbox();
        }