private BitmapFileSettings GetBitmapFileSettings() { BitmapFileSettings bitmapSettings = null; var saveFileDialog = new SaveFileDialog { Title = "Save Spirograph Image File", FileName = DefaultImageFileName, Filter = BitmapFileSettings.FileFilters, FilterIndex = PNGDefaultFileFiler, InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), AddExtension = true, OverwritePrompt = true, ValidateNames = true, }; bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { var encoding = (BitmapEncoding)(saveFileDialog.FilterIndex - 1); var imageFileName = saveFileDialog.FileName; bitmapSettings = new BitmapFileSettings(encoding, imageFileName); } return(bitmapSettings); }
private void SaveSpirographImage() { BitmapFileSettings bitmapSettings = GetBitmapFileSettings(); if (theSpirograph != null) { if (bitmapSettings != null) { theSpirograph.Save(SpiroCanvas, bitmapSettings.Encoder, bitmapSettings.BitmapFileName); } } }