private void 添加模块ToolStripMenuItem_Click(object sender, EventArgs e) { string parentID = ""; if (selectedNode != null) { if (selectedNode.TagType == NodeSelectTag.TAGTYPE.Classisication) { parentID = (selectedNode.Model as ProtocolClassificationModel).PCID; } } if (ProtocolDB.GetClassificationCount() > 9) { MessageBox.Show("至多只能有9个模块"); return; } EditClassificationModel editClassification = new EditClassificationModel(parentID); if (editClassification.ShowDialog() == DialogResult.OK) { var result = editClassification.ResultModel; TreeNode node = new TreeNode(); node.Text = $"[模块]{result.PCName}"; node.Tag = new NodeSelectTag() { Model = result, TagType = NodeSelectTag.TAGTYPE.Classisication, Target = node }; if (string.IsNullOrEmpty(parentID)) { myTree.Nodes.Add(node); } else { if (selectedNode.Target != null) { selectedNode.Target.Nodes.Add(node); } } myTree.SelectedNode = node; selectedNode = node.Tag as NodeSelectTag; myTree.Refresh(); } }
private void myTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { selectedNode = e.Node.Tag as NodeSelectTag; if (selectedNode == null) { return; } if (selectedNode.TagType == NodeSelectTag.TAGTYPE.Classisication) { EditClassificationModel editClassification = new EditClassificationModel(selectedNode.Model as ProtocolClassificationModel); if (editClassification.ShowDialog() == DialogResult.OK) { var result = editClassification.ResultModel; selectedNode.Target.Text = result.PCName; selectedNode.Model = result; myTree.Refresh(); } } }