public bool insertFunction(TreeIndex index, String name) { if (name == "") { return(false); } if (index.type != IndexTypes.Page && index.type != IndexTypes.Folder) { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } FuncParser parser = new FuncParser(index.path); parser[name] = $@" ### Function **{name}**() "; parser.reSave(); tree.addNode(index.tree_path, name, IndexTypes.Function, index.path); editor.openFile(index.path, name, IndexTypes.Function); return(false); } else { return(true); } }
public bool deleteNode(TreeIndex index, String name) { editor.closeFile(); switch (index.type) { case IndexTypes.Class: { File.Delete(index.path); tree.removeNode(index); break; } case IndexTypes.Page: { File.Delete(index.path); tree.removeNode(index); break; } case IndexTypes.Module: { String bpath; if (index.type == IndexTypes.Module) { bpath = Path.GetDirectoryName(index.path); } else { bpath = index.path; } System.IO.DirectoryInfo di = new DirectoryInfo(bpath); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } di.Delete(); tree.removeNode(index); break; } case IndexTypes.Folder: { System.IO.DirectoryInfo di = new DirectoryInfo(index.path); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } foreach (DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } di.Delete(); tree.removeNode(index); break; } case IndexTypes.Function: { FuncParser parser = new FuncParser(index.path); parser.functions.Remove(index.label); parser.reSave(); tree.removeNode(index); break; } } return(false); }