Example #1
0
        public static async Task<SettingsFlyout> CreatePropertiesFlyout(StorageFile file, StorageFolder topFolder, string fileSubPath)
        {
            if (file == null) return null;

            SettingsFlyout flyout = null;
            try
            {
                BasicProperties basicProps = null;
                try { basicProps = await file.GetBasicPropertiesAsync(); }
                catch (Exception ex) { Debug.WriteLine(ex.ToString()); }

                if (file.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase))
                {
                    var flyoutImg = new PropertiesFlyoutImage();
                    flyout = flyoutImg;
                    ImageProperties imageProps = await file.Properties.GetImagePropertiesAsync();
                    if (imageProps != null)
                        FillImageProperties(flyoutImg, imageProps, file, basicProps);
                }
                else if (file.ContentType.ToLower().StartsWith("audio"))
                {
                    var flyoutAud = new PropertiesFlyoutAudio();
                    flyout = flyoutAud;
                    MusicProperties musicProps = await file.Properties.GetMusicPropertiesAsync();
                    if (musicProps != null)
                        await FillAudioProperties(flyoutAud, musicProps, file);
                }
                else if (file.ContentType.ToLower().StartsWith("video"))
                {
                    var flyoutVdo = new PropertiesFlyoutVideo();
                    flyout = flyoutVdo;
                    VideoProperties videoProps = await file.Properties.GetVideoPropertiesAsync();
                    if (videoProps != null)
                        FillVideoProperties(flyoutVdo, videoProps);
                }
                else
                {
                    var flyoutGen = new PropertiesFlyoutGeneral();
                    flyout = flyoutGen;
                    await FillGeneralProperties(flyoutGen, file, basicProps);
                }

                Debug.Assert(flyout != null, "Flyout object must exist.");
                if (flyout != null)
                    await FillFileProperties((IFileProperties)flyout, file, topFolder, fileSubPath, basicProps);
            }
            catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
            return flyout;
        }
Example #2
0
        public static void FillImageProperties(PropertiesFlyoutImage flyout, ImageProperties imageProps, StorageFile file, BasicProperties basicProps)
        {
            try
            {
                if (imageProps.DateTaken.Year > 1700)
                    flyout.DateTaken.Text = DateTime_ToString(imageProps.DateTaken, EDateTimeFormat.G);
                else if (basicProps != null)
                    flyout.DateTaken.Text = DateTime_ToString(basicProps.DateModified, EDateTimeFormat.G);
                else
                    flyout.DateTaken.Visibility = Visibility.Collapsed;

                if (imageProps.Width > 0 && imageProps.Height > 0)
                    flyout.Dimensions.Text = imageProps.Width.ToString() + " x " + imageProps.Height.ToString() + " pixels";
                else
                    flyout.Dimensions.Visibility = Visibility.Collapsed;

                // IMPORTANT: Need GeoCoordinate class from System.Device.Location namespace (but not avail on WinRT);
                // Not suitable: Windows.Devices.Geolocation namespace;
                // GeoCoordinate geoCoord = new GeoCoordinate();
                if (imageProps.Latitude.HasValue)
                    flyout.Latitude.Text = Util.LatOrLong_ToString(imageProps.Latitude);
                else
                    flyout.Latitude.Visibility = Visibility.Collapsed;
                if (imageProps.Longitude.HasValue)
                    flyout.Longitude.Text = Util.LatOrLong_ToString(imageProps.Longitude);
                else
                    flyout.Longitude.Visibility = Visibility.Collapsed;

                if (!string.IsNullOrEmpty(imageProps.Title))
                    flyout.ImgTitle.Text = imageProps.Title;
                else
                    flyout.ImgTitle.Visibility = Visibility.Collapsed;

                if (!string.IsNullOrEmpty(imageProps.CameraManufacturer))
                {
                    flyout.Camera.Text = imageProps.CameraManufacturer;
                    if (!string.IsNullOrEmpty(imageProps.CameraModel))
                        flyout.Camera.Text += " " + imageProps.CameraModel;
                }
                else
                    flyout.Camera.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
        }