示例#1
0
        private void ToolStripMenuItem_Edit_Click(object sender, EventArgs e)
        {
            TreeNode       selectedNode = TreeView.SelectedNode;
            FrmInputDialog inputDialog;

            if (selectedNode.Tag == null)
            {
                inputDialog = new FrmInputDialog(selectedNode, TreeView);
            }
            else
            {
                Command dragNdropCmd;
                if (dragNdropPath != null)
                {
                    dragNdropCmd = new Command(selectedNode.Name, true, dragNdropPath, null);
                }
                else
                {
                    dragNdropCmd = new Command(selectedNode);
                }
                inputDialog = new FrmInputDialog(dragNdropCmd, TreeView);
            }

            Command cmd = InputCmd(CmdEditType.EDIT, ref inputDialog, selectedNode);

            if (cmd != null)
            {
                selectedNode.Name             = selectedNode.Text = cmd.Name;
                selectedNode.Tag              = cmd.ToDictionary();
                selectedNode.SelectedImageKey = selectedNode.ImageKey = SelectIcon(cmd.GetAbsolutePath(selectedNode));
                SaveTree(TreeView, cfgFileName);
            }
            dragNdropPath = null;
        }
示例#2
0
        private void ToolItem_Edit_Click(object sender, EventArgs e)
        {
            TreeNode       selectedNode = TreeView.SelectedNode;
            FrmInputDialog inputDialog;

            if (selectedNode.Tag == null)
            {
                inputDialog = new FrmInputDialog(new Command(selectedNode), TreeView);
            }
            else
            {
                Command dragNdropCmd = new Command(selectedNode);
                inputDialog = new FrmInputDialog(dragNdropCmd, TreeView);
            }
            Command cmd = OpenCmdDialog(CmdEditType.EDIT, ref inputDialog, selectedNode);

            if (cmd != null)
            {
                selectedNode.Name = selectedNode.Text = cmd.Name;
                selectedNode.Tag  = cmd.GetDictionary();
                string path = cmd.GetAbsolutePath();
                selectedNode.SelectedImageKey = selectedNode.ImageKey = SelectIcon(path);
                SaveTree(TreeView, cfgFileName);
            }
            dragNdropPath = null;
        }
示例#3
0
 private Command OpenCmdDialog(CmdEditType cmdEditType, ref FrmInputDialog inputDialog, TreeNode selectedNode)
 {
     while (inputDialog.ShowDialog() == DialogResult.OK)
     {
         Command cmd = inputDialog.GetCmdSet();
         if (ChkValidCmd(cmdEditType, selectedNode, cmd) == true)
         {
             return(SetProperRunState(cmd));
         }
     }
     return(null);
 }
示例#4
0
        private void ToolStripMenuItem_Add_Click(object sender, EventArgs e)
        {
            Point positionContextmunu = TreeView.PointToClient(contextMenuTreeView.Bounds.Location);
            //TreeNode NodeOver = TreeView.GetNodeAt(positionContextmunu);
            TreeNode       NodeOver = TreeView.SelectedNode;
            FrmInputDialog inputDialog;

            if (dragNdropPath != null)
            {
                Command cmdDragDrop = new Command(Path.GetFileNameWithoutExtension(dragNdropPath), true, dragNdropPath, null);
                inputDialog = new FrmInputDialog(cmdDragDrop, TreeView);
            }
            else
            {
                inputDialog = new FrmInputDialog(TreeView);
            }

            Command cmd = InputCmd(CmdEditType.ADD, ref inputDialog, NodeOver);

            if (cmd != null)
            {
                TreeNode newNode = cmd.ToTreeNode();

                if (NodeOver == null)
                {
                    TreeView.Nodes.Add(newNode);
                }
                else
                {
                    InsertCmd(TreeView, NodeOver, newNode, positionContextmunu.Y);
                    NodeOver.Expand();
                }

                newNode.SelectedImageKey = newNode.ImageKey = SelectIcon(cmd.GetAbsolutePath(NodeOver));
                SaveTree(TreeView, cfgFileName);
            }
            dragNdropPath = null;
        }
示例#5
0
        private void OpenDialog_NodeAdd(Point positionInTreeView)
        {
            TreeNode       NodeOver = TreeView.SelectedNode;
            FrmInputDialog inputDialog;

            if (dragNdropPath != null)
            {
                Command cmdDragDrop = new Command(Path.GetFileNameWithoutExtension(dragNdropPath), true, dragNdropPath, null);
                inputDialog = new FrmInputDialog(cmdDragDrop, TreeView);
            }
            else
            {
                inputDialog = new FrmInputDialog(TreeView);
            }

            Command cmd = OpenCmdDialog(CmdEditType.ADD, ref inputDialog, NodeOver);

            if (cmd != null)
            {
                TreeNode newNode = cmd.GetTreeNode();

                if (NodeOver == null)
                {
                    TreeView.Nodes.Add(newNode);
                }
                else
                {
                    InsertCmd(TreeView, NodeOver, newNode, positionInTreeView.Y);
                    NodeOver.Expand();
                }

                newNode.SelectedImageKey = newNode.ImageKey = SelectIcon(cmd.GetAbsolutePath());
                SaveTree(TreeView, cfgFileName);
            }
            dragNdropPath = null;
        }