private bool SaveFile() { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.FileName = "Untitled"; dlg.DefaultExt = ".jpg"; dlg.Filter = dlg.Filter = "Bitmap Image (.bmp)|*.bmp|Gif Image (.gif)|*.gif|JPEG Image (.jpeg)|*.jpeg|Png Image (.png)|*.png|Tiff Image (.tiff)|*.tiff"; if (dlg.ShowDialog().GetValueOrDefault()) { using (FileStream fs = new FileStream(dlg.FileName, FileMode.Create)) { try { Utils.GetBitmapFromCanvas(MainCanvas).Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg); MessageBox.Show("Сохранено.", "Успех", MessageBoxButton.OK, MessageBoxImage.Information); CanvasController.UndoAllChanges(new BitmapImage(new Uri(originalImageDetails.Path))); } catch (Exception) { MessageBox.Show("Не удалось сохранить файл, попробуйте еще раз.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning); } } } else { return(false); } return(true); }
private void DiscardChangesItem_Click(object sender, RoutedEventArgs e) { InvokeActionWithBusyIndicator(() => { currentCanvasImage = originalImage; MainCanvas.Children.Clear(); MainCanvas.Width = originalImage.Width; MainCanvas.Height = originalImage.Height; CanvasController.UndoAllChanges(originalImage); }); }