private async Task <PictureViewModel> LoadPictureAsync(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("Path cannot be empty");
            }
            PictureViewModel newPicture = PictureViewModel.CreateNew();

            newPicture.Path = path;
            newPicture.IsThumbnailRequested = this.IsThumbnailRequested;

            try
            {
                newPicture.Title = Path.GetFileName(path);
                if (this.IsThumbnailRequested)
                {
                    await newPicture.LoadThumbnailAsync();
                }
                else
                {
                    await newPicture.LoadImageAsync();
                }
            }
            catch (ArgumentException)
            {
                throw;
            }

            return(newPicture);
        }
 private static async Task <PictureViewModel> LoadPictureAsync(string filename)
 {
     return(await Task.Run(() =>
     {
         PictureViewModel newPicture = PictureViewModel.CreateNew();
         newPicture.Title = Path.GetFileName(filename);
         newPicture.Path = Path.GetFullPath(filename);
         newPicture.LoadImage(filename);
         newPicture.CreationDate = File.GetCreationTimeUtc(Path.GetFullPath(filename));
         return newPicture;
     }));
 }
Beispiel #3
0
        /// <summary>
        /// Creates a new ViewModel.
        /// </summary>
        /// <returns></returns>
        internal static PictureViewModel CreateNew()
        {
            PictureViewModel newViewModel = new PictureViewModel(new Picture());

            return(newViewModel);
        }