public void Delete <T>(Form parentForm, XCollection <T> list) where T : MappingItem, IDicomMappingItem, new() { T selitem = GetSelectedItem() as T; if (selitem == null) { return; } if (selitem.DPath.VR == DVR.SQ) { int index = list.IndexOf(selitem); if (DicomMappingHelper.HasSequence <T>(index, list)) { if (MessageBox.Show(parentForm, "Deleting SQ element will automatically delete all elements in the SQ sequence.\r\nAre you sure to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DicomMappingHelper.DeleteSequence <T>(index, list); } else { return; } } } list.Remove(selitem); }
private bool SaveSetting() { T testItem = _mappingItem.Clone() as T; _fieldControler.SaveSetting(testItem); _tagControler.SaveSetting(testItem.DPath, null); // get parallel item list int sqIndex = -1; XCollection <T> iList; int baseIndex = _baseItem == null ? -1 : _itemList.IndexOf(_baseItem); if (_addChild) { //when adding child _baseItem is the parent SQ item iList = DicomMappingHelper.GetSequence <T>(baseIndex, _itemList); } else { int tbaseIndex = baseIndex; sqIndex = DicomMappingHelper.FindParentSQItemIndex <T>(ref tbaseIndex, _itemList); iList = DicomMappingHelper.GetSequence <T>(sqIndex, _itemList); } if (iList == null) { iList = _itemList; } // avoid duplicated DICOM tag foreach (T item in iList) { if (item == _mappingItem) { continue; } if (item.DPath.GetTag() == testItem.DPath.GetTag()) { MessageBox.Show(this, "Element (" + item.DPath.GetTagName() + ") has already been in the mapping list"); this.comboBoxTag.Focus(); return(false); } } // avoid duplicated CS Broker field in inbound interface or in query criteria list of outbound interface if (_isInbound || !_isQueryResult) { foreach (T item in _itemList) { if (item == _mappingItem) { continue; } if (item.GWDataDBField.Table == GWDataDBTable.None) { continue; } if (item.GWDataDBField.Table == testItem.GWDataDBField.Table && item.GWDataDBField.FieldName == testItem.GWDataDBField.FieldName) { MessageBox.Show(this, "Element (" + item.DPath.GetTagName() + ") has been mapped to this GC Gateway field (" + item.GWDataDBField.GetFullFieldName() + "). \r\n" + "Pease change another GC Gateway field.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.comboBoxField.Focus(); return(false); } } } // delete items in SQ sequence when VR type change from non-SQ to SQ if (_mappingItem.DPath.VR == DVR.SQ && testItem.DPath.VR != DVR.SQ) { int index = _itemList.IndexOf(_mappingItem); if (DicomMappingHelper.HasSequence <T>(index, _itemList)) { if (MessageBox.Show(this, "Changing VR type from \"SQ\" to \"" + testItem.DPath.VR.ToString() + "\" will automatically delete all elements in the SQ sequence.\r\nAre you sure to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DicomMappingHelper.DeleteSequence <T>(index, _itemList); } else { return(false); } } } // save field and tag information _fieldControler.SaveSetting(_mappingItem); if (_addChild && _baseItem != null) { _tagControler.SaveSetting(_mappingItem.DPath, _baseItem.DPath); } else { if (sqIndex < 0) { _tagControler.SaveSetting(_mappingItem.DPath, null); } else { _tagControler.SaveSetting(_mappingItem.DPath, _itemList[sqIndex].DPath); } } // save other information _mappingItem.Refresh(); if (_isInbound) { _mappingItem.RedundancyFlag = this.checkBoxRedundancy.Checked; } if (_baseItem == null) { _mappingItem.DPath.Catagory = this.textBoxListGroup.Text.Trim(); } return(true); }