Exemplo n.º 1
0
        private void btnEditCommand_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }

            XmlCommandItem command = treeView1.SelectedNode.GetCommamd();

            if (command == null)
            {
                return;
            }


            EditCommandDialog dlg = new EditCommandDialog();

            dlg.Command = command;
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            command = dlg.Command;
            treeView1.SelectedNode.SetCommand(command);
            treeView1.SelectedNode.Text = command.CommandName;

            _changed = true;

            treeView1_AfterSelect(null, null);
        }
Exemplo n.º 2
0
        private void btnAddCommand_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeView1.SelectedNode;

            if (selectedNode == null)
            {
                return;
            }

            TreeNode root = (selectedNode.IsFileNode() ? selectedNode : selectedNode.Parent);

            EditCommandDialog dlg = new EditCommandDialog();

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            XmlCommandItem command = dlg.Command;
            TreeNode       node    = new TreeNode(command.CommandName, Icon_CommandItem, Icon_CommandItem2);

            node.SetCommand(command);

            root.Nodes.Add(node);
            treeView1.SelectedNode = node;
            node.EnsureVisible();

            SetChangedAndRefreshUIAndTreeFocus();
        }