private void mainFrm_Load(object sender, EventArgs e) { DataManager.initDataManager(); AutoCompleteItemManager.load(); if (DataManager.settings.openedPersonas.Count > 0) { foreach (string personaPath in DataManager.settings.openedPersonas) { OpenPersonaIgnoreChecks(personaPath); } } foreach (string filePath in DataManager.settings.openedTabs) { OpenableFile file = findFileInTree(this.projectView.Nodes, filePath); if (file == null) { file = PersonaFile.CreateInstance(filePath); } openFileIgnoreChecks(file); } this.recentlyOpenedScriptsToolStripMenuItem.Entries = DataManager.settings.last10OpenedScripts; this.recentlyOpenedPersonalitiesToolStripMenuItem.Entries = DataManager.settings.last10OpenedPersonas; this.toolStripMakroBtnRecord.Enabled = false; this.toolStripMakroBtnExecute.Enabled = false; //TODO: enable in later version after implementation }
private void addAssociatedFile(PersonaFile file, TreeNode parentNode) { TreeNode node = new TreeNode(file.File.Name, 1, 1) { Tag = file }; parentNode.Nodes.Add(node); }
private void openScript_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = DataManager.settings.lastOpenedSingleFileDirectory; if (ofd.ShowDialog() == DialogResult.OK) { PersonaFile newFile = PersonaFile.CreateInstance(ofd.FileName); openFile(newFile); DataManager.settings.lastOpenedSingleFileDirectory = newFile.File.Directory.FullName; } }
public Folder(DirectoryInfo dir) { this.Directory = dir; foreach (DirectoryInfo subDir in this.Directory.GetDirectories()) { this.Folders.Add(subDir.Name, new Folder(subDir)); } foreach (FileInfo file in this.Directory.GetFiles()) { PersonaFile newFile = PersonaFile.CreateInstance(file); this.Files.Add(file.Name, newFile); } }
public frmMain() { InitializeComponent(); this.projectView.ImageList = DataManager.iconList; //this.renameToolStripMenuItem.Enabled = false; this.recentlyOpenedScriptsToolStripMenuItem.EntryClicked += (object sender, EventArgs e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; OpenableFile file = PersonaFile.CreateInstance(menuItem.Text); openFile(file); }; this.recentlyOpenedPersonalitiesToolStripMenuItem.EntryClicked += (object sender, EventArgs e) => { ToolStripMenuItem menuItem = (ToolStripMenuItem)sender; OpenPersona(menuItem.Text); }; }
private void newScriptToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = ((Folder)this.projectView.SelectedNode.Tag).Directory.FullName; if (sfd.ShowDialog() == DialogResult.OK) { PersonaFile file = PersonaFile.CreateInstance(sfd.FileName); file.Persona = ((Folder)this.projectView.SelectedNode.Tag)?.Persona; //if persona is set in parent folder set it to the new file too File.Create(file.File.FullName).Close(); this.addAssociatedFile(file, this.projectView.SelectedNode); openFile(file); } }
public static PersonaFile CreateInstance(string path) { return(PersonaFile.CreateInstance(new FileInfo(path))); }
private void projectView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e) { if (e.Label == null) //no rename occured { return; } if (e.Node.Tag is Folder) { TreeNode parentNode = e.Node.Parent; Folder renamedFolder = (Folder)this.projectView.SelectedNode.Tag; string parentDir = ((Folder)e.Node.Parent.Tag).Directory.FullName; string newFolderPath = parentDir + @"\" + e.Label; DirectoryInfo dirInfo = new DirectoryInfo(newFolderPath); if (dirInfo.Exists) { e.CancelEdit = true; e.Node.EndEdit(true); return; } e.Node.EndEdit(false); renamedFolder.Directory.MoveTo(newFolderPath); updateFolderChildrenPath(renamedFolder); } else if (e.Node.Tag is PersonaFile) { PersonaFile renamedFile = (PersonaFile)e.Node.Tag; string newFullName = ((Folder)e.Node.Parent.Tag).Directory.FullName + @"\" + e.Label; FileInfo fileInfo = new FileInfo(newFullName); if (fileInfo.Exists) { e.CancelEdit = true; e.Node.EndEdit(true); return; } e.Node.EndEdit(false); File.Move(renamedFile.File.FullName, newFullName); renamedFile.File = fileInfo; if (renamedFile.tab != null) { if (TabStripUtils.isTagFlaggedAsModified(renamedFile.tab)) { renamedFile.tab.Title = e.Label; TabStripUtils.flagTabAsModified(renamedFile.tab); } else { renamedFile.tab.Title = e.Label; } int index = DataManager.settings.openedTabs.IndexOf(renamedFile.File.FullName); if (index >= 0) { DataManager.settings.openedTabs[index] = newFullName; } } } this.projectView.Invalidate(); }