Beispiel #1
0
        private void NewFolderMenuItemHandler(object sender, EventArgs e)
        {
            Commands.CreateFolder createCommand = null;
            TreeNode newNode = null;

            if (ContextNode != null)
            {
                var tag     = ContextNode.Tag as NodeTag;
                var dirPath = tag.Path;
                if (tag.NodeType == NodeTag.Type.File)
                {
                    dirPath = System.IO.Path.GetDirectoryName(dirPath);
                }
                createCommand = new Commands.CreateFolder(dirPath);
                InvokeCommand(createCommand);
                UpdateNode(ContextNode);
                foreach (TreeNode node in ContextNode.Nodes)
                {
                    if ((node.Tag as NodeTag).Path == dirPath + "\\" + createCommand.NewFileName)
                    {
                        newNode = node;
                    }
                }
            }
            else
            {
                createCommand = new Commands.CreateFolder(Project.Path);
                InvokeCommand(createCommand);
                UpdateNode(null);
                foreach (TreeNode node in treeView.Nodes)
                {
                    if ((node.Tag as NodeTag).Path == Project.Path + "\\" + createCommand.NewFileName)
                    {
                        newNode = node;
                    }
                }
            }

            newNode.EnsureVisible();
            treeView.SelectedNode = newNode;
            newNode.BeginEdit();
        }
Beispiel #2
0
        private void newFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Commands.CreateFolder createCommand = null;
            TreeNode newNode = null;

            if (ContextNode != null)
            {
                var tag = ContextNode.Tag as NodeTag;
                createCommand = new Commands.CreateFolder(tag.Path);
                ControllerCommand(createCommand);
                UpdateNode(ContextNode);
                foreach (TreeNode node in ContextNode.Nodes)
                {
                    if ((node.Tag as NodeTag).Path == tag.Path + "\\" + createCommand.NewFileName)
                    {
                        newNode = node;
                    }
                }
            }
            else
            {
                createCommand = new Commands.CreateFolder(System.IO.Path.GetDirectoryName(Project.Path));
                ControllerCommand(createCommand);
                UpdateNode(null);
                foreach (TreeNode node in treeView.Nodes)
                {
                    if ((node.Tag as NodeTag).Path == System.IO.Path.GetDirectoryName(Project.Path) + "\\" + createCommand.NewFileName)
                    {
                        newNode = node;
                    }
                }
            }

            newNode.EnsureVisible();
            treeView.SelectedNode = newNode;
            newNode.BeginEdit();
        }