Пример #1
0
        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;
            NodeClass nodeClass = nodeItem.NodeClass;

            EditClassForm editClassForm = new EditClassForm(this, nodeClass, delegate()
            {
                nodeItem = m_NodeTreeViewManager.BindNodeClass(nodeClass);
                treeView1.SelectedNode = nodeItem.TreeNode;
            });

            editClassForm.ShowDialog();
        }
Пример #2
0
        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;
                NodeClass nodeClass = nodeItem.NodeClass;


                EditClassForm editClassForm = new EditClassForm(this, nodeClass, delegate()
                {
                    nodeItem = m_NodeTreeViewManager.BindNodeClass(nodeClass);
                    treeView1.SelectedNode = nodeItem.TreeNode;
                });
                editClassForm.ShowDialog();
            }
        }