// Recursively reads values of the given node into an AnatomicEntityXML protected void ReadChildTreeNode(DropDownTreeNode node, AnatomicEntityXML xmlAnatomicEntity) { if (node != null) { ComboItem comboItem = node.ComboBox.SelectedItem as ComboItem; if (comboItem != null && comboItem.TagValue != null) { AnatomicEntityXML oldXmlAnatomicEntity = comboItem.TagValue as AnatomicEntityXML; if (oldXmlAnatomicEntity != null) { xmlAnatomicEntity = xmlAnatomicEntity.relatedAnatomicEntityXML.Append().AnatomicEntityXML2.Append(); xmlAnatomicEntity.codeValue.Append().Value = oldXmlAnatomicEntity.codeValue.Exists ? oldXmlAnatomicEntity.codeValue.First.Value : string.Empty; xmlAnatomicEntity.codeMeaning.Append().Value = oldXmlAnatomicEntity.codeMeaning.Exists ? oldXmlAnatomicEntity.codeMeaning.First.Value : string.Empty; xmlAnatomicEntity.codingSchemeDesignator.Append().Value = oldXmlAnatomicEntity.codingSchemeDesignator.Exists ? oldXmlAnatomicEntity.codingSchemeDesignator.First.Value : string.Empty; xmlAnatomicEntity.relationship.Append().Value = oldXmlAnatomicEntity.relationship.Exists ? oldXmlAnatomicEntity.relationship.First.Value : string.Empty; // Check node's descendents if (node.Nodes.Count > 0) { node = node.Nodes[0] as DropDownTreeNode; this.ReadChildTreeNode(node, xmlAnatomicEntity); } } } } }
//[Description("Occurs when the value of selected Anatomic Entity is changed")] //public event EventHandler ValueChanged //{ // // use pass through event subscription // add { mainTree.NodeValueChanged += value; } // remove { mainTree.NodeValueChanged -= value; } //} public void GetSelectedValues(AIMOntology outputDoc) { AnnotationDescriptionXML xmlAnnotationDescription = outputDoc.AnnotationDescriptionXML2.Exists ? outputDoc.AnnotationDescriptionXML2.First : outputDoc.AnnotationDescriptionXML2.Append(); anatomicEntityCollectionXMLType xmlAnatomicEntityCollection = xmlAnnotationDescription.anatomicEntityCollectionXML.Exists ? xmlAnnotationDescription.anatomicEntityCollectionXML.First : xmlAnnotationDescription.anatomicEntityCollectionXML.Append(); foreach (DropDownTreeNode node in mainTree.Nodes) { if (node != null) { ComboItem comboItem = node.ComboBox.SelectedItem as ComboItem; if (comboItem != null && comboItem.TagValue != null) { AnatomicEntityXML oldXmlAnatomicEntity = comboItem.TagValue as AnatomicEntityXML; if (oldXmlAnatomicEntity != null) { AnatomicEntityXML xmlAnatomicEntity = xmlAnatomicEntityCollection.AnatomicEntityXML2.Append(); xmlAnatomicEntity.codeValue.Append().Value = oldXmlAnatomicEntity.codeValue.Exists ? oldXmlAnatomicEntity.codeValue.First.Value : string.Empty; xmlAnatomicEntity.codeMeaning.Append().Value = oldXmlAnatomicEntity.codeMeaning.Exists ? oldXmlAnatomicEntity.codeMeaning.First.Value : string.Empty; xmlAnatomicEntity.codingSchemeDesignator.Append().Value = oldXmlAnatomicEntity.codingSchemeDesignator.Exists ? oldXmlAnatomicEntity.codingSchemeDesignator.First.Value : string.Empty; xmlAnatomicEntity.relationship.Append().Value = oldXmlAnatomicEntity.relationship.Exists ? oldXmlAnatomicEntity.relationship.First.Value : string.Empty; // Check node's descendents if (node.Nodes.Count > 0) { DropDownTreeNode childNode = node.Nodes[0] as DropDownTreeNode; this.ReadChildTreeNode(childNode, xmlAnatomicEntity); } } } } } }
private void mainTree_NodeValueChanged(object sender, EventArgs e) { DropDownTreeNode node = sender as DropDownTreeNode; if (node != null) { ComboItem comboTag = node.ComboBox.SelectedItem as ComboItem; this.SuspendLayout(); node.Nodes.Clear(); if (comboTag != null && comboTag.TagValue != null) { if (comboTag.TagValue is AnatomicEntityXML) { AnatomicEntityXML xmlAnatomicEntity = (AnatomicEntityXML)comboTag.TagValue; if (xmlAnatomicEntity.relatedAnatomicEntityXML.Exists) { DropDownTreeNode childNode = new DropDownTreeNode(_select_text); int i = childNode.ComboBox.Items.Add(new ComboItem(_select_text)); childNode.ComboBox.SelectedIndex = i; foreach (AnatomicEntityXML xmlRelatedAnatomicEntity in xmlAnatomicEntity.relatedAnatomicEntityXML.First.AnatomicEntityXML2) { if (xmlRelatedAnatomicEntity.codeMeaning.Exists) { ComboItem comboItem = new ComboItem(xmlRelatedAnatomicEntity.codeMeaning.First.Value, xmlRelatedAnatomicEntity); childNode.ComboBox.Items.Add(comboItem); } } if (childNode.ComboBox.Items.Count > 1) { node.Nodes.Add(childNode); node.Expand(); } } } } this.ResumeLayout(); this.Update(); EventsHelper.Fire(SelectedAnatomicEntitiesChanged, this, EventArgs.Empty); } }