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

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

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

            T newitem = frm.MappingItem;

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

            if (selitem == null)
            {
                list.Add(newitem);
            }
            else
            {
                newitem.DPath.Catagory = selitem.DPath.Catagory;
                int index = list.IndexOf(selitem);
                list.Insert(index, newitem);
            }

            return(newitem);
        }
Example #3
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);
        }
		private string GetIndexByGenreInCollection(XCollection<Genre> genres, Genre genre)
		{
			string res = string.Empty;
			if (genres != null)
			{
				if (genres.Contains(genre))
				{
					int index = genres.IndexOf(genre);
					return index.ToString(CultureInfo.InvariantCulture);
				}
				else
				{
					for (int i = 0; i < genres.Count; i++)
					{
						string idx = GetIndexByGenreInCollection(genres[i].Children, genre);
						if (!string.IsNullOrEmpty(idx))
						{
							res = i.ToString(CultureInfo.InvariantCulture) + ":" + idx;
							break;
						}
					}
				}
			}
			return res;
		}
Example #5
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);
        }