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); }
public void UpdateCanvasAfterFiltering() { InvokeActionWithBusyIndicator(() => { currentCanvasImage = tempImage; CanvasController.UpdateCanvas(currentCanvasImage); }); }
private void UndoItem_Click(object sender, RoutedEventArgs e) { InvokeActionWithBusyIndicator(() => { CanvasController.UndoChanges(); currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).ToBitmapImage(); }); }
private void SharpenItem_Click(object sender, RoutedEventArgs e) { InvokeActionWithBusyIndicator(() => { currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).Sharpen(); MainCanvas.Children.Clear(); CanvasController.UpdateCanvas(currentCanvasImage); }); }
public void PrepareCanvasForFiltering() { InvokeActionWithBusyIndicator(() => { currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).ToBitmapImage(); MainCanvas.Children.Clear(); CanvasController.UpdateCanvas(currentCanvasImage); }); }
private void Black_wight_Click(object sender, RoutedEventArgs e) { InvokeActionWithBusyIndicator(() => { currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).ConvertToGrayscale(); MainCanvas.Children.Clear(); CanvasController.UpdateCanvas(currentCanvasImage); }); }
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); }); }
private void RotateToRightItem_Click(object sender, RoutedEventArgs e) { InvokeActionWithBusyIndicator(() => { var canvas = Utils.GetBitmapFromCanvas(MainCanvas); canvas.RotateFlip(RotateFlipType.Rotate90FlipNone); currentCanvasImage = canvas.ToBitmapImage(); MainCanvas.Width = canvas.Width; MainCanvas.Height = canvas.Height; CanvasController.UpdateCanvas(currentCanvasImage); }); }
public NewWindow(ImageDetails originalImageDetails) { InitializeComponent(); this.originalImageDetails = originalImageDetails; var image = new BitmapImage(new Uri(originalImageDetails.Path)); this.originalImage = image; currentCanvasImage = image; MainCanvas.Width = image.Width; MainCanvas.Height = image.Height; CanvasController = new CanvasController(MainCanvas); CanvasController.UpdateCanvas(currentCanvasImage); InitBusyThread(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (CanvasController.GetNumberOfChanges() > 1) { MessageBoxResult messageBoxResult = MessageBox.Show("Есть несохраненные изменения. Сохранить изменения?", "Изменения", MessageBoxButton.YesNoCancel); if (messageBoxResult == MessageBoxResult.Yes) { e.Cancel = !SaveFile(); } if (messageBoxResult == MessageBoxResult.Cancel) { e.Cancel = true; } } }
public void EncodeText(string text) { currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).EncodeText(text); CanvasController.UpdateCanvas(currentCanvasImage); }