TreeNode AddNodeToNode(string Name, VDFData parentVDFDataStructure, TreeNodeVDFTag treeNodeTag, TreeNode nodeSelected) { TreeNode newTreeNode; if (treeNodeTag.TagType == TreeNodeVDFTag.Type.Node) //If we have the node itself selected on our Treeview, we just need to call the AddNodeToNode method directly. { newTreeNode = AddNodeToNode(Name, nodeSelected, parentVDFDataStructure, treeNodeTag.Token as VDFNode); } else { //We will need to retrieve the parent of this key for this one if the key is the one that is selected. if (nodeSelected.Parent == null) //Make sure that the parent of the TreeNode is set to another TreeNode { throw new NullReferenceException("TreeNode " + nodeSelected.Text + " parent property is not set!"); } VDFKey selectedKey = treeNodeTag.Token as VDFKey; //Cast our token to key first. if (selectedKey.Parent == null) { throw new NullReferenceException("Parent property of key " + selectedKey.Name + " is not set!"); } VDFNode parentNode = selectedKey.Parent; newTreeNode = AddNodeToNode(Name, nodeSelected.Parent, vdfData, parentNode); } return(newTreeNode); }
TreeNode CreateNewKey(string Name, string Value, TreeNodeVDFTag treeNodeTag, TreeNode nodeSelected) { TreeNode newTreeNode; if (treeNodeTag.TagType == TreeNodeVDFTag.Type.Node) //If the tag type of our selected tree node is a VDFNode. Then it's quite easy to create a new key for us. Just need to call the CreateNewKey method. { newTreeNode = CreateNewKey(Name, Value, treeNodeTag.Token as VDFNode, nodeSelected); } else { //We will need to retrieve the parent of this key for this one if the key is the one that is selected. if (nodeSelected.Parent == null) //Make sure that the parent of the TreeNode is set to another TreeNode { throw new NullReferenceException("TreeNode " + nodeSelected.Text + " parent property is not set!"); } VDFKey selectedKey = treeNodeTag.Token as VDFKey; //Cast our token to key first. if (selectedKey.Parent == null) { throw new NullReferenceException("Parent property of key " + selectedKey.Name + " is not set!"); } VDFNode parentNode = selectedKey.Parent; newTreeNode = CreateNewKey(Name, Value, parentNode, nodeSelected.Parent); } return(newTreeNode); }
void UpdateTokenInfo(TreeNodeVDFTag treeNodeTag, TreeNode treeNodeToUpdate) { if (treeNodeTag.TagType == TreeNodeVDFTag.Type.Key) //Call the correct function by checking the type of token that we have. { UpdateKeyInfo(txtName.Text, txtValue.Text, (VDFKey)treeNodeTag.Token, treeNodeToUpdate); } else { UpdateNodeInfo(txtName.Text, (VDFNode)treeNodeTag.Token, treeNodeToUpdate); } }
void GUIUpdate_RevertInfo(TreeNodeVDFTag token) { if (token.TagType == TreeNodeVDFTag.Type.Key) { GUIUpdate_LoadKeyInfo(token.Token as VDFKey); } else { GUIUpdate_LoadNodeInfo(token.Token as VDFNode); } }