public void createControler(string defaultPLCType) { dataManage.newControlerFlag = true; localPLCType_ = defaultPLCType; LocalPLC.Base.xml.ClassParseBaseXml ttt = new ClassParseBaseXml(localPLCType_, dataManage); var topNode = treeView_.TopNode; var commNode = FindNode(topNode, "通信线路"); delSubNodes(commNode); addSerialNode(commNode); createSerialUserControl(); createEthernetUserControl(); topNode.Text = localPLCType_; string tmp = string.Format("LocalPLC.Base.{0}", localPLCType_); Type type = Type.GetType(/*"LocalPLC.Base.PlcType"*/ tmp); //object obj = type.Assembly.CreateInstance(type); UserControl user1 = (UserControl)Activator.CreateInstance(type, splitContainer2, this, dataManage); //PlcType user1 = new PlcType(splitContainer2, this, dataManage); curPlcType = (LocalPLC24P)user1; curWeaponType = user1 as IWeapon; user1.Parent = this; PlcTypeArr.Add(user1); splitContainer2.Panel1.Controls.Add(user1); user1.Location = new System.Drawing.Point(PlcTypeArr.Count * user1.Width, 0); user1.Name = defaultPLCType; //user1.Dock = DockStyle.Fill; //user1.Size = new System.Drawing.Size(41, 12); user1.TabIndex = 0; }
private void splitContainer1_Panel1_DragDrop(object sender, DragEventArgs e) { if (!LocalPLC.UserControl1.multiprogApp.IsProjectOpen()) { MessageBox.Show("请先打开工程!"); return; } dataManage.newControlerFlag = true; object item = e.Data.GetData("Test"); foreach (Control control in splitContainer2.Panel1.Controls) { if (control.Tag.ToString() == 0.ToString()) { splitContainer2.Panel1.Controls.Remove(control); PlcTypeArr.Clear(); } } TreeNode node = (TreeNode)item; string localPLCType = node.Text.ToString(); LocalPLC.Base.xml.ClassParseBaseXml ttt = new ClassParseBaseXml(localPLCType, dataManage); var topNode = treeView_.TopNode; var commNode = FindNode(topNode, "通信线路"); delSubNodes(commNode); addSerialNode(commNode); createSerialUserControl(); createEthernetUserControl(); topNode.Text = localPLCType; string tmp = string.Format("LocalPLC.Base.{0}", localPLCType); Type type = Type.GetType(/*"LocalPLC.Base.PlcType"*/ tmp); if (type == null) { return; } //object obj = type.Assembly.CreateInstance(type); UserControl user1 = (UserControl)Activator.CreateInstance(type, splitContainer2, this, dataManage); //PlcType user1 = new PlcType(splitContainer2, this, dataManage); curPlcType = (LocalPLC24P)user1; curWeaponType = user1 as IWeapon; user1.Parent = this; PlcTypeArr.Add(user1); splitContainer2.Panel1.Controls.Add(user1); user1.Location = new System.Drawing.Point(PlcTypeArr.Count * user1.Width, 0); user1.Name = node.Name; //user1.Dock = DockStyle.Fill; //user1.Size = new System.Drawing.Size(41, 12); user1.TabIndex = 0; }