/* * Finds the first module and then continues to fill the tree */ private void FillTreeModules() { try { for (int x = 0; x < ds.ModuleCount; x++) { TreeNode node; DicomModule module; DicomIod iod; module = ds.FindModuleByIndex(x); iod = DicomIodTable.Instance.FindModule(ds.InformationClass, module.Type); node = treeViewElements.Nodes.Add(iod.Name); node.Tag = module; foreach (DicomElement element in module.Elements) { FillModuleSubTree(element, node, false); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
void CopyExistingElementsValues(DicomDataSet dsTarget, DicomDataSet dsSrc) { for (int nIndex = 0; nIndex < dsTarget.ModuleCount; nIndex++) { DicomModule dm = dsTarget.FindModuleByIndex(nIndex); foreach (DicomElement elementTarget in dm.Elements) { if (elementTarget.Length == 0) { DicomElement elementSrc = dsSrc.FindFirstElement(null, elementTarget.Tag, false); if (null != elementSrc) { dsTarget.SetValue(elementTarget, dsSrc.GetValue <object>(elementSrc, null)); } } } } }
private void FillTreeModules() { for (int x = 0; x < _dsImage.ModuleCount; x++) { TreeNode node; DicomModule module; DicomIod iod; module = _dsImage.FindModuleByIndex(x); iod = DicomIodTable.Instance.FindModule(_dsImage.InformationClass, module.Type); node = _treeView_Elements.Nodes.Add(iod.Name); node.Tag = module; foreach (DicomElement element in module.Elements) { FillModuleSubTree(element, node, false); } } }
public void BuildTreeFromDataset(DicomDataSet ds, bool IsMWLDS) { if (Globals._closing == true || this.Disposing || this.IsDisposed) { return; } if (InvokeRequired) { Invoke(new BuildTreeFromDatasetDelegate(BuildTreeFromDataset), ds, IsMWLDS); } else { try { TreeNodeCollection IODClassNodes; if (IsMWLDS) { // Add a root level node since there could be multiple MWL datasets to be displayed string parentNodeString = String.Format( "{0:D3} Modality Work List - {1} ", (Nodes.Count + 1), Utils.GetStringValue(ds, DemoDicomTags.Modality, false)); MyTreeNode rootNode = new MyTreeNode(parentNodeString, ds); Nodes.Add(rootNode); rootNode.ImageIndex = (int)MyIconIndex.Worklist; rootNode.SelectedImageIndex = (int)MyIconIndex.Worklist; IODClassNodes = rootNode.Nodes; } else { // Use the tree's root for IOD classes IODClassNodes = Nodes; } // Insert nodes for IOD classes for (int i = 0; i < ds.ModuleCount; i++) { DicomModule dm = ds.FindModuleByIndex(i); DicomIod dIod = DicomIodTable.Instance.FindModule(ds.InformationClass, dm.Type); if (dIod != null) { IODClassNodes.Add( new MyTreeNode(dIod.Name, ds, dIod)); IODClassNodes[i].ImageIndex = (int)MyIconIndex.Folder; IODClassNodes[i].SelectedImageIndex = (int)MyIconIndex.Folder; } else { IODClassNodes.Add( new MyTreeNode("UNKNOWN")); IODClassNodes[i].ImageIndex = (int)MyIconIndex.Missing; IODClassNodes[i].SelectedImageIndex = (int)MyIconIndex.Missing; } // Insert nodes for the elements within the current IOD class for (int j = 0; j < dm.Elements.Length; j++) { // Determine the element tag DicomTag tag; long tagValue; #if (LTV15_CONFIG) if (dm.Elements[j].Tag != DemoDicomTags.Undefined) { tag = DicomTagTable.Instance.Find(dm.Elements[j].Tag); tagValue = (long)dm.Elements[j].Tag; } else { tag = DicomTagTable.Instance.Find(dm.Elements[j].UserTag); tagValue = dm.Elements[j].UserTag; } #else tag = DicomTagTable.Instance.Find(dm.Elements[j].Tag); tagValue = (long)dm.Elements[j].Tag; #endif // Add new element TreeNode IODClassNodes[i].Nodes.Add( new MyTreeNode(String.Format("{0:X4}:{1:X4} - {2}", Utils.GetGroup(tagValue), Utils.GetElement(tagValue), tag.Name), ds, dm.Elements[j])); IODClassNodes[i].Nodes[j].ImageIndex = (int)MyIconIndex.Element; IODClassNodes[i].Nodes[j].SelectedImageIndex = (int)MyIconIndex.Element; // Check to see if the element has children if (ds.GetChildElement(dm.Elements[j], true) != null) { IODClassNodes[i].Nodes[j].ImageIndex = (int)MyIconIndex.Sequence; IODClassNodes[i].Nodes[j].SelectedImageIndex = (int)MyIconIndex.Sequence; // Recursively add children of this element AddChildrenOfElement(ds, (MyTreeNode)IODClassNodes[i].Nodes[j], dm.Elements[j]); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }