/// <summary> /// Add New File /// </summary> private void AddNewFile() { try { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) { return; } var file = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, file, ProjectNodeType.File); File.WriteAllText(file, ""); projtree.SelectedNode.Nodes.Add(node); } } } catch (Exception ex) { MessageBox.Show("There was an Error : " + ex.Message, "Project Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
/// <summary> /// Adds a New Folder to existing folder /// </summary> private void AddNewFolder() { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) { return; } var dir = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, dir, ProjectNodeType.Folder); Directory.CreateDirectory(dir); projtree.SelectedNode.Nodes.Add(node); } } }
/// <summary> /// DoRename /// </summary> private void DoRename() { var node = projtree.SelectedNode as ExTreeNode; var filename = projtree.SelectedNode.Name; var dir = Path.GetDirectoryName(projtree.SelectedNode.Name); using (var dlg = new FolderUtils()) { var result = dlg.ShowDialog() == DialogResult.OK; if (result) { if (node.Type == ProjectNodeType.Folder) { RenameDirectory(filename, dir + @"\" + dlg.FileName, node); } else if (node.Type == ProjectNodeType.File) { RenameFile(filename, dir + @"\" + dlg.FileName, node); } node.Text = dlg.FileName; } } }
/// <summary> /// DoRename /// </summary> private void DoRename() { var node = projtree.SelectedNode as ExTreeNode; var filename = projtree.SelectedNode.Name; var dir = Path.GetDirectoryName(projtree.SelectedNode.Name); using (var dlg = new FolderUtils()) { var result = dlg.ShowDialog() == DialogResult.OK; if (result) { if (node.Type == ProjectNodeType.Folder) RenameDirectory(filename, dir + @"\" + dlg.FileName, node); else if (node.Type == ProjectNodeType.File) RenameFile(filename, dir + @"\" + dlg.FileName, node); node.Text = dlg.FileName; } } }
/// <summary> /// Adds a New Folder to existing folder /// </summary> private void AddNewFolder() { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) return; var dir = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, dir, ProjectNodeType.Folder); Directory.CreateDirectory(dir); projtree.SelectedNode.Nodes.Add(node); } } }
/// <summary> /// Add New File /// </summary> private void AddNewFile() { try { var path = projtree.SelectedNode as ExTreeNode; if (path != null && path.Type == ProjectNodeType.Folder) { using (var util = new FolderUtils()) { if (util.ShowDialog(this) != DialogResult.OK) return; var file = Path.Combine(path.Name, util.FileName); var node = new ExTreeNode(util.FileName, file, ProjectNodeType.File); File.WriteAllText(file, ""); projtree.SelectedNode.Nodes.Add(node); } } } catch (Exception ex) { MessageBox.Show("There was an Error : " + ex.Message, "Project Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }