Пример #1
0
        public async override void GetSpecialProperties()
        {
            ViewModel.IsReadOnly = NativeFileOperationsHelper.HasFileAttribute(Library.ItemPath, System.IO.FileAttributes.ReadOnly);
            ViewModel.IsHidden   = NativeFileOperationsHelper.HasFileAttribute(Library.ItemPath, System.IO.FileAttributes.Hidden);

            var fileIconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(Library.ItemPath, 80);

            if (fileIconData != null)
            {
                ViewModel.IconData       = fileIconData;
                ViewModel.LoadCustomIcon = false;
                ViewModel.LoadFileIcon   = true;
            }

            BaseStorageFile libraryFile = await AppInstance.FilesystemViewModel.GetFileFromPathAsync(Library.ItemPath);

            if (libraryFile != null)
            {
                ViewModel.ItemCreatedTimestamp = dateTimeFormatter.ToShortLabel(libraryFile.DateCreated);
                if (libraryFile.Properties != null)
                {
                    GetOtherProperties(libraryFile.Properties);
                }
            }

            var storageFolders = new List <BaseStorageFolder>();

            if (Library.Folders != null)
            {
                try
                {
                    foreach (var path in Library.Folders)
                    {
                        BaseStorageFolder folder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(path);

                        if (!string.IsNullOrEmpty(folder.Path))
                        {
                            storageFolders.Add(folder);
                        }
                    }
                }
                catch (Exception ex)
                {
                    App.Logger.Warn(ex, ex.Message);
                }
            }

            if (storageFolders.Count > 0)
            {
                ViewModel.ContainsFilesOrFolders = true;
                ViewModel.LocationsCount         = storageFolders.Count;
                GetLibrarySize(storageFolders, TokenSource.Token);
            }
            else
            {
                ViewModel.FilesAndFoldersCountString = "LibraryNoLocations/Text".GetLocalized();
            }
        }
Пример #2
0
        public async void GetOtherProperties(IStorageItemExtraProperties properties)
        {
            string        dateAccessedProperty = "System.DateAccessed";
            List <string> propertiesName       = new List <string>();

            propertiesName.Add(dateAccessedProperty);
            IDictionary <string, object> extraProperties = await properties.RetrievePropertiesAsync(propertiesName);

            // Cannot get date and owner in MTP devices
            ViewModel.ItemAccessedTimestamp = dateTimeFormatter.ToShortLabel((DateTimeOffset)(extraProperties[dateAccessedProperty] ?? DateTimeOffset.Now));
        }
Пример #3
0
 public string ToShortLabel(DateTimeOffset offset) => formatter.ToShortLabel(offset);