public void ResyncFile(Dialogue dialogue, bool focus)
        {
            if (dialogue == null)
            {
                return;
            }

            if (dialogue.Package == null)
            {
                EditorCore.LogError("Unable to show a Dialogue without Package in project explorer : " + dialogue.GetName());
                return;
            }

            TreeNode[] nodePackages = tree.Nodes.Find(GetPackageKey(dialogue.Package.Name), false);
            if (nodePackages.Count() > 0)
            {
                TreeNode nodeParent = nodePackages[0];

                string   path       = dialogue.GetFilePath();
                string[] folders    = path.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                string   folderPath = "";
                foreach (string folder in folders)
                {
                    folderPath = Path.Combine(folderPath, folder);

                    TreeNode[] nodeFolders = nodeParent.Nodes.Find(folder, false);
                    if (nodeFolders.Count() > 0)
                    {
                        nodeParent = nodeFolders[0];
                    }
                    else
                    {
                        nodeParent     = nodeParent.Nodes.Add(folder, folder);
                        nodeParent.Tag = new Folder()
                        {
                            Path = folderPath
                        };
                        nodeParent.ContextMenuStrip = menuFolder;
                        EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder);
                    }
                }

                TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName());
                nodeDialogue.ContextMenuStrip = menuDocument;
                EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue);

                nodeDialogue.Tag = dialogue;

                if (focus)
                {
                    nodeDialogue.EnsureVisible();
                }
            }
            else
            {
                EditorCore.LogError("Unable to show a Dialogue with unknown Package in project explorer : " + dialogue.GetName() + " in " + dialogue.Package.Name);
            }
        }
        private void OnDocumentOpenDirectory(object sender, EventArgs e)
        {
            Dialogue dialogue = tree.SelectedNode.Tag as Dialogue;

            if (dialogue != null)
            {
                Process.Start(Path.Combine(EditorHelper.GetProjectDirectory(), dialogue.GetFilePath()));
            }
        }
        static private bool AddDialogue(Dialogue dialogue)
        {
            string name = dialogue.GetName();

            if (CheckDialogueNameAvailable(dialogue.GetFilePath(), name, true))
            {
                dialogues.Add(name, new ResourceHolder {
                    Dialogue = dialogue
                });
                return(true);
            }

            return(false);
        }
        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 bool AddDialogue(Dialogue dialogue)
        {
            string name = dialogue.GetName();

            if (!dialogues.ContainsKey(name))
            {
                dialogues.Add(name, new ResourceHolder {
                    Dialogue = dialogue
                });
                return(true);
            }

            EditorCore.LogError("Dialogue already exists (ignored) : " + name + " at \"" + dialogue.GetFilePath() + "\" and \"" + dialogues[name].Dialogue.GetFilePath() + "\"");
            return(false);
        }