private void 添加子事件ToolStripMenuItem_Click(object sender, EventArgs e) { var node = treeViewRoot.SelectedNode; if (node.Level < 4) { MessageBox.Show("不能在这里添加子事件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FormAddCode addform = new FormAddCode(); if (addform.ShowDialog() == DialogResult.OK) { if (addform.m_select < 4) { MessageBox.Show("code 0,1,2,3不能被手动添加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ScriptSection sec = (ScriptSection)getLeve2Nodes(node).Tag; ScriptCommand newCmd = (ScriptCommand)node.Parent.Tag; newCmd.extValue = 2; sec.addCode(0, newCmd); sec.addCode(addform.m_select, newCmd, true); sec.addCode(1, newCmd); buildTreeView(scriptRoot[m_cur_index]); } }
private void 添加ToolStripMenuItem_Click(object sender, EventArgs e) { if (treeViewRoot.SelectedNode.Level == 1) { scriptRoot[m_cur_index].addScene((ScriptScene)treeViewRoot.SelectedNode.Tag); } else if (treeViewRoot.SelectedNode.Level == 2) { ScriptScene scene = (ScriptScene)treeViewRoot.SelectedNode.Parent.Tag; scene.addSection((ScriptSection)treeViewRoot.SelectedNode.Tag); } else if (treeViewRoot.SelectedNode.Level == 3) { MessageBox.Show("不能在此处添加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (treeViewRoot.SelectedNode.Level > 3) { FormAddCode addform = new FormAddCode(0, selectIndex); if (addform.ShowDialog() == DialogResult.OK) { selectIndex = addform.m_select + 1; if (addform.m_select < 4) { MessageBox.Show("code 0,1,2,3不能被手动添加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ScriptSection sec = (ScriptSection)getLeve2Nodes(treeViewRoot.SelectedNode).Tag; sec.addCode(addform.m_select, (ScriptCommand)treeViewRoot.SelectedNode.Parent.Tag); } } buildTreeView(scriptRoot[m_cur_index]); }
void CopyNode(ScriptSection sec, TreeNode node, int level = 1) { ScriptCommand copy_cmd = new ScriptCommand(); foreach (TreeNode eachNode in node.Nodes) { if (eachNode.Index == 0) { copy_cmd = (ScriptCommand)eachNode.Parent.Tag; sec.addCode(copy_cmd.id, (ScriptCommand)eachNode.Parent.Tag, true); sec.addCode(0, copy_cmd); } else { copy_cmd = (ScriptCommand)eachNode.Tag; sec.addCode(copy_cmd.id, (ScriptCommand)eachNode.Parent.Tag); } if (eachNode.Nodes.Count > 0) { CopyNode(sec, eachNode); } } }
private void 粘帖ToolStripMenuItem_Click(object sender, EventArgs e) { if (copyNode != null && treeViewRoot.SelectedNode != null) { if (copyNode.Level != treeViewRoot.SelectedNode.Level) { if (cutNodeParent != null && cutNodeParent.Level != treeViewRoot.SelectedNode.Parent.Level) { MessageBox.Show("粘贴目录不匹配", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (isCut) { cutNodeParent.Nodes.Add(copyNode); } if (treeViewRoot.SelectedNode.Level == 1) { ScriptScene scene = scriptRoot[m_cur_index].addScene((ScriptScene)copyNode.Tag); scene.SectionList = ((ScriptScene)copyNode.Tag).SectionList; } else if (treeViewRoot.SelectedNode.Level == 2) { ScriptScene scene = (ScriptScene)(copyNode.Parent != null ? copyNode.Parent.Tag : cutNodeParent.Tag); ScriptSection section = scene.addSection((ScriptSection)copyNode.Tag); section.CommandList = ((ScriptSection)copyNode.Tag).CommandList; } else if (treeViewRoot.SelectedNode.Level == 3) { MessageBox.Show("不能在此处复制", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (treeViewRoot.SelectedNode.Level > 3) { ScriptCommand copy_cmd = (ScriptCommand)copyNode.Tag; if (copy_cmd.id != 0) { ScriptSection sec = (ScriptSection)getLeve2Nodes(copyNode).Tag; if (copyNode.Nodes.Count > 0) { //sec.addCode(copy_cmd.id, (ScriptCommand)copyNode.Parent.Tag, true); CopyNode(sec, copyNode); } else { sec.addCode(copy_cmd.id, (ScriptCommand)copyNode.Tag); } //int copy_index = sec.FindCommand((ScriptCommand)copyNode.Parent.Tag); //int index = sec.addCode(copy_cmd.id, (ScriptCommand)copyNode.Parent.Tag, copy_cmd.isExtValueAvailable()); //sec.CommandList[index] = sec.CommandList[copy_index]; } else { MessageBox.Show("code 0,1,2,3不能被手动添加", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } buildTreeView(scriptRoot[m_cur_index]); } }