Exemplo n.º 1
0
		/// <summary>
		/// Recursive function for handling Seq attributes
		/// </summary>
		/// <param name="attribute"></param>
		void GetSeqAttributesValues(HLI.Attribute attribute)
		{
			int itemCount = attribute.ItemCount;
			int sqVm = 1;
			string displayTagString = "";
			
			for(int i=0; i < levelOfSeq; i++)
				displayTagString += ">";
			displayTagString += TagString(attribute.GroupNumber,attribute.ElementNumber);

			// Attribute name 
			string attributeName = attribute.Name;
			if(attributeName == "")
				attributeName = "Undefined";

			// Add the sequence attribute to the DataGrid
			AttributeProperty theSeqAttributeInfo = 
				new AttributeProperty(displayTagString,
				attributeName,
				"SQ",
				sqVm.ToString(),
				"",
				attribute);

			_AttributesInfoForDataGrid.Add(theSeqAttributeInfo);

			for( int i=0; i < itemCount; i++ )
			{
				string itemString = "";

				for(int j=0; j < levelOfSeq; j++)
					itemString += ">";
				itemString += string.Format(">BEGIN ITEM {0}", i+1);

				AttributeProperty theDataGridItemInfo = 
					new AttributeProperty(itemString,
					"",
					"",
					"",
					"",
					attribute);
				_AttributesInfoForDataGrid.Add(theDataGridItemInfo);

				HLI.SequenceItem item = attribute.GetItem(i+1);
				for( int k=0; k < item.Count; k++ )
				{
					HLI.Attribute seqAttribute   = item[k];
					string attributesValues = "";
					string seqTagString = "";
					string seqAttributeName = seqAttribute.Name;
					if(seqAttributeName == "")
						seqAttributeName = "Undefined";

					if (seqAttribute.VR != VR.SQ)
					{
						for(int m=0; m <= levelOfSeq; m++)
							seqTagString += ">";
						seqTagString += TagString(seqAttribute.GroupNumber,seqAttribute.ElementNumber);

						if (seqAttribute.Values.Count != 0)
						{
							for( int l=0; l < seqAttribute.Values.Count; l++ )
							{
								attributesValues += seqAttribute.Values[l] + "\\";
							}

							if (attributesValues.Trim().EndsWith("\\")) 
							{
								// now search for the last "\"...
								int lastLocation = attributesValues.LastIndexOf( "\\" );

								// remove the identified section, if it is a valid region
								if ( lastLocation >= 0 )
									attributesValues =  attributesValues.Substring( 0, lastLocation );
							}						
						}
						else
						{
							attributesValues = "";
						}
					}
					else
					{
						sequenceInSq = true;
						levelOfSeq++;
						GetSeqAttributesValues(seqAttribute);
						sequenceInSq = false;
						--levelOfSeq;
						continue;
					}

					AttributeProperty theDataGridSeqAttributeInfo = 
						new AttributeProperty(seqTagString,
						seqAttributeName,
						seqAttribute.VR.ToString(),
						seqAttribute.VM.ToString(),
						attributesValues,
						seqAttribute);

					_AttributesInfoForDataGrid.Add(theDataGridSeqAttributeInfo);
				}

				itemString = "";
				for(int m=0; m < levelOfSeq; m++)
					itemString += ">";
				itemString += string.Format(">END ITEM {0}", i+1);

				AttributeProperty theDataGridEndItemInfo = 
					new AttributeProperty(itemString,
					"",
					"",
					"",
					"",
					null);

				_AttributesInfoForDataGrid.Add(theDataGridEndItemInfo);
			}
		}
Exemplo n.º 2
0
		/// <summary>
		/// Helper function for adding dataset to the datagrid
		/// </summary>
		void AddDatasetInfoToDataGrid()
		{			
			for( int i=0; i < _DCMdataset.Count; i++ )
			{
				HLI.Attribute attribute   = _DCMdataset[i];
				string attributesValues = "";
				string attributeName = attribute.Name;
				if(attributeName == "")
					attributeName = "Undefined";
								
				if (attribute.VR != VR.SQ)
				{
					if (attribute.Values.Count != 0)
					{
						for( int j=0; j < attribute.Values.Count; j++ )
						{
							attributesValues += attribute.Values[j] + "\\";
						}
						
						if (attributesValues.EndsWith("\\")) 
						{
							// now search for the last "\"...
							int lastLocation = attributesValues.LastIndexOf( "\\" );

							// remove the identified section, if it is a valid region
							if ( lastLocation >= 0 )
								attributesValues =  attributesValues.Substring( 0, lastLocation );
						}
					}
					else
					{
						attributesValues = "";
					}
				}
				else
				{
					try
					{
						GetSeqAttributesValues(attribute);
					}
					catch(Exception exception)
					{
						string theErrorText;

						theErrorText = string.Format("DCM file {0} could not be read:\n{1}\n\n", _DCMFileName, exception.Message);

						richTextBoxLog.AppendText(theErrorText);
						richTextBoxLog.ScrollToCaret();
					}

					if(sequenceInSq)
					{
						--levelOfSeq;
						sequenceInSq = false;
					}
					continue;
				}

				AttributeProperty theDataGridAttributeInfo = 
					new AttributeProperty(TagString(attribute.GroupNumber,attribute.ElementNumber),
					attributeName,
					attribute.VR.ToString(),
					attribute.VM.ToString(),
					attributesValues,
					attribute);
				
				_AttributesInfoForDataGrid.Add(theDataGridAttributeInfo);
			}
		}
