using System; using System.IO; /// /// This class was first written by Drew Noakes in Java. /// /// This is public domain software - that is, you can do whatever you want /// with it, and include it software that is licensed under the GNU or the /// BSD license, or whatever other licence you choose, including proprietary /// closed source licenses. I do ask that you leave this header in tact. /// /// If you make modifications to this code that you think would benefit the /// wider community, please send me a copy and I'll post it on my site. /// /// If you make use of this code, Drew Noakes will appreciate hearing /// about it: drew@drewnoakes.com /// /// Latest Java version of this software kept at /// http://drewnoakes.com/ /// /// The C# class was made by Ferret Renaud: /// renaud91@free.fr /// If you find a bug in the C# code, feel free to mail me. /// namespace com.drew.metadata { /// /// This class represent a basic tag /// [Serializable] public class Tag { private int tagType; private Directory directory; /// /// Constructor of the object /// /// the type of this tag /// the directory of this tag public Tag(int aTagType, Directory aDirectory) : base() { tagType = aTagType; directory = aDirectory; } /// /// Gets the tag type as an int /// /// the tag type as an int public int GetTagType() { return tagType; } /// /// Gets the tag type in hex notation as a string with padded leading zeroes if necessary (i.e. 0x100E). /// /// the tag type as a string in hexadecimal notation public string GetTagTypeHex() { string hex = tagType.ToString("X"); while (hex.Length < 4) hex = "0" + hex; return "0x" + hex; } /// /// Get a description of the tag's value, considering enumerated values and units. /// /// a description of the tag's value public string GetDescription() { return directory.GetDescription(tagType); } /// /// Get the name of the tag, such as Aperture, or InteropVersion. /// /// the tag's name public string GetTagName() { return directory.GetTagName(tagType); } /// /// Get the name of the directory in which the tag exists, such as Exif, GPS or Interoperability. /// /// name of the directory in which this tag exists public string GetDirectoryName() { return directory.GetName(); } /// /// A basic representation of the tag's type and value in format: FNumber - F2.8. /// /// the tag's type and value public override string ToString() { string description; try { description = GetDescription(); } catch (MetadataException ) { description = directory.GetString(GetTagType()) + " (unable to formulate description)"; } return "[" + directory.GetName() + "] " + GetTagName() + " - " + description; } } }