コード例 #1
0
        public static void SetExifProperties(this ExifMetadata.Metadata metadata)
        {
            string full = string.Empty;
            Type   type = typeof(ExifMetadata.Metadata);

            foreach (FieldInfo prop in type.GetFields())
            {
                string value   = string.Empty;
                string caption = prop.Name.ToCaption() ?? prop.Name;
                switch (prop.Name)
                {
                case nameof(ExifMetadata.Metadata.ImageDimensions):
                    value = metadata.ImageDimensionsAsString();
                    break;

                case nameof(ExifMetadata.Metadata.Resolution):
                    value = metadata.ResolutionAsString();
                    break;

                case nameof(ExifMetadata.Metadata.Location):
                    GUIPropertyManager.SetProperty("#pictures.exif.location.latitude", string.Empty);
                    GUIPropertyManager.SetProperty("#pictures.exif.location.longitude", string.Empty);
                    if (metadata.Location != null)
                    {
                        string latitude  = metadata.Location.Latitude.ToLatitudeString() ?? string.Empty;
                        string longitude = metadata.Location.Longitude.ToLongitudeString() ?? string.Empty;
                        if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
                        {
                            value = latitude + " / " + longitude;
                            GUIPropertyManager.SetProperty("#pictures.exif.location.latitude", metadata.Location.Latitude.ToMapString());
                            GUIPropertyManager.SetProperty("#pictures.exif.location.longitude", metadata.Location.Longitude.ToMapString());
                        }
                    }
                    break;

                case nameof(ExifMetadata.Metadata.Altitude):
                    if (metadata.Location != null)
                    {
                        value = metadata.Altitude.ToAltitudeString();
                    }
                    break;

                case nameof(ExifMetadata.Metadata.HDR):
                    GUIPropertyManager.SetProperty("#pictures.exif.is" + prop.Name.ToLower(), metadata.HDR ? "true" : "false");
                    continue;

                default:
                    value = ((ExifMetadata.MetadataItem)prop.GetValue(metadata)).DisplayValue ?? string.Empty;
                    break;
                }
                if (!string.IsNullOrEmpty(value))
                {
                    value = value.ToValue() ?? value;
                    full  = full + caption + ": " + value + "\n";
                }
                GUIPropertyManager.SetProperty("#pictures.exif." + prop.Name.ToLower(), value);
            }
            GUIPropertyManager.SetProperty("#pictures.exif.full", full);
            GUIPropertyManager.SetProperty("#pictures.haveexif", metadata.IsEmpty() ? "false" : "true");
        }
コード例 #2
0
ファイル: GUIDialogExif.cs プロジェクト: hnjm/MediaPortal-1
        private void Update()
        {
            if (m_pTexture != null)
            {
                m_pTexture.Dispose();
            }

            SetLabel(lblCameraModel, string.Empty);
            SetLabel(lblDateTakenLabel, string.Empty);
            SetLabel(lblEquipmentMake, string.Empty);
            SetLabel(lblExposureCompensation, string.Empty);
            SetLabel(lblExposureTime, string.Empty);
            SetLabel(lblFlash, string.Empty);
            SetLabel(lblFstop, string.Empty);
            SetLabel(lblImgDimensions, string.Empty);
            SetLabel(lblImgTitle, string.Empty);
            SetLabel(lblMeteringMode, string.Empty);
            SetLabel(lblResolutions, string.Empty);
            SetLabel(lblShutterSpeed, string.Empty);
            SetLabel(lblViewComments, string.Empty);

            if (!File.Exists(FileName))
            {
                GUIPropertyManager.SetProperty("#selectedthumb", string.Empty);
                return;
            }

            int iRotate = PictureDatabase.GetRotation(FileName);

            m_pTexture = Util.Picture.Load(FileName, iRotate, (int)Thumbs.LargeThumbSize.uhd, (int)Thumbs.LargeThumbSize.uhd,
                                           true, false, out m_iTextureWidth, out m_iTextureHeight);

            ExifMetadata.Metadata metaData = PictureDatabase.GetExifFromDB(FileName);
            if (metaData.IsEmpty())
            {
                metaData = PictureDatabase.GetExifFromFile(FileName);
            }
            if (!metaData.IsEmpty())
            {
                SetLabel(lblCameraModel, metaData.CameraModel.DisplayValue);
                SetLabel(lblDateTakenLabel, metaData.DatePictureTaken.DisplayValue);
                SetLabel(lblEquipmentMake, metaData.EquipmentMake.DisplayValue);
                SetLabel(lblExposureCompensation, metaData.ExposureCompensation.DisplayValue);
                SetLabel(lblExposureTime, metaData.ExposureTime.DisplayValue);
                SetLabel(lblFlash, metaData.Flash.DisplayValue, true);
                SetLabel(lblFstop, metaData.Fstop.DisplayValue);
                SetLabel(lblImgDimensions, metaData.ImageDimensionsAsString());
                SetLabel(lblImgTitle, Path.GetFileNameWithoutExtension(FileName));
                SetLabel(lblMeteringMode, metaData.MeteringMode.DisplayValue, true);
                SetLabel(lblResolutions, metaData.ResolutionAsString());
                SetLabel(lblShutterSpeed, metaData.ShutterSpeed.DisplayValue);
                SetLabel(lblViewComments, metaData.ViewerComments.DisplayValue);

                imgPicture.IsVisible = false;
            }
            metaData.SetExifProperties();
            GUIPropertyManager.SetProperty("#selectedthumb", FileName);
        }
コード例 #3
0
ファイル: ExifExtensions.cs プロジェクト: hnjm/MediaPortal-1
        public static string ToString(this ExifMetadata.Metadata metadata)
        {
            string full = string.Empty;
            Type   type = typeof(ExifMetadata.Metadata);

            foreach (FieldInfo prop in type.GetFields())
            {
                string value   = string.Empty;
                string caption = prop.Name.ToCaption() ?? prop.Name;
                switch (prop.Name)
                {
                case nameof(ExifMetadata.Metadata.ImageDimensions):
                    value = metadata.ImageDimensionsAsString();
                    break;

                case nameof(ExifMetadata.Metadata.Resolution):
                    value = metadata.ResolutionAsString();
                    break;

                case nameof(ExifMetadata.Metadata.Location):
                    if (metadata.Location != null)
                    {
                        string latitude  = metadata.Location.Latitude.ToLatitudeString() ?? string.Empty;
                        string longitude = metadata.Location.Longitude.ToLongitudeString() ?? string.Empty;
                        if (!string.IsNullOrEmpty(latitude) && !string.IsNullOrEmpty(longitude))
                        {
                            value = latitude + " / " + longitude;
                        }
                    }
                    break;

                case nameof(ExifMetadata.Metadata.Altitude):
                    if (metadata.Location != null)
                    {
                        value = metadata.Altitude.ToAltitudeString();
                    }
                    break;

                case nameof(ExifMetadata.Metadata.HDR):
                    continue;

                default:
                    value = ((ExifMetadata.MetadataItem)prop.GetValue(metadata)).DisplayValue ?? string.Empty;
                    break;
                }
                if (!string.IsNullOrEmpty(value))
                {
                    value = value.ToValue() ?? value;
                    full  = full + caption + ": " + value + "\n";
                }
            }
            return(full);
        }