Click here to Skip to main content
15,895,656 members
Articles / Programming Languages / C#

Access image metadata using Visual Studio's new object data binding feature

Rate me:
Please Sign up or sign in to vote.
4.85/5 (13 votes)
1 Feb 200712 min read 83.3K   975   46  
Using a new class library to bind to photo metadata with a few line of code.
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
namespace Reynsoft.PhotoInfo
{
    /// <summary>
    /// The XmpTPgMetadata class
    /// </summary>
    public class XmpTPgMetadata : PhotoMetadata
    {
        /// <summary>
        /// Private constructor to enforce the factory pattern.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="doc"></param>
        private XmpTPgMetadata(XmlNode node, XmlDocument doc): base(node, doc)
	      {
 	      }
        /// <summary>
        /// The public factory method.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static XmpTPgMetadata CreateNewXmpTPgMetadata(XmlNode node, XmlDocument doc)
	      {
            if (node == null)
            {
                // TODO:  Insert the namespace name and URI for this group.
                //        Leave unchanged if this group is never edited.
                XmlNode emptyNode = CreateEmptyNode("xmlns:xmpTPg", "http://ns.adobe.com/xap/1.0/t/pg/", doc);
                return new XmpTPgMetadata(emptyNode, doc);
            }
            else
            {
                return new XmpTPgMetadata(node, doc);
            }
	      }
		#region Generated property definitions

		private string m_MaxPageSize = null;
		/// <summary>
		/// The size of the largest page in the document (including any
		/// in contained documents).
		/// </summary>
		public string MaxPageSize
		{
			get
			{
				return m_MaxPageSize;
			}
		}

		private string m_NPages = null;
		/// <summary>
		/// The number of pages in the document (including any in
		/// contained documents).
		/// </summary>
		public string NPages
		{
			get
			{
				return m_NPages;
			}
		}

		private string m_Fonts = null;
		/// <summary>
		/// An unordered array of fonts that are used in the document
		/// (including any in contained documents).
		/// </summary>
		public string Fonts
		{
			get
			{
				return m_Fonts;
			}
		}

		private string m_Colorants = null;
		/// <summary>
		/// An ordered array of colorants (swatches) that are used in
		/// the document (including any in contained documents).
		/// </summary>
		public string Colorants
		{
			get
			{
				return m_Colorants;
			}
		}

		private string m_PlateNames = null;
		/// <summary>
		/// An ordered array of plate names that are needed to print the
		/// document (including any in contained documents).
		/// </summary>
		public string PlateNames
		{
			get
			{
				return m_PlateNames;
			}
		}
		#endregion
		#region Generated function to initialize properties
		/// <summary>
		/// Generated function to initialize properties
		/// </summary>
		public override void LoadInitialData()
		{
			this.m_MaxPageSize = GetInitialValue("xmpTPg:MaxPageSize", "Dimensions");
			NotifyPropertyChanged("MaxPageSize");
			this.m_NPages = GetInitialValue("xmpTPg:NPages", "Integer");
			NotifyPropertyChanged("NPages");
			this.m_Fonts = GetInitialValue("xmpTPg:Fonts", "Bag Font");
			NotifyPropertyChanged("Fonts");
			this.m_Colorants = GetInitialValue("xmpTPg:Colorants", "Seq Colorant");
			NotifyPropertyChanged("Colorants");
			this.m_PlateNames = GetInitialValue("xmpTPg:PlateNames", "Seq Text");
			NotifyPropertyChanged("PlateNames");
		}
		#endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This is a picture of John still in the cubicled environment of the Northern Virginia tech world. There are great software jobs there, but the traffic is horrible! He has since retired, or really, started a new, freer lifestyle. He now travels and takes photographs. At home, he is involved in a number of community activities including work at the Historical Society of Frederick County (MD) where he has helped preserve historic documents and photographs by making photographic copies. Some of them are posted on the HSFC photo catalog website. He is fascinated by the new ability, using applications like Google Earth, to link photos to geographic locations. This adds a new dimension to photography, which he is working to develop. These pursuits, which require the ability to access and manage photo metadata, are a major motivation for getting involved as deeply as he did in this exciting topic.

Comments and Discussions