public void TreeBoxInit() { ToolBoxTabCollection tabCollection = new ToolBoxTabCollection(); //增加tab for (int i = 0; i < TabName.Count(); i++) { this.treeBox.AddTab(TabName[i], 1); ToolBoxTab tab = this.treeBox[i]; tabCollection.Add(tab); } treeView = new TreeView(); treeView.BorderStyle = BorderStyle.None; treeView.Dock = DockStyle.Fill; treeView.ImageList = imageList1; for (int i = 0; i < deType.Count(); i++) { FillTreeView(treeView, deType[i], i); this.treeBox[0].Control = treeView; } treeView1 = new TreeView(); treeView1.BorderStyle = BorderStyle.None; treeView1.Dock = DockStyle.Fill; treeView1.ImageList = imageList1; for (int i = 0; i < reType.Count(); i++) { FillTreeView(treeView1, reType[i], i); this.treeBox[1].Control = treeView1; } }
public void init() { this.ToolBox.TabMouseUp += new TabMouseEventHandler(ToolBox_TabMouseUp); //组件类型 ToolBoxTabCollection tabCollection = new ToolBoxTabCollection(); ToolBoxItemCollection itemCollection = new ToolBoxItemCollection(); for (int i = 0; i < CTabNameStrings.Count(); i++) { this.ToolBox.AddTab(CTabNameStrings[i], 1); ToolBoxTab tab = this.ToolBox[i]; tabCollection.Add(tab); } //自定义控件处理:xuehaouan 2016-4-13 -> string nodeString = "Components/AddedComponent";//注意这里AddedComponent作为与原先的区别 XmlNodeList tmpXNodeLst = mXDoc.SelectNodes(nodeString); XmlNode m_tmpXNode; IEnumerator tmpIe = tmpXNodeLst.GetEnumerator(); List <string> dllFailList = new List <string>(); while (tmpIe.MoveNext()) { m_tmpXNode = tmpIe.Current as XmlNode; string ModName = m_tmpXNode.Attributes["FullName"].Value; string AsmStr = m_tmpXNode.Attributes["Asm"].Value; Assembly assembly; Type type = null; if (AsmStr.Substring(AsmStr.Length - 3) == "dll" || AsmStr.Substring(AsmStr.Length - 3) == "DLL") { if (File.Exists(@dllmng.DLLPATH + AsmStr)) { assembly = Assembly.LoadFile(dllmng.DLLPATH + AsmStr); type = assembly.GetType(AsmStr.Substring(0, AsmStr.Length - 3) + ModName); //类名称 e.g. ACMV.Controls.PIDControlPanelWithDataConn } else { if (!dllFailList.Contains("Can not find DLL: " + AsmStr + " in file " + dllmng.DLLPATH)) { dllFailList.Add("Can not find DLL: " + AsmStr + " in file " + dllmng.DLLPATH); } //MessageBox.Show("Can not find" + AsmStr + " in file " + dllmng.DLLPATH, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (File.Exists(@dllmng.DLLPATH + AsmStr + ".dll")) { assembly = Assembly.LoadFile(dllmng.DLLPATH + AsmStr + ".dll"); type = assembly.GetType(AsmStr + "." + ModName); //类名称 e.g. ACMV.Controls.PIDControlPanelWithDataConn } else { if (!dllFailList.Contains("Can not find DLL: " + AsmStr + ".dll" + " in file " + dllmng.DLLPATH)) { dllFailList.Add("Can not find DLL: " + AsmStr + ".dll" + " in file " + dllmng.DLLPATH); } //MessageBox.Show("Can not find" + AsmStr + ".dll " + " in file " + dllmng.DLLPATH, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (type != null) { System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(type); tabCollection[tabCollection.Count - 1].AddItem(tbi.DisplayName, 2, true, tbi); } } string infoStr = ""; foreach (string dllFail in dllFailList) { infoStr += dllFail + "\r\n"; } if (infoStr != "") { MessageBox.Show(infoStr + "\r\n" + "Please Check!", "Custom Control(DLL) Error Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } //<- if (null != tabCollection) { for (int i = 0; i < moduleType.Count(); i++) { FillTreeView(bnTreeView, moduleType[i], i); tabCollection[0].Control = bnTreeView; } // } for (int i = 0; i < SubModuleTypes.Count(); i++) { System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(SubModuleTypes[i]); tabCollection[1].AddItem(tbi.DisplayName, 3, true, tbi); } } }