// // - Methods - // /// <summary> /// Check if the supplied values are equal to the content of this object. /// </summary> /// <param name="values">Values to compare with.</param> /// <returns>Boolean indicating if the Values are equal.</returns> public override bool EqualTo(Values values) { // Start Interface logging. // InterfaceLogging.Start(this, values); bool equalTo = true; if (values is InvalidValues) { InvalidValues attributeToCompareWith = values as InvalidValues; // InterfaceLogging.WriteError("Comparing the values of two non-existing attributes with tag sequence " + this.TagSequence + " and " + attributeToCompareWith.TagSequence + "\r\nReturning true."); equalTo = true; } else if (values is ValidValues) { ValidValues validValues = values as ValidValues; // InterfaceLogging.WriteError("Comparing the value of a non-existing sttribute with tag " + this.TagSequence + " with valid values from attribute with tag " + validValues.TagSequence + ".\r\nReturning false."); equalTo = false; } else { // InterfaceLogging.WriteError("This type of Values descendant object not expected. Returning false."); equalTo = false; } // End Interface logging. // InterfaceLogging.End(equalTo); return(equalTo); }
private static void SetSimpleAttribute(AttributeSet attributeSet, SetParameterGroup setParameterGroup) { ArrayList attributeValuesAsStrings = new ArrayList(); bool validStringValues = true; foreach (Object parameter in setParameterGroup.values) { if (parameter is ValidValues) { ValidValues validValues = parameter as ValidValues; for (int valueIndex = 1; valueIndex <= validValues.Count; valueIndex++) { attributeValuesAsStrings.Add(validValues.GetString(valueIndex)); } } else if (parameter is InvalidValues) { InvalidValues invalidValues = parameter as InvalidValues; // InterfaceLogging.WriteError("Setting an attribute with tag " + setParameterGroup.tagAsString + " fails because one of the supplied values is from a non-existing attribute with tag " + invalidValues.TagSequence); validStringValues = false; break; } else { attributeValuesAsStrings.Add(parameter.ToString()); } } if (validStringValues) { ValidAttribute validAttribute = new ValidAttribute(setParameterGroup.tagAsUInt32, setParameterGroup.vR, attributeValuesAsStrings.ToArray()); attributeSet.Set(validAttribute); } }
public Values GetAttributeValues(int index) { Values theValues = null; Attribute attribute = GetAttribute(index); if (attribute == null) { // InterfaceLogging.WriteError("Attribute does not exist."); // Temporary. theValues = new InvalidValues("0x00000000"); } else { if (attribute is SimpleAttribute) { SimpleAttribute simpleAttribute = attribute as SimpleAttribute; theValues = simpleAttribute.GetValues(); } else if (attribute is PixelDataAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for pixel data attributes in the High Level Interface./r/nReturning single empty string"); // Temporary. theValues = new ValidValues("0x00000000", ""); } else if (attribute is SequenceAttribute) { // InterfaceLogging.WriteError("Attribute with tag sequence " + tagSequence + " is a sequence attribute."); // Temporary. theValues = new InvalidValues("0x00000000"); } else if (attribute is UnknownAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for attributes with VR Unknown in the High Level Interface./r/nReturning single empty string"); // Temporary. theValues = new ValidValues("0x00000000", ""); } else { DvtkHighLevelInterfaceException.Throw("Not expecting this type of attribute in the code"); } } // End Interface logging. // InterfaceLogging.End(theValues); return(theValues); }
/// <summary> /// Check if the supplied values are equal to the content of this object. /// </summary> /// <param name="values">Values to compare with.</param> /// <returns>Boolean indicating if the Values are equal.</returns> public override bool EqualTo(Values values) { // Start Interface logging. // InterfaceLogging.Start(this, values); bool equalTo = true; if (values is InvalidValues) { InvalidValues invalidValues = values as InvalidValues; // InterfaceLogging.WriteError("the values to compare with are from a non-existing attribute with tag sequence" + invalidValues.TagSequence + ".\r\nReturning false."); equalTo = false; } else if (values is ValidValues) { ValidValues validValues = values as ValidValues; if (Count == validValues.Count) { for (int index = 1; index <= Count; index++) { if (GetString(index) != validValues.GetString(index)) { equalTo = false; break; } } } else { equalTo = false; } } else { // InterfaceLogging.WriteError("This type of Values descendant object not expected.\r\n Returning false."); equalTo = false; } // End Interface logging. // InterfaceLogging.End(equalTo); return(equalTo); }
/// <summary> /// Get the values for an attribute. /// </summary> /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/').</param> /// <returns>The values.</returns> public Values GetAttributeValues(String tagSequence) { // Start Interface logging. // InterfaceLogging.Start(this, tagSequence); Values theValues = null; Attribute attribute = GetAttribute(tagSequence); if (attribute == null) { // InterfaceLogging.WriteError("Attribute does not exist."); theValues = new InvalidValues(tagSequence); } else { if (attribute is SimpleAttribute) { SimpleAttribute simpleAttribute = attribute as SimpleAttribute; theValues = simpleAttribute.GetValues(); } else if (attribute is PixelDataAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for pixel data attributes in the High Level Interface./r/nReturning single empty string"); theValues = new ValidValues(tagSequence, ""); } else if (attribute is SequenceAttribute) { // InterfaceLogging.WriteError("Attribute with tag sequence " + tagSequence + " is a sequence attribute."); theValues = new InvalidValues(tagSequence); } else if (attribute is UnknownAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for attributes with VR Unknown in the High Level Interface./r/nReturning single empty string"); theValues = new ValidValues(tagSequence, ""); } else { DvtkHighLevelInterfaceException.Throw("Not expecting this type of attribute in the code"); } } // End Interface logging. // InterfaceLogging.End(theValues); return theValues; }