private void SaveCircuitBoardWithDialog() { try { var options = new SaveFileDialogOptions { FileName = "CircuitBoard.png", DefaultExtension = "png", Filters = { new KeyValuePair <string, string>("Portable Network Graphics (*.png)", "*.png"), new KeyValuePair <string, string>("Windows Bitmap (*.bmp)", "*.bmp"), new KeyValuePair <string, string>("Targa Image File (*.tga)", "*.tga"), new KeyValuePair <string, string>("All Files (*.*)", "*.*") } }; if (Dialogs.OpenSaveFileDialog(options, out string path)) { SaveCircuitBoard(path); } } catch (Exception exception) { Debug.WriteLine(exception); } }
public async Task <SaveFileDialogResult> ShowDialogAsync(SaveFileDialogOptions options) { Microsoft.Win32.SaveFileDialog saveFileDialog = new() { Filter = await ConvertFileFiltersToFileFilterFormat(options.FileFilters) }; return(saveFileDialog.ShowDialog() switch { true => OnTrueResult(saveFileDialog), false => OnFalseResult(), _ => throw new SaveFileDialogUnknownResultTypeException("An unknown error occurred while reading the result of the dialog box!") }); }