// Modifying Script private void toolStripButtonInsertTag_Click(object sender, EventArgs e) { List <long> tags = GetTags(); using (InsertElementDlg dlgInsert = new InsertElementDlg(tags)) { if (dlgInsert.ShowDialog(this) == DialogResult.OK) { AnonymizeScript selectedScript = listViewAnonymizeScripts.GetSelectedScript(); DicomTagNode node = null; foreach (long tag in dlgInsert.Tags) { DicomTag dicomTag = DicomTagTable.Instance.Find(tag); DicomTagNode tagNode = AddAnonymizationTag(selectedScript, tag, dicomTag != null ? dicomTag.Name : string.Empty, GetDefaultMacro(dicomTag)); if (node == null) { node = tagNode; } } if (dlgInsert.Tags.Count > 0) { SetDirty(); } if (node != null) { treeGridViewTags.ClearSelection(); Console.WriteLine("Need to SelectRow"); //treeGridViewTags.SelectRow(node.Index); treeGridViewTags.FirstDisplayedScrollingRowIndex = node.Index; } } } }
private DicomTagNode AddAnonymizationTag(AnonymizeScript selectedScript, long tag, string name, string macro) { DicomTag dicomTag = DicomTagTable.Instance.Find(tag); DicomTagNode node = new DicomTagNode(); node.CreateCells(treeGridViewTags); node.SetValues(string.Format("({0:X4},{1:X4})", tag.GetGroup(), tag.GetElement()), name, macro); treeGridViewTags.Rows.Add(node); // treeGridViewTags.Rows.Add(node); node.DicomTag = dicomTag; // node.Image = Resources.Tag_16x16; //if (dicomTag != null && dicomTag.VR == DicomVRType.SQ) // node.Image = Resources.Tags_16x16; Anonymizer selectedAnonymizer = null; if (selectedScript != null) { selectedAnonymizer = selectedScript.Anonymizer; } if (selectedAnonymizer != null) { selectedAnonymizer[tag] = macro; node.Tag = selectedAnonymizer.FindTag(tag); return(node); } return(null); }
private List <long> GetTags() { List <long> tags = new List <long>(); foreach (DataGridViewRow node in treeGridViewTags.Rows) { DicomTagNode dicomTagNode = node as DicomTagNode; if (dicomTagNode != null) { tags.Add(dicomTagNode.DicomTag.Code); } } return(tags); }
private void LoadMacros(AnonymizeScript selectedScript) { treeGridViewTags.Rows.Clear(); ObservableCollection <TagMacro> macros = new ObservableCollection <TagMacro>(); if (selectedScript != null) { macros = selectedScript.Anonymizer.TagMacros; } foreach (TagMacro macro in macros) { DicomTag dicomTag = DicomTagTable.Instance.Find(macro.Tag); string name = dicomTag != null ? dicomTag.Name : string.Empty; DicomTagNode node = new DicomTagNode(); string sValue = string.Format("{0:X4},{1:X4}", macro.Tag.GetGroup(), macro.Tag.GetElement()); // bool bRet = node.SetValues(sValue, name, macro.Macro); // DataGridViewRow row = new DataGridViewRow(); node.CreateCells(treeGridViewTags); node.SetValues(sValue, name, macro.Macro); treeGridViewTags.Rows.Add(node); node.DicomTag = dicomTag; node.Tag = macro; AddToList(macro.Macro); //if (dicomTag != null) //{ // if (dicomTag.VR == DicomVRType.SQ) // node.Image = Resources.Tags_16x16; // else // node.Image = Resources.Tag_16x16; //} } // treeGridViewTags.Refresh(); }