示例#1
0
        private IGalleryObjectMetadataItem GetApertureMetadataItem()
        {
            // The aperture is the same as the F-Number if present; otherwise it is calculated from ExifAperture.
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;
            string       aperture          = String.Empty;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFNumber, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    float exifFNumber = ((Fraction)rawMdi.Value).ToSingle();
                    aperture = exifFNumber.ToString("f/##0.#", CultureInfo.InvariantCulture);
                }
            }

            if ((String.IsNullOrEmpty(aperture)) && (RawMetadata.TryGetValue(RawMetadataItemName.ExifAperture, out rawMdi)))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    float exifAperture = ((Fraction)rawMdi.Value).ToSingle();
                    float exifFNumber  = (float)Math.Round(Math.Pow(Math.Sqrt(2), exifAperture), 1);
                    aperture = exifFNumber.ToString("f/##0.#", CultureInfo.InvariantCulture);
                }
            }

            if (!String.IsNullOrEmpty(aperture))
            {
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.LensAperture, Resources.Metadata_LensAperture, aperture, true);
            }

            return(mdi);
        }
        /// <summary>
        /// Create a new <see cref="IGalleryObjectMetadataItem"/> item from the specified parameters and add it to the collection. Return a
        /// reference to the new item.
        /// </summary>
        /// <param name="mediaObjectMetadataId">A value that uniquely indentifies this metadata item.</param>
        /// <param name="metadataItemName">The name of this metadata item.</param>
        /// <param name="description">The description of the metadata item (e.g. "Exposure time", "Camera model")</param>
        /// <param name="value">The value of the metadata item (e.g. "F5.7", "1/500 sec.").</param>
        /// <param name="hasChanges">A value indicating whether this metadata item has changes that have not been persisted to the database.</param>
        /// <returns>Returns a reference to the new item.</returns>
        public IGalleryObjectMetadataItem AddNew(int mediaObjectMetadataId, FormattedMetadataItemName metadataItemName, string description, string value, bool hasChanges)
        {
            IGalleryObjectMetadataItem metadataItem = new GalleryObjectMetadataItem(mediaObjectMetadataId, metadataItemName, description, value, hasChanges);

            Items.Add(metadataItem);

            return(metadataItem);
        }
示例#3
0
        private IGalleryObjectMetadataItem GetStringMetadataItem(RawMetadataItemName sourceRawMetadataName, FormattedMetadataItemName destinationFormattedMetadataName, string metadataDescription, string formatString)
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(sourceRawMetadataName, out rawMdi))
            {
                mdi = new GalleryObjectMetadataItem(int.MinValue, destinationFormattedMetadataName, metadataDescription, String.Format(CultureInfo.CurrentCulture, formatString, rawMdi.Value.ToString().TrimEnd(new char[] { '\0' })), true);
            }
            return(mdi);
        }
示例#4
0
        private IGalleryObjectMetadataItem GetWidthMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            int width = GetWidth();

            if (width > 0)
            {
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Width, Resources.Metadata_Width, String.Concat(width, " ", Resources.Metadata_Width_Units), true);
            }

            return(mdi);
        }
示例#5
0
        private IGalleryObjectMetadataItem GetHeightMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            int height = GetHeight();

            if (height > 0)
            {
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Height, Resources.Metadata_Height, String.Concat(height, " ", Resources.Metadata_Height_Units), true);
            }

            return(mdi);
        }
示例#6
0
        private IGalleryObjectMetadataItem GetDimensionsMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            int width  = GetWidth();
            int height = GetHeight();

            if ((width > 0) && (height > 0))
            {
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Dimensions, Resources.Metadata_Dimensions, String.Concat(width, " x ", height), true);
            }

            return(mdi);
        }
示例#7
0
        private IGalleryObjectMetadataItem GetColorRepresentationMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifColorSpace, out rawMdi))
            {
                string value          = rawMdi.Value.ToString().Trim();
                string formattedValue = (value == "1" ? Resources.Metadata_ColorRepresentation_sRGB : Resources.Metadata_ColorRepresentation_Uncalibrated);
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ColorRepresentation, Resources.Metadata_ColorRepresentation, formattedValue, true);
            }
            return(mdi);
        }