Exemplo n.º 3
0
		/// <summary>
		/// Helper function for adding FMI to the datagrid
		/// </summary>
		void AddFMIToDataGrid()
		{			
			for( int i=0; i < _FileMetaInfo.Count; i++ )
			{
				HLI.Attribute attribute   = _FileMetaInfo[i];
				string attributesValues = "";
				string attributeName = attribute.Name;
				if(attributeName == "")
					attributeName = "Undefined";
								
				if (attribute.Values.Count != 0)
				{
					for( int j=0; j < attribute.Values.Count; j++ )
					{
						attributesValues += attribute.Values[j] + "\\";
					}
					
					if (attributesValues.EndsWith("\\")) 
					{
						// now search for the last "\"...
						int lastLocation = attributesValues.LastIndexOf( "\\" );

						// remove the identified section, if it is a valid region
						if ( lastLocation >= 0 )
							attributesValues =  attributesValues.Substring( 0, lastLocation );
					}
				}
				else
				{
					attributesValues = "";
				}

				AttributeProperty theDataGridAttributeInfo = 
					new AttributeProperty(TagString(attribute.GroupNumber,attribute.ElementNumber),
					attributeName,
					attribute.VR.ToString(),
					attribute.VM.ToString(),
					attributesValues,
					attribute);
				
				_FMIForDataGrid.Add(theDataGridAttributeInfo);
			}

			//Pass the DCM Editor object for updating FMI grid
			AttributeProperty attrProperty = new AttributeProperty(this);
		}
Exemplo n.º 4
0
		private void dataGridAttributes_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
            DataGridView.HitTestInfo theHitTestInfo;
			
			// Find out what part of the data grid is below the mouse pointer.
			theHitTestInfo = dataGridAttributes.HitTest(e.X, e.Y);

			switch (theHitTestInfo.Type)
			{
                case DataGridViewHitTestType.Cell:
				{
					menuItem_CopyItem.Visible = false;
					menuItem_DeleteAttribute.Visible = false;
					menuItem_AddNewAttribute.Visible = false;
					menuItem_AddNewAttribute.Text = "Add New Attribute";
					menuItem_DeleteAttribute.Text = "Delete Attribute";

                    //if(selectedRow != -1)
                    //{
                    //    if(dataGridAttributes.IsSelected(selectedRow))
                    //    {
                    //        dataGridAttributes.UnSelect(selectedRow);
                    //    }
                    //}

					//selectedRow = theHitTestInfo.Row;
                    theSelectedAttributeProperty = (AttributeProperty)_AttributesInfoForDataGrid[theHitTestInfo.RowIndex];
					//dataGridAttributes.Select(theHitTestInfo.Row);

					// Check for BEGIN ITEM & END ITEM rows
					if((theSelectedAttributeProperty.AttributeTag.IndexOf("BEGIN") == -1) &&
						(theSelectedAttributeProperty.AttributeTag.IndexOf("END") == -1))
					{
						menuItem_AddNewAttribute.Visible = true;
						menuItem_DeleteAttribute.Visible = true;
						menuItem_CopyItem.Visible = false;
					}
					else
					{
						menuItem_AddNewAttribute.Visible = true;
						menuItem_CopyItem.Visible = true;
						menuItem_DeleteAttribute.Visible = true;
						menuItem_DeleteAttribute.Text = "Delete Sequence Item";
					}
					//Check for Sequence attribute
					if(theSelectedAttributeProperty.AttributeVR == "SQ")
					{
						menuItem_AddNewAttribute.Visible = true;
						menuItem_AddNewAttribute.Text = "Add Sequence Item";
					}

					//Check for attributes in a sequence item
					if(theSelectedAttributeProperty.AttributeTag.StartsWith(">") && 
					  (theSelectedAttributeProperty.AttributeTag.IndexOf("BEGIN") == -1))
					{
						menuItem_AddNewAttribute.Visible = false;
					}

                    if (dataGridAttributes.SelectedRows.Count > 1)
                    {
                        menuItem_AddNewAttribute.Visible = false;
                        menuItem_DeleteAttribute.Visible = true;
                        menuItem_CopyItem.Visible = false;
                        menuItem_DeleteAttribute.Text = "Delete Selected Attributes";
                    }

					break;
				}
			}		
		}