private void addNodeTrade(TreeNode textNode, String id)
        {
            TalkNode talkNode = new TalkNode(textNode, TalkNodeTypes.Trade, id, "");

            textNode.Nodes.Insert(0, new TreeNode(talkNode.ToString())); // Always shown first
            textNode.Nodes[0].Tag = talkNode;
        }
        private void addNodeFlag(TreeNode textNode, String id, String text)
        {
            TalkNode talkNode  = new TalkNode(textNode, TalkNodeTypes.Flags, id, text);
            int      childNode = textNode.Nodes.Add(new TreeNode(talkNode.ToString()));

            textNode.Nodes[childNode].Tag = talkNode;
        }
        private TreeNode addNodeText(String id, String text)
        {
            TalkNode talkNode = new TalkNode(null, TalkNodeTypes.None, id, text);
            TreeNode textNode = guiTalkTree.Nodes.Add(talkNode.ToString());

            textNode.Tag = talkNode;
            return(textNode);
        }
        private void onNodeAdd(object sender, EventArgs e)
        {
            int id = guiTalkTree.Nodes.Count + 1;

            TalkNode talkNode = new TalkNode(null, TalkNodeTypes.None, id.ToString(), "");
            TreeNode newNode  = guiTalkTree.Nodes.Add(talkNode.ToString());

            newNode.Tag = talkNode;
            guiTalkTree.SelectedNode = newNode;
            guiTalkTree.Focus();
        }
        private void addNodeBranch(TreeNode textNode, String id, String text)
        {
            if (text.Length > m_MaxText)
            {
                text = text.Substring(0, m_MaxText);
            }
            TalkNode talkNode  = new TalkNode(textNode, TalkNodeTypes.Branch, id, text);
            int      childNode = textNode.Nodes.Add(new TreeNode(talkNode.ToString()));

            textNode.Nodes[childNode].Tag = talkNode;
        }
        private void onAddNode(object sender, EventArgs e)
        {
            int id = talkTree.Nodes.Count + 1;

            TalkNode talkNode = new TalkNode(null, TalkNodeTypes.None, id.ToString(), "");
            TreeNode newNode  = talkTree.Nodes.Add(talkNode.ToString());

            newNode.Tag           = talkNode;
            talkTree.SelectedNode = newNode;
            talkTree.Focus();
            setFields(null);
            refreshTree();
        }
 private void onTextChanged(object sender, EventArgs e)
 {
     if (!m_muteFieldEvents)
     {
         TextBox textField = (TextBox)sender;
         foreach (Replies replyGroup in m_replies)
         {
             if (replyGroup.textField == textField && replyGroup.treeNode != null)
             {
                 TalkNode talkNode = (TalkNode)replyGroup.treeNode.Tag;
                 talkNode.text            = textField.Text;
                 replyGroup.treeNode.Text = talkNode.ToString();
                 break;
             }
         }
     }
 }
        private void onNodeAdd(object sender, EventArgs e)
        {
            int id = guiTalkTree.Nodes.Count + 1;

            TalkNode talkNode = new TalkNode(null, TalkNodeTypes.None, id.ToString(), "");
            TreeNode newNode = guiTalkTree.Nodes.Add(talkNode.ToString());
            newNode.Tag = talkNode;
            guiTalkTree.SelectedNode = newNode;
            guiTalkTree.Focus();
        }
 private void addNodeTrade(TreeNode textNode, String id)
 {
     TalkNode talkNode = new TalkNode(textNode, TalkNodeTypes.Trade, id, "");
     textNode.Nodes.Insert(0, new TreeNode(talkNode.ToString())); // Always shown first
     textNode.Nodes[0].Tag = talkNode;
 }
 private TreeNode addNodeText(String id, String text)
 {
     TalkNode talkNode = new TalkNode(null, TalkNodeTypes.None, id, text);
     TreeNode textNode = guiTalkTree.Nodes.Add(talkNode.ToString());
     textNode.Tag = talkNode;
     return textNode;
 }
 private void addNodeFlag(TreeNode textNode, String id, String text)
 {
     TalkNode talkNode = new TalkNode(textNode, TalkNodeTypes.Flags, id, text);
     int childNode = textNode.Nodes.Add(new TreeNode(talkNode.ToString()));
     textNode.Nodes[childNode].Tag = talkNode;
 }
        /// <summary>
        /// The type has been changed.  Find the appropriate reply and enable/disable its fields.
        /// </summary>
        private void onReplyType(object sender, EventArgs e)
        {
            if (m_displayField)
            {
                setFields(null);
            }
            else
            {
                // User is manually changing the field
                for (int childIndex = 0; childIndex < m_replies.Count; ++childIndex)
                {
                    if (sender == m_replies[childIndex].typeField)
                    {
                        TalkNodeTypes newType = (TalkNodeTypes)Enum.Parse(typeof(TalkNodeTypes), (String)m_replies[childIndex].typeField.SelectedItem);

                        TalkNodeTypes currentType = m_replies[childIndex].treeNode == null
                                                  ? TalkNodeTypes.None
                                                  : ((TalkNode)m_replies[childIndex].treeNode.Tag).type;
                        if (!currentType.Equals(newType))
                        {
                            // The type has been changed
                            if (newType.Equals(TalkNodeTypes.None))
                            {
                                // Delete this sub-node
                                TreeNode deletedNode = m_replies[childIndex].treeNode;
                                talkTree.SelectedNode.Nodes.Remove(deletedNode);
                                refreshTree();
                                setFields(null);
                            }
                            else
                            {
                                if (newType.Equals(TalkNodeTypes.Trade) &&
                                    !canSetNodeToTrade(talkTree.SelectedNode))
                                {
                                    // Already contains a Trade sub-node so reset to previous type
                                    m_replies[childIndex].typeField.SelectedItem = currentType.ToString();
                                    setFields(sender);
                                    return;
                                }

                                if (currentType.Equals(TalkNodeTypes.None))
                                {
                                    // Create a sub-node
                                    if (newType.Equals(TalkNodeTypes.Trade))
                                    {
                                        addNodeTrade(talkTree.SelectedNode, "1");
                                    }
                                    else
                                    {
                                        addNodeBranch(talkTree.SelectedNode, "", "");
                                    }
                                    setFields(sender);
                                    refreshTree();
                                }
                                else
                                {
                                    TreeNode modifiedNode = m_replies[childIndex].treeNode;
                                    TalkNode talkNode     = (TalkNode)modifiedNode.Tag;
                                    talkNode.type = newType;
                                    if (newType.Equals(TalkNodeTypes.Trade))
                                    {
                                        talkTree.SelectedNode.Nodes.Remove(modifiedNode);
                                        addNodeTrade(talkTree.SelectedNode, "");
                                    }
                                    refreshTree();
                                    setFields(sender);
                                    modifiedNode.Text = talkNode.ToString();
                                }
                            }
                        }
                    }
                }
            }
        }