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 AddNodeFlag(NodeFlag flag)
        {
            if (flag != null)
            {
                dialogueNode.Flags.Add(flag);
                AddTreeNodeFlag(flag);

                document.RefreshTreeNode(treeNode);
                document.SetDirty();
            }
        }
        private void RemoveTreeNode(TreeNode node)
        {
            if (node == null)
            {
                return;
            }

            if (selectedTreeNode == treeNodeRootConditions)
            {
                RemoveAllConditions();
            }
            else if (selectedTreeNode == treeNodeRootActions)
            {
                RemoveAllActions();
            }
            else if (selectedTreeNode == treeNodeRootFlags)
            {
                RemoveAllFlags();
            }
            else
            {
                NodeCondition condition = node.Tag as NodeCondition;
                NodeAction    action    = node.Tag as NodeAction;
                NodeFlag      flag      = node.Tag as NodeFlag;

                var parent = node.Parent;
                node.Remove();

                if (condition != null)
                {
                    if (parent.Tag is NodeConditionGroup)
                    {
                        ((NodeConditionGroup)parent.Tag).Conditions.Remove(condition);
                    }
                    else
                    {
                        dialogueNode.Conditions.Remove(condition);
                    }
                }
                else if (action != null)
                {
                    dialogueNode.Actions.Remove(action);
                }
                else if (flag != null)
                {
                    dialogueNode.Flags.Remove(flag);
                }
            }

            document.RefreshTreeNode(treeNode);
            document.SetDirty();
        }
        private void OnPropertyGridAttributesChanged(object s, PropertyValueChangedEventArgs e)
        {
            NodeCondition condition = selectedTreeNode.Tag as NodeCondition;
            NodeAction    action    = selectedTreeNode.Tag as NodeAction;
            NodeFlag      flag      = selectedTreeNode.Tag as NodeFlag;

            //Refresh node text
            if (condition != null)
            {
                selectedTreeNode.Text = condition.GetTreeText();
            }
            if (action != null)
            {
                selectedTreeNode.Text = action.GetTreeText();
            }
            if (flag != null)
            {
                selectedTreeNode.Text = flag.GetTreeText();
            }

            document.RefreshTreeNode(treeNode);
            document.SetDirty();
        }