private void OnFolderNewDialogue(object sender, EventArgs e) { Folder folder = tree.SelectedNode.Tag as Folder; if (folder != null) { var root = tree.SelectedNode.GetRootNode(); Package package = root.Tag as Package; if (package != null) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Create Dialogue"; dialog.Filter = "Dialogue Files|*" + Dialogue.GetExtension(); dialog.InitialDirectory = Path.Combine(EditorHelper.GetProjectDirectory(), folder.Path); DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { Dialogue newDialogue = ResourcesHandler.CreateDialogueFile(dialog.FileName, package); if (newDialogue != null) { ResyncFile(newDialogue, true); EditorCore.MainWindow.OpenDocumentDialogue(newDialogue); } } } } }
private void OnNewDialogue(object sender, EventArgs e) { if (ResourcesHandler.Project == null) { return; } string projectDirectory = EditorHelper.GetProjectDirectory(); SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Create Dialogue"; dialog.Filter = "Dialogue Files|*" + Dialogue.GetExtension(); dialog.InitialDirectory = projectDirectory; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { Dialogue newDialogue = ResourcesHandler.CreateDialogueFile(dialog.FileName); if (newDialogue != null) { EditorCore.ProjectExplorer.ResyncFile(newDialogue, true); OpenDocumentDialogue(newDialogue); } } }
private void OnDocumentRename(object sender, EventArgs e) { Dialogue dialogue = tree.SelectedNode.Tag as Dialogue; if (dialogue != null) { bool proceed = false; if (EditorCore.MainWindow != null) { proceed = EditorCore.MainWindow.TryToReloadOrSaveDialogueIfDirty(dialogue); } if (proceed) { SaveFileDialog dialog = new SaveFileDialog(); dialog.Title = "Rename Dialogue"; dialog.Filter = "Dialogue Files|*" + Dialogue.GetExtension(); dialog.InitialDirectory = Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePath()); DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { if (EditorCore.MainWindow != null) { EditorCore.MainWindow.CloseDocumentDialogue(dialogue, true); } TreeNode nodeFolder = tree.SelectedNode.Parent; tree.Nodes.Remove(tree.SelectedNode); tree.SelectedNode = null; DeleteIfEmptyFolder(nodeFolder); ResourcesHandler.RenameDialogueFile(dialogue, dialog.FileName); ResyncFile(dialogue, true); if (EditorCore.MainWindow != null) { EditorCore.MainWindow.OpenDocumentDialogue(dialogue); } } } } }
static public void ParseDirectory(System.IO.DirectoryInfo root) { System.IO.FileInfo[] files = null; System.IO.DirectoryInfo[] subDirs = null; try { files = root.GetFiles("*.*"); } catch (UnauthorizedAccessException e) { Console.WriteLine(e.Message); } catch (System.IO.DirectoryNotFoundException e) { Console.WriteLine(e.Message); } if (files != null) { string projectDirectory = Path.Combine(System.Environment.CurrentDirectory, Project.GetFilePath()); foreach (System.IO.FileInfo fi in files) { if (fi.Extension == Dialogue.GetExtension()) { string filePath = Utility.GetRelativePath(fi.FullName, projectDirectory); Dialogue dialogue = new Dialogue(); dialogue.Init(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath)); AddDialogue(dialogue); } } subDirs = root.GetDirectories(); foreach (System.IO.DirectoryInfo dirInfo in subDirs) { ParseDirectory(dirInfo); } } }