示例#8
0
        /// <summary>
        /// Gets a metadata item containing the date the picture was taken. The date format conforms to the IETF RFC 1123 specification,
        /// which means it uses this format string: "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'" (e.g. "Mon, 17 Apr 2006 21:38:09 GMT"). See
        /// the DateTimeFormatInfo.RFC1123Pattern property for more information about the format. Returns null if no date is found
        /// in the metadata.
        /// </summary>
        /// <returns>Returns a metadata item containing the date the picture was taken. Returns null if no date is found
        /// in the metadata.</returns>
        private IGalleryObjectMetadataItem GetDatePictureTakenMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifDTOrig, out rawMdi))
            {
                DateTime convertedDateTimeValue = ConvertExifDateTimeToDateTime(rawMdi.Value.ToString());
                if (convertedDateTimeValue > DateTime.MinValue)
                {
                    mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.DatePictureTaken, Resources.Metadata_DatePictureTaken, convertedDateTimeValue.ToString("R", CultureInfo.InvariantCulture), true);
                }
            }
            return(mdi);
        }
示例#9
0
        private IGalleryObjectMetadataItem GetFocalLengthMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFocalLength, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    float  value          = ((Fraction)rawMdi.Value).ToSingle();
                    string formattedValue = String.Concat(Math.Round(value), " ", Resources.Metadata_FocalLength_Units);
                    mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.FocalLength, Resources.Metadata_FocalLength, formattedValue, true);
                }
            }
            return(mdi);
        }
示例#10
0
        private IGalleryObjectMetadataItem GetExposureCompensationMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifExposureBias, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    float  value          = ((Fraction)rawMdi.Value).ToSingle();
                    string formattedValue = String.Concat(value.ToString("##0.# ", CultureInfo.InvariantCulture), Resources.Metadata_ExposureCompensation_Suffix);
                    mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ExposureCompensation, Resources.Metadata_ExposureCompensation, formattedValue, true);
                }
            }
            return(mdi);
        }
示例#11
0
        private IGalleryObjectMetadataItem GetFNumberMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFNumber, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    float  value          = ((Fraction)rawMdi.Value).ToSingle();
                    string formattedValue = value.ToString("f/##0.#", CultureInfo.InvariantCulture);
                    mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.FNumber, Resources.Metadata_FNumber, formattedValue, true);
                }
            }
            return(mdi);
        }
示例#12
0
        private IGalleryObjectMetadataItem GetFlashModeMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFlash, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
                {
                    FlashMode flashMode = (FlashMode)(Int64)rawMdi.Value;
                    if (MetadataEnumHelper.IsValidFlashMode(flashMode))
                    {
                        mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.FlashMode, Resources.Metadata_FlashMode, flashMode.ToString(), true);
                    }
                }
            }
            return(mdi);
        }
示例#13
0
        private IGalleryObjectMetadataItem GetExposureProgramMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifExposureProg, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
                {
                    ExposureProgram expProgram = (ExposureProgram)(Int64)rawMdi.Value;
                    if (MetadataEnumHelper.IsValidExposureProgram(expProgram))
                    {
                        mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ExposureProgram, Resources.Metadata_ExposureProgram, expProgram.ToString(), true);
                    }
                }
            }
            return(mdi);
        }
示例#14
0
        private IGalleryObjectMetadataItem GetYResolutionMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;
            string       resolutionUnit    = String.Empty;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ResolutionYUnit, out rawMdi))
            {
                resolutionUnit = rawMdi.Value.ToString();
            }

            if ((String.IsNullOrEmpty(resolutionUnit)) && (RawMetadata.TryGetValue(RawMetadataItemName.ResolutionUnit, out rawMdi)))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
                {
                    ResolutionUnit resUnit = (ResolutionUnit)(Int64)rawMdi.Value;
                    if (MetadataEnumHelper.IsValidResolutionUnit(resUnit))
                    {
                        resolutionUnit = resUnit.ToString();
                    }
                }
            }

            if (RawMetadata.TryGetValue(RawMetadataItemName.YResolution, out rawMdi))
            {
                string yResolution;
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    yResolution = Math.Round(((Fraction)rawMdi.Value).ToSingle(), 2).ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    yResolution = rawMdi.Value.ToString();
                }

                string yResolutionString = String.Concat(yResolution, " ", resolutionUnit);
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.VerticalResolution, Resources.Metadata_VerticalResolution, yResolutionString, true);
            }

            return(mdi);
        }
