/// <summary> /// Method to hide the currently-selected node's ComboBox /// </summary> private void HideComboBox() { if (this.m_CurrentNode != null) { // Save current node for NodeValueChanged event DropDownTreeNode senderCtrl = m_CurrentNode; // Unregister the event listener this.m_CurrentNode.ComboBox.SelectedValueChanged -= ComboBox_SelectedValueChanged; this.m_CurrentNode.ComboBox.DropDownClosed -= ComboBox_DropDownClosed; // Copy the selected text from the ComboBox to the TreeNode this.m_CurrentNode.Text = this.m_CurrentNode.ComboBox.Text; // Hide the ComboBox this.m_CurrentNode.ComboBox.Hide(); this.m_CurrentNode.ComboBox.DroppedDown = false; // Remove the control from the TreeView's list of currently-displayed controls this.Controls.Remove(this.m_CurrentNode.ComboBox); // And return to the default state (no ComboBox displayed) this.m_CurrentNode = null; // VK: // Notify others that selection changed if (this.NodeValueChanged != null && senderCtrl != null && senderCtrl.ComboBox.SelectedIndex != this.m_CurrentSelectionIdx) { this.NodeValueChanged(senderCtrl, EventArgs.Empty); } this.m_CurrentSelectionIdx = -1; } }
private ImagingObservationXML GetSelectedImagingObservation() { ImagingObservationXML xmlImagingObservation = new ImagingObservationXML(null); int mainNodeIdx = GetTreeNodeIndex(mainTree, mainTree.SelectedNode); if (mainNodeIdx > -1) { DropDownTreeNode ddNode = mainTree.SelectedNode as DropDownTreeNode; if (ddNode != null) { ComboItem comboItem = ddNode.ComboBox.SelectedItem as ComboItem; if (comboItem != null) { ImagingObservationXML selectedImagingObservationXML = comboItem.TagValue as ImagingObservationXML; if (selectedImagingObservationXML != null) { xmlImagingObservation = new ImagingObservationXML(selectedImagingObservationXML.Node); } } } } return(xmlImagingObservation); }
/// <summary> /// Shows drop down control for the given tree node /// </summary> /// <param name="treeNode">Tree Node to show drop down control at</param> private bool ShowComboBox(DropDownTreeNode treeNode) { if (treeNode == null) { return(false); } this.m_CurrentNode = treeNode; this.m_CurrentSelectionIdx = this.m_CurrentNode.ComboBox.SelectedIndex; // Need to add the node's ComboBox to the TreeView's list of controls for it to work this.Controls.Add(this.m_CurrentNode.ComboBox); // Set the bounds of the ComboBox, with a little adjustment to make it look right this.m_CurrentNode.ComboBox.SetBounds( this.m_CurrentNode.Bounds.X - 1, this.m_CurrentNode.Bounds.Y - 2, AimWinFormsUtil.CalculateComboBoxDropdownWidth(this.m_CurrentNode.ComboBox), //this.m_CurrentNode.Bounds.Width + 25, this.m_CurrentNode.Bounds.Height); // Listen to the SelectedValueChanged event of the node's ComboBox this.m_CurrentNode.ComboBox.SelectedValueChanged += ComboBox_SelectedValueChanged; this.m_CurrentNode.ComboBox.DropDownClosed += ComboBox_DropDownClosed; this.m_CurrentNode.ComboBox.BackColor = Color.DeepPink; // Now show the ComboBox this.m_CurrentNode.ComboBox.Show(); this.m_CurrentNode.ComboBox.DroppedDown = true; return(true); }
protected void AddRootImagingObservationNode() { if (_xmlDoc != null && _xmlDoc.AnnotationDescriptionXML2.Exists && _xmlDoc.AnnotationDescriptionXML2.First.imagingObservationCollectionXML.Exists) { DropDownTreeNode node = new DropDownTreeNode(_select_text); int i = node.ComboBox.Items.Add(new ComboItem(_select_text)); node.ComboBox.SelectedIndex = i; foreach (ImagingObservationXML xmlImagingObservation in _xmlDoc.AnnotationDescriptionXML2.First.imagingObservationCollectionXML.First.ImagingObservationXML2) { if (xmlImagingObservation.codeMeaning.Exists) { ComboItem comboItem = new ComboItem(xmlImagingObservation.codeMeaning.First.Value, xmlImagingObservation); node.ComboBox.Items.Add(comboItem); } } int nodeIdx = mainTree.Nodes.Add(node); _selectedImagingObservations.Add(new ObservationSelection(new ImagingObservationXML(null))); System.Diagnostics.Debug.Assert(_selectedImagingObservations.Count == nodeIdx + 1); // Set initial selection if (mainTree.SelectedNode == null) { mainTree.SelectedNode = mainTree.Nodes[nodeIdx]; } } else if (mainTree.Nodes.Count == 0) { this.AddNoDataNode(mainTree.Nodes); _selectedImagingObservations.Clear(); } this.UpdateEnabledStates(); }
// 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); } }
protected void AddRootAnatomicEntityNode() { if (_xmlDoc != null && _xmlDoc.AnnotationDescriptionXML2.Exists && _xmlDoc.AnnotationDescriptionXML2.First.anatomicEntityCollectionXML.Exists) { // 1-st top level node DropDownTreeNode node = new DropDownTreeNode(_select_text); int i = node.ComboBox.Items.Add(new ComboItem(_select_text)); node.ComboBox.SelectedIndex = i; // 2-d actual data node foreach (anatomicEntityCollectionXMLType xmlAnatomicEntityCollection in _xmlDoc.AnnotationDescriptionXML2.First.anatomicEntityCollectionXML) { if (xmlAnatomicEntityCollection.AnatomicEntityXML2.Exists) { foreach (AnatomicEntityXML xmlAnatomicEntity in xmlAnatomicEntityCollection.AnatomicEntityXML2) { if (xmlAnatomicEntity.codeMeaning.Exists) { ComboItem comboItem = new ComboItem(xmlAnatomicEntity.codeMeaning.First.Value, xmlAnatomicEntity); node.ComboBox.Items.Add(comboItem); } } } } int nodeIdx = mainTree.Nodes.Add(node); // Set initial selection if (mainTree.SelectedNode == null) { mainTree.SelectedNode = mainTree.Nodes[nodeIdx]; } } else if (mainTree.Nodes.Count == 0) { this.AddNoDataNode(mainTree.Nodes); } }
private void mainTree_NodeValueChanged(object sender, EventArgs e) { DropDownTreeNode node = mainTree.SelectedNode as DropDownTreeNode; if (node != null) { int nodeIdx = this.GetTreeNodeIndex(mainTree, node); if (nodeIdx > -1) { ComboItem comboItem = node.ComboBox.SelectedItem as ComboItem; // Get saved node from the ComboItem if (null == comboItem) { _selectedImagingObservations[nodeIdx] = new ObservationSelection(new ImagingObservationXML(null)); } else { ImagingObservationXML selectedImagingObservationXML = comboItem.TagValue as ImagingObservationXML; if (selectedImagingObservationXML != null) { if (_selectedImagingObservations[nodeIdx].xmlImagingObservation.Node == null || !_selectedImagingObservations[nodeIdx].xmlImagingObservation.codeValue.Exists || !_selectedImagingObservations[nodeIdx].xmlImagingObservation.codeValue.First.Value.Equals(comboItem.TagValue)) { _selectedImagingObservations[nodeIdx] = new ObservationSelection(new ImagingObservationXML(selectedImagingObservationXML.Node)); } } else { _selectedImagingObservations[nodeIdx] = new ObservationSelection(new ImagingObservationXML(null)); } } } } this.UpdateTreeImagingObservation(); }
protected void AddRootAnatomicEntityNode() { if (_xmlDoc != null && _xmlDoc.AnnotationDescriptionXML2.Exists && _xmlDoc.AnnotationDescriptionXML2.First.anatomicEntityCollectionXML.Exists) { // 1-st top level node DropDownTreeNode node = new DropDownTreeNode(_select_text); int i = node.ComboBox.Items.Add(new ComboItem(_select_text)); node.ComboBox.SelectedIndex = i; // 2-d actual data node foreach (anatomicEntityCollectionXMLType xmlAnatomicEntityCollection in _xmlDoc.AnnotationDescriptionXML2.First.anatomicEntityCollectionXML) { if (xmlAnatomicEntityCollection.AnatomicEntityXML2.Exists) { foreach (AnatomicEntityXML xmlAnatomicEntity in xmlAnatomicEntityCollection.AnatomicEntityXML2) { if (xmlAnatomicEntity.codeMeaning.Exists) { ComboItem comboItem = new ComboItem(xmlAnatomicEntity.codeMeaning.First.Value, xmlAnatomicEntity); node.ComboBox.Items.Add(comboItem); } } } } int nodeIdx = mainTree.Nodes.Add(node); // Set initial selection if (mainTree.SelectedNode == null) mainTree.SelectedNode = mainTree.Nodes[nodeIdx]; } else if (mainTree.Nodes.Count == 0) { this.AddNoDataNode(mainTree.Nodes); } }
/// <summary> /// Method to hide the currently-selected node's ComboBox /// </summary> private void HideComboBox() { if (this.m_CurrentNode != null) { // Save current node for NodeValueChanged event DropDownTreeNode senderCtrl = m_CurrentNode; // Unregister the event listener this.m_CurrentNode.ComboBox.SelectedValueChanged -= ComboBox_SelectedValueChanged; this.m_CurrentNode.ComboBox.DropDownClosed -= ComboBox_DropDownClosed; // Copy the selected text from the ComboBox to the TreeNode this.m_CurrentNode.Text = this.m_CurrentNode.ComboBox.Text; // Hide the ComboBox this.m_CurrentNode.ComboBox.Hide(); this.m_CurrentNode.ComboBox.DroppedDown = false; // Remove the control from the TreeView's list of currently-displayed controls this.Controls.Remove(this.m_CurrentNode.ComboBox); // And return to the default state (no ComboBox displayed) this.m_CurrentNode = null; // VK: // Notify others that selection changed if (this.NodeValueChanged != null && senderCtrl != null && senderCtrl.ComboBox.SelectedIndex != this.m_CurrentSelectionIdx) this.NodeValueChanged(senderCtrl, EventArgs.Empty); this.m_CurrentSelectionIdx = -1; } }
/// <summary> /// Shows drop down control for the given tree node /// </summary> /// <param name="treeNode">Tree Node to show drop down control at</param> private bool ShowComboBox(DropDownTreeNode treeNode) { if (treeNode == null) return false; this.m_CurrentNode = treeNode; this.m_CurrentSelectionIdx = this.m_CurrentNode.ComboBox.SelectedIndex; // Need to add the node's ComboBox to the TreeView's list of controls for it to work this.Controls.Add(this.m_CurrentNode.ComboBox); // Set the bounds of the ComboBox, with a little adjustment to make it look right this.m_CurrentNode.ComboBox.SetBounds( this.m_CurrentNode.Bounds.X - 1, this.m_CurrentNode.Bounds.Y - 2, AimWinFormsUtil.CalculateComboBoxDropdownWidth(this.m_CurrentNode.ComboBox), //this.m_CurrentNode.Bounds.Width + 25, this.m_CurrentNode.Bounds.Height); // Listen to the SelectedValueChanged event of the node's ComboBox this.m_CurrentNode.ComboBox.SelectedValueChanged += ComboBox_SelectedValueChanged; this.m_CurrentNode.ComboBox.DropDownClosed += ComboBox_DropDownClosed; this.m_CurrentNode.ComboBox.BackColor = Color.DeepPink; // Now show the ComboBox this.m_CurrentNode.ComboBox.Show(); this.m_CurrentNode.ComboBox.DroppedDown = true; return true; }
protected void AddRootImagingObservationNode() { if (_xmlDoc != null && _xmlDoc.AnnotationDescriptionXML2.Exists && _xmlDoc.AnnotationDescriptionXML2.First.imagingObservationCollectionXML.Exists) { DropDownTreeNode node = new DropDownTreeNode(_select_text); int i = node.ComboBox.Items.Add(new ComboItem(_select_text)); node.ComboBox.SelectedIndex = i; foreach (ImagingObservationXML xmlImagingObservation in _xmlDoc.AnnotationDescriptionXML2.First.imagingObservationCollectionXML.First.ImagingObservationXML2) { if (xmlImagingObservation.codeMeaning.Exists) { ComboItem comboItem = new ComboItem(xmlImagingObservation.codeMeaning.First.Value, xmlImagingObservation); node.ComboBox.Items.Add(comboItem); } } int nodeIdx = mainTree.Nodes.Add(node); _selectedImagingObservations.Add( new ObservationSelection(new ImagingObservationXML(null))); System.Diagnostics.Debug.Assert(_selectedImagingObservations.Count == nodeIdx + 1); // Set initial selection if (mainTree.SelectedNode == null) mainTree.SelectedNode = mainTree.Nodes[nodeIdx]; } else if (mainTree.Nodes.Count == 0) { this.AddNoDataNode(mainTree.Nodes); _selectedImagingObservations.Clear(); } this.UpdateEnabledStates(); }