/// <inheritdoc/> public virtual async Task <DetermineSaveFileResult> DetermineFileAsync(DetermineSaveFileContext context) { Argument.IsNotNull("context", context); var fileDialog = new SaveFileDialog(); ConfigureFileDialog(fileDialog, context); var result = new DetermineSaveFileResult { Result = fileDialog.ShowDialog() ?? false, FileName = fileDialog.FileName }; return(result); }
/// <summary> /// The save to file. /// </summary> /// <param name="bitmap">The bitmap.</param> private async Task SaveToFileAsync(BitmapSource bitmap) { var context = new DetermineSaveFileContext { Filter = "PNG (*.png) |*.png" }; var result = await _saveFileService.DetermineFileAsync(context); if (result.Result) { var fileName = result.FileName; using (var stream = new FileStream(fileName, FileMode.Create)) { var encoder = new PngBitmapEncoder { Interlace = PngInterlaceOption.On }; encoder.Frames.Add(BitmapFrame.Create(bitmap)); encoder.Save(stream); } } }