Example #1
0
        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);
        }
Example #2
0
 public void UpdateCanvasAfterFiltering()
 {
     InvokeActionWithBusyIndicator(() =>
     {
         currentCanvasImage = tempImage;
         CanvasController.UpdateCanvas(currentCanvasImage);
     });
 }
Example #3
0
 private void UndoItem_Click(object sender, RoutedEventArgs e)
 {
     InvokeActionWithBusyIndicator(() =>
     {
         CanvasController.UndoChanges();
         currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).ToBitmapImage();
     });
 }
Example #4
0
 private void SharpenItem_Click(object sender, RoutedEventArgs e)
 {
     InvokeActionWithBusyIndicator(() =>
     {
         currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).Sharpen();
         MainCanvas.Children.Clear();
         CanvasController.UpdateCanvas(currentCanvasImage);
     });
 }
Example #5
0
 public void PrepareCanvasForFiltering()
 {
     InvokeActionWithBusyIndicator(() =>
     {
         currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).ToBitmapImage();
         MainCanvas.Children.Clear();
         CanvasController.UpdateCanvas(currentCanvasImage);
     });
 }
Example #6
0
 private void Black_wight_Click(object sender, RoutedEventArgs e)
 {
     InvokeActionWithBusyIndicator(() =>
     {
         currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).ConvertToGrayscale();
         MainCanvas.Children.Clear();
         CanvasController.UpdateCanvas(currentCanvasImage);
     });
 }
Example #7
0
 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);
     });
 }
Example #8
0
 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);
     });
 }
Example #9
0
        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();
        }
Example #10
0
 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;
         }
     }
 }
Example #11
0
 public void EncodeText(string text)
 {
     currentCanvasImage = Utils.GetBitmapFromCanvas(MainCanvas).EncodeText(text);
     CanvasController.UpdateCanvas(currentCanvasImage);
 }