private ToolboxTabCollection PopulateToolboxTabs() { ToolboxTabCollection toolboxTabs = new ToolboxTabCollection(); string[] tabNames = { Strings.WindowsForms, Strings.Components, Strings.Data, Strings.Data1 }; for (int i = 0; i < tabNames.Length; i++) { ToolboxTab toolboxTab = new ToolboxTab(); toolboxTab.Name = tabNames[i]; PopulateToolboxItems(toolboxTab); toolboxTabs.Add(toolboxTab); } return(toolboxTabs); }
private ToolboxTabCollection PopulateToolboxTabs(XmlDocument xmlDocument) { if (xmlDocument == null) { return(null); } XmlNode toolboxNode = xmlDocument.FirstChild; if (toolboxNode == null) { return(null); } XmlNode tabCollectionNode = toolboxNode.FirstChild; if (tabCollectionNode == null) { return(null); } XmlNodeList tabsNodeList = tabCollectionNode.ChildNodes; if (tabsNodeList == null) { return(null); } ToolboxTabCollection toolboxTabs = new ToolboxTabCollection(); foreach (XmlNode tabNode in tabsNodeList) { if (tabNode == null) { continue; } XmlNode propertiesNode = tabNode.FirstChild; if (propertiesNode == null) { continue; } XmlNode nameNode = propertiesNode[Strings.Name]; if (nameNode == null) { continue; } ToolboxTab toolboxTab = new ToolboxTab(); toolboxTab.Name = nameNode.InnerXml.ToString(); PopulateToolboxItems(tabNode, toolboxTab); toolboxTabs.Add(toolboxTab); } if (toolboxTabs.Count == 0) { return(null); } return(toolboxTabs); }
// 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; // 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 ToolboxTabCollection PopulateToolboxTabs(XmlDocument xmlDocument) { if(xmlDocument==null) return null; XmlNode toolboxNode = xmlDocument.FirstChild; if(toolboxNode==null) return null; XmlNode tabCollectionNode = toolboxNode.FirstChild; if(tabCollectionNode==null) return null; XmlNodeList tabsNodeList = tabCollectionNode.ChildNodes; if(tabsNodeList==null) return null; ToolboxTabCollection toolboxTabs = new ToolboxTabCollection(); foreach(XmlNode tabNode in tabsNodeList) { if(tabNode==null) continue; XmlNode propertiesNode = tabNode.FirstChild; if(propertiesNode==null) continue; XmlNode nameNode = propertiesNode[Strings.Name]; if(nameNode==null) continue; ToolboxTab toolboxTab = new ToolboxTab(); toolboxTab.Name = nameNode.InnerXml.ToString(); PopulateToolboxItems(tabNode, toolboxTab); toolboxTabs.Add(toolboxTab); } if(toolboxTabs.Count==0) return null; return toolboxTabs; }