示例#15
0
        private IGalleryObjectMetadataItem GetLightSourceMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifLightSource, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
                {
                    LightSource lightSource = (LightSource)(Int64)rawMdi.Value;
                    if (MetadataEnumHelper.IsValidLightSource(lightSource))
                    {
                        // Don't bother with it if it is "Unknown"
                        if (lightSource != LightSource.Unknown)
                        {
                            mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.LightSource, Resources.Metadata_LightSource, lightSource.ToString(), true);
                        }
                    }
                }
            }
            return(mdi);
        }
示例#16
0
        private IGalleryObjectMetadataItem GetExposureTimeMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi            = null;
            const Single NUM_SECONDS       = 1;       // If the exposure time is less than this # of seconds, format as fraction (1/350 sec.); otherwise convert to Single (2.35 sec.)

            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifExposureTime, out rawMdi))
            {
                string exposureTime = String.Empty;
                if ((rawMdi.ExtractedValueType == ExtractedValueType.Fraction) && ((Fraction)rawMdi.Value).ToSingle() > NUM_SECONDS)
                {
                    exposureTime = Math.Round(((Fraction)rawMdi.Value).ToSingle(), 2).ToString(CultureInfo.InvariantCulture);
                }
                else
                {
                    exposureTime = rawMdi.Value.ToString();
                }

                string exposureTimeString = String.Concat(exposureTime, " ", Resources.Metadata_ExposureTime_Units);
                mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ExposureTime, Resources.Metadata_ExposureTime, exposureTimeString, true);
            }
            return(mdi);
        }
		private IGalleryObjectMetadataItem GetExposureTimeMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			const Single NUM_SECONDS = 1; // If the exposure time is less than this # of seconds, format as fraction (1/350 sec.); otherwise convert to Single (2.35 sec.)
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifExposureTime, out rawMdi))
			{
				string exposureTime = String.Empty;
				if ((rawMdi.ExtractedValueType == ExtractedValueType.Fraction) && ((Fraction)rawMdi.Value).ToSingle() > NUM_SECONDS)
				{
					exposureTime = Math.Round(((Fraction)rawMdi.Value).ToSingle(), 2).ToString(CultureInfo.InvariantCulture);
				}
				else
				{
					exposureTime = rawMdi.Value.ToString();
				}

				string exposureTimeString = String.Concat(exposureTime, " ", Resources.Metadata_ExposureTime_Units);
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ExposureTime, Resources.Metadata_ExposureTime, exposureTimeString, true);
			}
			return mdi;
		}
		/// <summary>
		/// Gets a metadata item containing the date the picture was taken. The date format conforms to the IETF RFC 1123 specification,
		/// which means it uses this format string: "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'" (e.g. "Mon, 17 Apr 2006 21:38:09 GMT"). See 
		/// the DateTimeFormatInfo.RFC1123Pattern property for more information about the format. Returns null if no date is found 
		/// in the metadata.
		/// </summary>
		/// <returns>Returns a metadata item containing the date the picture was taken. Returns null if no date is found 
		/// in the metadata.</returns>
		private IGalleryObjectMetadataItem GetDatePictureTakenMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifDTOrig, out rawMdi))
			{
				DateTime convertedDateTimeValue = ConvertExifDateTimeToDateTime(rawMdi.Value.ToString());
				if (convertedDateTimeValue > DateTime.MinValue)
				{
					mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.DatePictureTaken, Resources.Metadata_DatePictureTaken, convertedDateTimeValue.ToString("R", CultureInfo.InvariantCulture), true);
				}
			}
			return mdi;
		}
        private IGalleryObjectMetadataItem GetSubjectDistanceMetadataItem()
        {
            IGalleryObjectMetadataItem mdi = null;
            MetadataItem rawMdi;
            if (RawMetadata.TryGetValue(RawMetadataItemName.ExifSubjectDist, out rawMdi))
            {
                if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
                {
                    double distance = ((Fraction)rawMdi.Value).ToSingle();

                    if (distance > 1)
                    {
                        distance = Math.Round(distance, 1);
                    }

                    string formattedValue = String.Concat(distance.ToString("0.### ", CultureInfo.InvariantCulture), Resources.Metadata_SubjectDistance_Units);
                    mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.SubjectDistance, Resources.Metadata_SubjectDistance, formattedValue, true);
                }
                else
                {
                    string value = rawMdi.Value.ToString().Trim().TrimEnd(new char[] { '\0' });

                    if (!String.IsNullOrEmpty(value))
                    {
                        mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.SubjectDistance, Resources.Metadata_SubjectDistance, String.Format(CultureInfo.CurrentCulture, String.Concat("{0} ", Resources.Metadata_SubjectDistance_Units), value), true);
                    }
                }
            }

            return mdi;
        }
		private IGalleryObjectMetadataItem GetExposureCompensationMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifExposureBias, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
				{
					float value = ((Fraction)rawMdi.Value).ToSingle();
					string formattedValue = String.Concat(value.ToString("##0.# ", CultureInfo.InvariantCulture), Resources.Metadata_ExposureCompensation_Suffix);
					mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ExposureCompensation, Resources.Metadata_ExposureCompensation, formattedValue, true);
				}
			}
			return mdi;
		}
		private IGalleryObjectMetadataItem GetFocalLengthMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFocalLength, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
				{
					float value = ((Fraction)rawMdi.Value).ToSingle();
					string formattedValue = String.Concat(Math.Round(value), " ", Resources.Metadata_FocalLength_Units);
					mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.FocalLength, Resources.Metadata_FocalLength, formattedValue, true);
				}
			}
			return mdi;
		}
		private IGalleryObjectMetadataItem GetLightSourceMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifLightSource, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
				{
					LightSource lightSource = (LightSource)(Int64)rawMdi.Value;
					if (MetadataEnumHelper.IsValidLightSource(lightSource))
					{
						// Don't bother with it if it is "Unknown"
						if (lightSource != LightSource.Unknown)
						{
							mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.LightSource, Resources.Metadata_LightSource, lightSource.ToString(), true);
						}
					}
				}
			}
			return mdi;
		}
		private IGalleryObjectMetadataItem GetFNumberMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFNumber, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
				{
					float value = ((Fraction)rawMdi.Value).ToSingle();
					string formattedValue = value.ToString("f/##0.#", CultureInfo.InvariantCulture);
					mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.FNumber, Resources.Metadata_FNumber, formattedValue, true);
				}
			}
			return mdi;
		}
		private IGalleryObjectMetadataItem GetYResolutionMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			string resolutionUnit = String.Empty;

			if (RawMetadata.TryGetValue(RawMetadataItemName.ResolutionYUnit, out rawMdi))
			{
				resolutionUnit = rawMdi.Value.ToString();
			}

			if ((String.IsNullOrEmpty(resolutionUnit)) && (RawMetadata.TryGetValue(RawMetadataItemName.ResolutionUnit, out rawMdi)))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
				{
					ResolutionUnit resUnit = (ResolutionUnit)(Int64)rawMdi.Value;
					if (MetadataEnumHelper.IsValidResolutionUnit(resUnit))
					{
						resolutionUnit = resUnit.ToString();
					}
				}
			}

			if (RawMetadata.TryGetValue(RawMetadataItemName.YResolution, out rawMdi))
			{
				string yResolution;
				if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
				{
					yResolution = Math.Round(((Fraction)rawMdi.Value).ToSingle(), 2).ToString(CultureInfo.InvariantCulture);
				}
				else
				{
					yResolution = rawMdi.Value.ToString();
				}

				string yResolutionString = String.Concat(yResolution, " ", resolutionUnit);
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.VerticalResolution, Resources.Metadata_VerticalResolution, yResolutionString, true);
			}

			return mdi;
		}
		private IGalleryObjectMetadataItem GetApertureMetadataItem()
		{
			// The aperture is the same as the F-Number if present; otherwise it is calculated from ExifAperture.
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			string aperture = String.Empty;

			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFNumber, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
				{
					float exifFNumber = ((Fraction)rawMdi.Value).ToSingle();
					aperture = exifFNumber.ToString("f/##0.#", CultureInfo.InvariantCulture);
				}
			}

			if ((String.IsNullOrEmpty(aperture)) && (RawMetadata.TryGetValue(RawMetadataItemName.ExifAperture, out rawMdi)))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Fraction)
				{
					float exifAperture = ((Fraction)rawMdi.Value).ToSingle();
					float exifFNumber = (float)Math.Round(Math.Pow(Math.Sqrt(2), exifAperture), 1);
					aperture = exifFNumber.ToString("f/##0.#", CultureInfo.InvariantCulture);
				}
			}

			if (!String.IsNullOrEmpty(aperture))
			{
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.LensAperture, Resources.Metadata_LensAperture, aperture, true);
			}

			return mdi;
		}
		private IGalleryObjectMetadataItem GetWidthMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			int width = GetWidth();

			if (width > 0)
			{
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Width, Resources.Metadata_Width, String.Concat(width, " ", Resources.Metadata_Width_Units), true);
			}

			return mdi;
		}
		private IGalleryObjectMetadataItem GetDimensionsMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			int width = GetWidth();
			int height = GetHeight();

			if ((width > 0) && (height > 0))
			{
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Dimensions, Resources.Metadata_Dimensions, String.Concat(width, " x ", height), true);
			}

			return mdi;
		}
		private IGalleryObjectMetadataItem GetHeightMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			int height = GetHeight();

			if (height > 0)
			{
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Height, Resources.Metadata_Height, String.Concat(height, " ", Resources.Metadata_Height_Units), true);
			}

			return mdi;
		}
		private IGalleryObjectMetadataItem GetFlashModeMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifFlash, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
				{
					FlashMode flashMode = (FlashMode)(Int64)rawMdi.Value;
					if (MetadataEnumHelper.IsValidFlashMode(flashMode))
					{
						mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.FlashMode, Resources.Metadata_FlashMode, flashMode.ToString(), true);
					}
				}
			}
			return mdi;
		}
		private IGalleryObjectMetadataItem GetStringMetadataItem(RawMetadataItemName sourceRawMetadataName, FormattedMetadataItemName destinationFormattedMetadataName, string metadataDescription, string formatString)
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(sourceRawMetadataName, out rawMdi))
			{
				mdi = new GalleryObjectMetadataItem(int.MinValue, destinationFormattedMetadataName, metadataDescription, String.Format(CultureInfo.CurrentCulture, formatString, rawMdi.Value.ToString().TrimEnd(new char[] { '\0' })), true);
			}
			return mdi;
		}
        /// <summary>
        /// Parses the <paramref name="ffmpegOutput" /> data and adds useful metadata items to the <paramref name="metadataItems" />
        /// collection.
        /// </summary>
        /// <param name="ffmpegOutput">The text output from the execution of the FFmpeg utility against a media file.</param>
        /// <param name="metadataItems">The collection of <see cref="IGalleryObjectMetadataItem" /> objects to add to.</param>
        private static void ParseVideoMetadata(string ffmpegOutput, IGalleryObjectMetadataItemCollection metadataItems)
        {
            //Use a regular expression to get the different properties from the video parsed out.
            Regex re = new Regex("[D|d]uration:.((\\d|:|\\.)*)");
            Match m = re.Match(ffmpegOutput);

            if (m.Success)
            {
                //string dur = m.Groups[1].Value;
                //string[] timepieces = dur.Split(new char[] { ':', '.' });
                //if (timepieces.Length == 4)
                //{
                //TimeSpan duration = new TimeSpan(0, Convert.ToInt16(timepieces[0]), Convert.ToInt16(timepieces[1]), Convert.ToInt16(timepieces[2]), Convert.ToInt16(timepieces[3]));
                GalleryObjectMetadataItem mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Duration, Resources.Metadata_Duration, m.Groups[1].Value.Trim(), true);
                AddMetadataItem(metadataItems, mdi);
                //}
            }

            //get bit rate
            re = new Regex("[B|b]itrate:.((\\d|:)*)");
            m = re.Match(ffmpegOutput);
            double kb;
            if (m.Success && Double.TryParse(m.Groups[1].Value, out kb))
            {
                //TODO: Parse bitrate units instead of assuming they are kb/s
                // Line we are parsing looks like this: Duration: 00:00:25.27, start: 0.000000, bitrate: 932 kb/s
                GalleryObjectMetadataItem mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.BitRate, Resources.Metadata_BitRate, String.Concat(kb, " kb/s"), true);
                AddMetadataItem(metadataItems, mdi);
            }

            //get the audio format
            re = new Regex("[A|a]udio:.*");
            m = re.Match(ffmpegOutput);
            if (m.Success)
            {
                GalleryObjectMetadataItem mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.AudioFormat, Resources.Metadata_AudioFormat, m.Value.Trim(), true);
                AddMetadataItem(metadataItems, mdi);
            }

            //get the video format
            re = new Regex("[V|v]ideo:.*");
            m = re.Match(ffmpegOutput);
            if (m.Success)
            {
                GalleryObjectMetadataItem mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.VideoFormat, Resources.Metadata_VideoFormat, m.Value.Trim(), true);
                AddMetadataItem(metadataItems, mdi);
            }

            //get the video width and height
            // TODO: Get width and height from the metadata lines rather than looking for "200x300"
            re = new Regex("(\\d{2,4})x(\\d{2,4})");
            m = re.Match(ffmpegOutput);
            if (m.Success)
            {
                int width; int height;
                int.TryParse(m.Groups[1].Value, out width);
                int.TryParse(m.Groups[2].Value, out height);

                GalleryObjectMetadataItem mdiWidth = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Width, Resources.Metadata_Width, String.Concat(width, " ", Resources.Metadata_Width_Units), true);
                GalleryObjectMetadataItem mdiHeight = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.Height, Resources.Metadata_Height, String.Concat(height, " ", Resources.Metadata_Height_Units), true);

                AddMetadataItem(metadataItems, mdiWidth);
                AddMetadataItem(metadataItems, mdiHeight);
            }
        }
		private IGalleryObjectMetadataItem GetExposureProgramMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifExposureProg, out rawMdi))
			{
				if (rawMdi.ExtractedValueType == ExtractedValueType.Int64)
				{
					ExposureProgram expProgram = (ExposureProgram)(Int64)rawMdi.Value;
					if (MetadataEnumHelper.IsValidExposureProgram(expProgram))
					{
						mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ExposureProgram, Resources.Metadata_ExposureProgram, expProgram.ToString(), true);
					}
				}
			}
			return mdi;
		}
		private IGalleryObjectMetadataItem GetColorRepresentationMetadataItem()
		{
			IGalleryObjectMetadataItem mdi = null;
			MetadataItem rawMdi = null;
			if (RawMetadata.TryGetValue(RawMetadataItemName.ExifColorSpace, out rawMdi))
			{
				string value = rawMdi.Value.ToString().Trim();
				string formattedValue = (value == "1" ? Resources.Metadata_ColorRepresentation_sRGB : Resources.Metadata_ColorRepresentation_Uncalibrated);
				mdi = new GalleryObjectMetadataItem(int.MinValue, FormattedMetadataItemName.ColorRepresentation, Resources.Metadata_ColorRepresentation, formattedValue, true);
			}
			return mdi;
		}
 private static void AddMetadataItem(IGalleryObjectMetadataItemCollection metadataItems, GalleryObjectMetadataItem metadataItem)
 {
     if ((metadataItem != null) && (!metadataItems.Contains(metadataItem)))
     {
         metadataItems.Add(metadataItem);
     }
 }