Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Fill the class-level _rawMetadata dictionary with MetadataItem objects created from the
        /// PropertyItems property of the image. Skip any items that are not defined in the
        /// RawMetadataItemName enumeration.
        /// </summary>
        private void FillRawMetadataDictionary()
        {
            this._rawMetadata = new Dictionary <RawMetadataItemName, MetadataItem>();

            foreach (System.Drawing.Imaging.PropertyItem itemIterator in this._propertyItems)
            {
                RawMetadataItemName metadataName = (RawMetadataItemName)itemIterator.Id;
                if (Enum.IsDefined(typeof(RawMetadataItemName), metadataName))
                {
                    if (!this._rawMetadata.ContainsKey(metadataName))
                    {
                        MetadataItem metadataItem = new MetadataItem(itemIterator);
                        if (metadataItem.Value != null)
                        {
                            this._rawMetadata.Add(metadataName, metadataItem);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
		/// <summary>
		/// Fill the class-level _rawMetadata dictionary with MetadataItem objects created from the
		/// PropertyItems property of the image. Skip any items that are not defined in the 
		/// RawMetadataItemName enumeration.
		/// </summary>
		private void FillRawMetadataDictionary()
		{
			this._rawMetadata = new Dictionary<RawMetadataItemName, MetadataItem>();

			foreach (System.Drawing.Imaging.PropertyItem itemIterator in this._propertyItems)
			{
				RawMetadataItemName metadataName = (RawMetadataItemName)itemIterator.Id;
				if (Enum.IsDefined(typeof(RawMetadataItemName), metadataName))
				{
					if (!this._rawMetadata.ContainsKey(metadataName))
					{
						MetadataItem metadataItem = new MetadataItem(itemIterator);
						if (metadataItem.Value != null)
							this._rawMetadata.Add(metadataName, metadataItem);
					}
				}
			}
		}
 /// <summary>
 /// Serves as a hash function for a particular type.
 /// </summary>
 /// <returns>
 /// A hash code for the current <see cref="MetadataDefinition"/>.
 /// </returns>
 public override int GetHashCode()
 {
     return(MetadataItem.GetHashCode());
 }
        /// <summary>
        /// Fill the class-level _rawMetadata dictionary with MetadataItem objects created from the
        /// PropertyItems property of the image. Skip any items that are not defined in the 
        /// RawMetadataItemName enumeration. Guaranteed to not return null.
        /// </summary>
        private Dictionary<RawMetadataItemName, MetadataItem> GetRawMetadataDictionary()
        {
            var rawMetadata = new Dictionary<RawMetadataItemName, MetadataItem>();

            foreach (var itemIterator in PropertyItems)
            {
                var metadataName = (RawMetadataItemName)itemIterator.Id;
                if (Enum.IsDefined(typeof(RawMetadataItemName), metadataName))
                {
                    if (!rawMetadata.ContainsKey(metadataName))
                    {
                        var metadataItem = new MetadataItem(itemIterator);
                        if (metadataItem.Value != null)
                            rawMetadata.Add(metadataName, metadataItem);
                    }
                }
            }

            return rawMetadata;
        }