private SubjectNodes GetParentNode() { int SelectedIndex = lvSubjects.SelectedIndex; string SelectedNodesLevelName = SubjectStaticMembers.SubjectNodesLevelNameList[SelectedIndex]; // Create ParentNode NewParentNode = SubjectStaticMembers.SubjectNodeDictionary[SelectedNodesLevelName]; return(NewParentNode); }
//Select an item in the lvSubjects and create a SelectedNode from its NodeLevelName private void lvSubjects_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (lvSubjects.SelectedItems != null) { int SelectedNodePosition = lvSubjects.SelectedIndex; string SelectedNodesLevelName = SubjectStaticMembers.SubjectNodesLevelNameList[SelectedNodePosition]; SelectedNode = SubjectStaticMembers.SubjectNodeDictionary[SelectedNodesLevelName]; } }
private void CreateNewChildSubjectNode(int currentItemCount) { // Instantiate a SubjectNode with the currentItemCount NewChildNode = new SubjectNodes(currentItemCount); // Get the Parent Node NewParentNode = GetParentNode(); //Get the Parent's Number of Children to calcuate the child's NodeLevelName int ParentsNumchildren = NewParentNode.NOC; //Get the Child's NodeLevelPosition string ChildsNodeLevelPosition = SubjectStaticMembers.GetNodeLevelPosition(ParentsNumchildren); // Set the NewChildNodes NodeLevel NewChildNode.NodeLevelName = NewParentNode.NodeLevelName + ChildsNodeLevelPosition; NewChildNode.LeadingChars = SubjectStaticMembers.GetLeadingChars(NewChildNode.NodeLevelName); NewChildNode.LeadingChars = "- "; NewChildNode.TitleText = tbxNodeName.Text; NewChildNode.HasData = false; NewChildNode.NOC = 0; // Add this child to the dictionary SubjectStaticMembers.AddNodeToDictionary(NewChildNode); // reeset the displau List <string> DisplayList = SubjectStaticMembers.ResetDisplayList(NewChildNode.NodeLevelName); lvSubjects.Items.Clear(); foreach (string item in DisplayList) { lvSubjects.Items.Add(item); } //Increment and save the ItemsIndex }