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 AddTreeNodeFlag(NodeFlag flag)
        {
            TreeNode treeNodeAttribute = treeNodeRootFlags.Nodes.Add(flag.GetTreeText());

            treeNodeAttribute.ContextMenuStrip = menuAttributes;
            treeNodeAttribute.Tag = flag;
            EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.ListItemFlag);

            treeNodeRootFlags.ExpandAll();
        }
        private void AddTreeNodeAction(NodeAction action)
        {
            TreeNode treeNodeAttribute = treeNodeRootActions.Nodes.Add(action.GetTreeText());

            treeNodeAttribute.ContextMenuStrip = menuAttributes;
            treeNodeAttribute.Tag = action;
            EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.ListItemAction);

            treeNodeRootActions.ExpandAll();
        }
        private void AddTreeNodeCondition(NodeCondition condition, TreeNode parent)
        {
            TreeNode treeNodeAttribute = parent.Nodes.Add(condition.GetTreeText());

            treeNodeAttribute.ContextMenuStrip = menuAttributes;
            treeNodeAttribute.Tag = condition;

            if (condition is NodeConditionGroup)
            {
                EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.ListItemConditionGroup);

                foreach (NodeCondition subCondition in ((NodeConditionGroup)condition).Conditions)
                {
                    AddTreeNodeCondition(subCondition, treeNodeAttribute);
                }
            }
            else
            {
                EditorHelper.SetNodeIcon(treeNodeAttribute, ENodeIcon.ListItemCondition);
            }

            parent.ExpandAll();
        }
        public void ResyncAllFiles()
        {
            Clear();

            Project project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            if (EditorCore.CustomLists["SceneTypes"].Count > 0)
            {
                var sceneTypes = new Dictionary <string, string>();
                sceneTypes.Add("", "");
                foreach (var kvp in EditorCore.CustomLists["SceneTypes"])
                {
                    sceneTypes.Add(kvp.Key, kvp.Value);
                }

                comboBoxSearchSceneType.DataSource    = new BindingSource(sceneTypes, null);
                comboBoxSearchSceneType.ValueMember   = "Key";
                comboBoxSearchSceneType.DisplayMember = "Value";

                comboBoxSearchSceneType.Enabled = true;
            }

            if (project.ListActors.Count > 0)
            {
                var actors = new Dictionary <string, string>();
                actors.Add("", "");
                foreach (var actor in project.ListActors)
                {
                    actors.Add(actor.ID, actor.Name);
                }

                comboBoxSearchActor.DataSource    = new BindingSource(actors, null);
                comboBoxSearchActor.ValueMember   = "Key";
                comboBoxSearchActor.DisplayMember = "Value";

                comboBoxSearchActor.Enabled = true;
            }

            tree.BeginUpdate();

            TreeNode nodeProject = tree.Nodes.Add("Project", String.Format("Project {0}", project.GetName()));

            nodeProject.Tag = project;
            EditorHelper.SetNodeIcon(nodeProject, ENodeIcon.Project);

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = tree.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                nodePackage.ContextMenuStrip = menuPackage;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                ResyncFile(dialogue, false);
            }

            tree.EndUpdate();

            //tree.CollapseAll();
            foreach (TreeNode node in tree.Nodes)
            {
                node.Expand();
            }
        }
        private void populateDialogueTreeView(List <Dialogue> inCheckedDialogues)
        {
            var project = ResourcesHandler.Project;

            if (project == null)
            {
                return;
            }

            dialogueTreeView.BeginUpdate();

            foreach (Package package in project.ListPackages)
            {
                TreeNode nodePackage = dialogueTreeView.Nodes.Add(GetPackageKey(package.Name), package.Name);
                nodePackage.Tag = package;
                EditorHelper.SetNodeIcon(nodePackage, ENodeIcon.Package);
            }

            foreach (Dialogue dialogue in ResourcesHandler.GetAllDialogues())
            {
                if (dialogue == null)
                {
                    continue;
                }

                if (dialogue.Package == null)
                {
                    continue;
                }

                TreeNode[] nodePackages = dialogueTreeView.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
                            };
                            EditorHelper.SetNodeIcon(nodeParent, ENodeIcon.Folder);
                        }
                    }

                    TreeNode nodeDialogue = nodeParent.Nodes.Add(dialogue.GetFileName(), dialogue.GetName());
                    nodeDialogue.Checked = checkedDialogues.Contains(dialogue);
                    nodeDialogue.Tag     = dialogue;
                    EditorHelper.SetNodeIcon(nodeDialogue, ENodeIcon.Dialogue);
                }
            }

            dialogueTreeView.EndUpdate();

            foreach (TreeNode node in dialogueTreeView.Nodes)
            {
                node.Expand();
            }
        }
        public void Init(DocumentDialogue inDocument, TreeNode inTreeNode, DialogueNode inDialogueNode)
        {
            document     = inDocument;
            treeNode     = inTreeNode;
            dialogueNode = inDialogueNode;

            treeAttributes.ImageList = EditorCore.DefaultImageList;

            //Roots
            treeNodeRootConditions = treeAttributes.Nodes.Add("Root", "Conditions");
            treeNodeRootConditions.ContextMenuStrip = menuAttributes;
            EditorHelper.SetNodeIcon(treeNodeRootConditions, ENodeIcon.ListRootConditions);

            treeNodeRootActions = treeAttributes.Nodes.Add("Root", "Actions");
            treeNodeRootActions.ContextMenuStrip = menuAttributes;
            EditorHelper.SetNodeIcon(treeNodeRootActions, ENodeIcon.ListRootActions);

            treeNodeRootFlags = treeAttributes.Nodes.Add("Root", "Flags");
            treeNodeRootFlags.ContextMenuStrip = menuAttributes;
            EditorHelper.SetNodeIcon(treeNodeRootFlags, ENodeIcon.ListRootFlags);

            //Sync Conditions
            foreach (NodeCondition condition in dialogueNode.Conditions)
            {
                AddTreeNodeCondition(condition, treeNodeRootConditions);
            }

            //Sync Actions
            foreach (NodeAction action in dialogueNode.Actions)
            {
                AddTreeNodeAction(action);
            }

            //Sync Flags
            foreach (NodeFlag flag in dialogueNode.Flags)
            {
                AddTreeNodeFlag(flag);
            }

            //Fill Menu Conditions
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = "AND";
                menuItem.Click += delegate
                {
                    AddNodeCondition(Activator.CreateInstance(typeof(NodeConditionAnd)) as NodeCondition);
                };
                menuItemAddCondition.DropDownItems.Add(menuItem);
            }

            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = "OR";
                menuItem.Click += delegate
                {
                    AddNodeCondition(Activator.CreateInstance(typeof(NodeConditionOr)) as NodeCondition);
                };
                menuItemAddCondition.DropDownItems.Add(menuItem);
            }

            menuItemAddCondition.DropDownItems.Add(new ToolStripSeparator());

            foreach (ConditionSlot slot in EditorCore.ConditionSlots)
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = slot.Text;
                menuItem.Click += delegate
                {
                    AddNodeCondition(Activator.CreateInstance(slot.ConditionType) as NodeCondition);
                };
                menuItemAddCondition.DropDownItems.Add(menuItem);
            }

            //Fill Menu Actions
            foreach (ActionSlot slot in EditorCore.ActionSlots)
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = slot.Text;
                menuItem.Click += delegate
                {
                    AddNodeAction(Activator.CreateInstance(slot.ActionType) as NodeAction);
                };
                menuItemAddAction.DropDownItems.Add(menuItem);
            }

            //Fill Menu Flags
            foreach (FlagSlot slot in EditorCore.FlagSlots)
            {
                ToolStripMenuItem menuItem = new System.Windows.Forms.ToolStripMenuItem();
                menuItem.Text   = slot.Text;
                menuItem.Click += delegate
                {
                    AddNodeFlag(Activator.CreateInstance(slot.FlagType) as NodeFlag);
                };
                menuItemAddFlag.DropDownItems.Add(menuItem);
            }

            ready = true;
        }