Exemple #1
0
        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);
        }
Exemple #2
0
        public T AddChild <T>(Form parentForm, XCollection <T> list)
            where T : MappingItem, IDicomMappingItem, new()
        {
            T selitem = GetSelectedItem() as T;

            if (selitem == null || selitem.DPath.VR != DVR.SQ)
            {
                return(null);
            }

            FormElement2 <T> frm = new FormElement2 <T>(null, list, selitem, true, _gwDataDBConnection, _log, _asQueryResult, _isInbound);

            BeforeShowFormElement(ButtonType.AddChild, frm, selitem);
            if (frm.ShowDialog(parentForm) != DialogResult.OK)
            {
                return(null);
            }
            AfterShowFormElement(ButtonType.AddChild, frm, selitem);

            T newitem = frm.MappingItem;

            if (newitem == null)
            {
                return(null);
            }

            int  index    = list.IndexOf(selitem);
            bool hasChild = DicomMappingHelper.HasSequence <T>(index, list);

            if (hasChild == false)
            {
                T iBegin = new T();
                DPath.SetItemGroupPathBegin(iBegin.DPath, 0);
                T iEnd = new T();
                DPath.SetItemGroupPathEnd(iEnd.DPath, 0);

                int sqIndex = index + 1;
                list.Insert(sqIndex++, iBegin);
                list.Insert(sqIndex, iEnd);
            }

            if (DicomMappingHelper.FindEndDPathIndex <T>(ref index, list))
            {
                newitem.DPath.Catagory = selitem.DPath.Catagory;
                list.Insert(index, newitem);
            }

            return(newitem);
        }
Exemple #3
0
        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);
        }