public static StorageCommand SetImageSource(this StorageCommand command, Image image)
        {
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
            var source = StorageCommand.CreateSourceProvider(async () =>
            {
                ImageFormat format = null;
                if (!String.IsNullOrEmpty(command.Extension))
                {
                    format = command.Extension.GetImageFormat();
                }
                else
                {
                    format = image.GetImageFormat();
                    command.Extension = format.FileExtension();
                }
                return image.ToStream(format);
            }, true);
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously

            return command.SetSourceProvider(source);
        }
コード例 #2
0
 /// <summary>
 /// Provides a file info object describing a file to be created for an
 /// image with a given index and format
 /// </summary>
 /// <returns>The for new image.</returns>
 /// <param name="imageIndex">Image index.</param>
 /// <param name="format">Format.</param>
 private FileInfo FileForNewImage(int imageIndex, ImageFormat format)
 {
     return(new FileInfo(Path.Combine(_imageRootDir.FullName, imageIndex + format.FileExtension())));
 }