private async void ShowImages()
        {
            if (!libraries.ContainsKey(LibraryName))
            {
                libraries.Add(LibraryName, await PhotoLibraryObj.LoadPhotoLibraryAsync(LibraryName));
            }

            var photos = libraries[LibraryName].GetPhotos();

            // Open the file picker.
            //Windows.Storage.StorageFile file = await openPicker.PickSingleFileAsync();
            foreach (Photo photo in photos)
            {
                StorageFile file = await StorageFile.GetFileFromPathAsync(photo.Path);

                // 'file' is null if user cancels the file picker.
                if (file != null)
                {
                    // Open a stream for the selected file.
                    // The 'using' block ensures the stream is disposed
                    // after the image is loaded.
                    await ShowPhoto(file);
                }
            }
        }
        public static async Task <PhotoLibraryObj> LoadPhotoLibraryAsync(string libraryName)
        {
            string fileContact = await FileHelper.ReadTextFileAsync(TEXT_FILE_NAME + libraryName + ".txt");

            PhotoLibraryObj library = JsonConvert.DeserializeObject <PhotoLibraryObj>(fileContact);

            return(library);
        }
        public static async Task <PhotoLibraryObj> CreatePhotoLibraryAsync(string name, string coverPicPath)
        {
            var library = new PhotoLibraryObj();

            library.Name           = name;
            library.CoverPhotoPath = coverPicPath;
            await library.SaveAsync();

            return(library);
        }
Example #4
0
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            var name = nameText.Text;
            var path = pathLabel.Text;

            var library = await PhotoLibraryObj.CreatePhotoLibraryAsync(name, path);

            var libraryManager = PhotoLibraryManager.GetInstance();
            await libraryManager.AddPhotoLibraryAsync(library);

            ReturnToHomePage();
        }
        public async Task AddPhotoLibraryAsync(PhotoLibraryObj library)
        {
            this.libraryCollection.Add(library.Name, library.CoverPhotoPath);

            await UpdateFileAsync();
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     _library = e.Parameter as PhotoLibraryObj;
 }