private void 编辑类ToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView1.SelectedNode == null) { return; } if (treeView1.SelectedNode.Tag == null) { return; } if (!(treeView1.SelectedNode.Tag is NodeItem)) { return; } NodeItem nodeItem = treeView1.SelectedNode.Tag as NodeItem; NodeDefine nodeDefine = nodeItem.NodeDefine; EditNodeDefineForm editClassForm = new EditNodeDefineForm(this, nodeDefine, delegate() { nodeItem = m_NodeTreeViewManager.BindNodeDefine(nodeDefine); treeView1.SelectedNode = nodeItem.TreeNode; }); editClassForm.ShowDialog(); }
private void treeView1_MouseDown(object sender, MouseEventArgs e) { if (treeView1.SelectedNode == null) { return; } for (int i = 0; i < contextMenuStrip1.Items.Count; i++) { contextMenuStrip1.Items[i].Visible = false; } if (treeView1.SelectedNode.Tag is NodeTypeItem || treeView1.SelectedNode.Tag is CategoryItem) { contextMenuStrip1.Items[0].Visible = true; contextMenuStrip1.Items[3].Visible = true; } else if (treeView1.SelectedNode.Tag is NodeItem) { contextMenuStrip1.Items[1].Visible = true; contextMenuStrip1.Items[2].Visible = true; } if (e.Clicks == 2) { if (treeView1.SelectedNode == null) { return; } if (treeView1.SelectedNode.Tag == null) { return; } if (!(treeView1.SelectedNode.Tag is NodeItem)) { return; } NodeItem nodeItem = treeView1.SelectedNode.Tag as NodeItem; NodeDefine nodeDefine = nodeItem.NodeDefine; EditNodeDefineForm editClassForm = new EditNodeDefineForm(this, nodeDefine, delegate() { nodeItem = m_NodeTreeViewManager.BindNodeDefine(nodeDefine); treeView1.SelectedNode = nodeItem.TreeNode; }); editClassForm.ShowDialog(); } }