コード例 #1
0
        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);
        }
コード例 #2
0
 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;
     }));
 }