Esempio n. 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;
        }
Esempio n. 2
0
        public async static Task FillGeneralProperties(PropertiesFlyoutGeneral flyout, StorageFile file, BasicProperties basicProps)
        {
            try
            {
                if (!string.IsNullOrEmpty(file.DisplayType))
                    flyout.SetPropsKindTitle(file.DisplayType);

                DocumentProperties doc = await file.Properties.GetDocumentPropertiesAsync();
                if (doc != null)
                {
                    if (doc.Author != null && doc.Author.Count > 0)
                        flyout.Authors.Text = NameCreditsStr("", doc.Author);
                    else
                        flyout.HideAuthors();

                    if (!string.IsNullOrEmpty(doc.Title))
                        flyout.DocumentTitle.Text = doc.Title;
                    else
                        flyout.HideDocumentTitle();

                    if (!string.IsNullOrEmpty(doc.Comment))
                        flyout.Comments.Text = doc.Comment.Substring(0, Math.Min(200, doc.Comment.Length));
                    else
                        flyout.HideComments();

                    if (doc.Keywords != null && doc.Keywords.Count > 0)
                        flyout.Keywords.Text = NameCreditsStr("", doc.Keywords);
                    else
                        flyout.HideKeywords();
                }

                if (!string.IsNullOrEmpty(file.ContentType))
                    flyout.ContentType.Text = file.ContentType;
                else
                    flyout.HideContentType();

                if (basicProps != null && basicProps.DateModified.Year > 1700)
                    flyout.DateModified.Text = DateTime_ToString(basicProps.DateModified, EDateTimeFormat.G);
                else
                    flyout.HideDateModified();

                if (file.DateCreated.Year > 1700)
                    flyout.DateCreated.Text = DateTime_ToString(file.DateCreated, EDateTimeFormat.G);
                else
                    flyout.HideDateCreated();

                FileAttributes attr = file.Attributes;
                if ((uint)attr > 0)
                    flyout.Attributes.Text = attr.ToString();
                else
                    flyout.HideAttributes();

                //if (!string.IsNullOrEmpty(file.FolderRelativeId))
                //    flyout.FolderRelativeId.Text = file.FolderRelativeId;
                //else
                flyout.HideFolderRelativeId();

                //DisplayName
                //IsAvailable
            }
            catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
        }