@@ -267,7 +267,8 @@ private async void ApplyButton_Click(object sender, RoutedEventArgs e)
267
267
SetUiForCompletedTask ( ) ;
268
268
}
269
269
270
- private async void Save_Click ( object sender , RoutedEventArgs e )
270
+
271
+ private async void ApplySaveSplitButton_Click ( object sender , RoutedEventArgs e )
271
272
{
272
273
SetUiForLongTask ( ) ;
273
274
@@ -282,6 +283,7 @@ private async void Save_Click(object sender, RoutedEventArgs e)
282
283
{
283
284
BottomPane . IsEnabled = true ;
284
285
BottomPane . Cursor = null ;
286
+ SetUiForCompletedTask ( ) ;
285
287
return ;
286
288
}
287
289
@@ -320,6 +322,58 @@ private async void Save_Click(object sender, RoutedEventArgs e)
320
322
}
321
323
}
322
324
325
+ private async void Save_Click ( object sender , RoutedEventArgs e )
326
+ {
327
+ SaveFileDialog saveFileDialog = new ( )
328
+ {
329
+ Filter = "Image Files|*.jpg;" ,
330
+ RestoreDirectory = true ,
331
+ FileName = $ "{ openedFileName } _corrected.jpg",
332
+ } ;
333
+
334
+ if ( saveFileDialog . ShowDialog ( ) is not true || lines is null )
335
+ {
336
+ BottomPane . IsEnabled = true ;
337
+ BottomPane . Cursor = null ;
338
+ SetUiForCompletedTask ( ) ;
339
+ return ;
340
+ }
341
+
342
+ string correctedImageFileName = saveFileDialog . FileName ;
343
+
344
+ if ( string . IsNullOrWhiteSpace ( imagePath ) || string . IsNullOrWhiteSpace ( correctedImageFileName ) )
345
+ {
346
+ SetUiForCompletedTask ( ) ;
347
+ return ;
348
+ }
349
+
350
+ MagickImage image = new ( imagePath ) ;
351
+
352
+ try
353
+ {
354
+ await image . WriteAsync ( correctedImageFileName ) ;
355
+
356
+ OpenFolderButton . IsEnabled = true ;
357
+ SaveWindow saveWindow = new ( correctedImageFileName ) ;
358
+ saveWindow . Show ( ) ;
359
+ }
360
+ catch ( Exception ex )
361
+ {
362
+ System . Windows . MessageBox . Show (
363
+ ex . Message ,
364
+ "Error" ,
365
+ System . Windows . MessageBoxButton . OK ,
366
+ MessageBoxImage . Error ) ;
367
+ }
368
+ finally
369
+ {
370
+ savedPath = correctedImageFileName ;
371
+
372
+ SetUiForCompletedTask ( ) ;
373
+ image . Dispose ( ) ;
374
+ }
375
+ }
376
+
323
377
private void SetUiForLongTask ( )
324
378
{
325
379
BottomPane . IsEnabled = false ;
@@ -351,6 +405,7 @@ private async void OpenFileButton_Click(object sender, RoutedEventArgs e)
351
405
352
406
private async Task OpenImagePath ( string imageFilePath )
353
407
{
408
+ ApplySaveSplitButton . IsEnabled = true ;
354
409
Save . IsEnabled = true ;
355
410
ApplyButton . IsEnabled = true ;
356
411
MagickImage bitmap = new ( imageFilePath ) ;
@@ -713,7 +768,7 @@ private void SquareThePolygon()
713
768
private void CropImage_Click ( object sender , RoutedEventArgs e )
714
769
{
715
770
isCropping = true ;
716
- ApplyButton . Visibility = Visibility . Collapsed ;
771
+ ApplySaveSplitButton . Visibility = Visibility . Collapsed ;
717
772
CropButtonPanel . Visibility = Visibility . Visible ;
718
773
719
774
foreach ( UIElement element in _polygonElements )
@@ -725,7 +780,7 @@ private void CropImage_Click(object sender, RoutedEventArgs e)
725
780
private async void ApplyCropButton_Click ( object sender , RoutedEventArgs e )
726
781
{
727
782
CropButtonPanel . Visibility = Visibility . Collapsed ;
728
- ApplyButton . Visibility = Visibility . Visible ;
783
+ ApplySaveSplitButton . Visibility = Visibility . Visible ;
729
784
730
785
foreach ( UIElement element in _polygonElements )
731
786
element . Visibility = Visibility . Visible ;
@@ -757,7 +812,7 @@ private async void ApplyCropButton_Click(object sender, RoutedEventArgs e)
757
812
private void CancelCrop_Click ( object sender , RoutedEventArgs e )
758
813
{
759
814
CropButtonPanel . Visibility = Visibility . Collapsed ;
760
- ApplyButton . Visibility = Visibility . Visible ;
815
+ ApplySaveSplitButton . Visibility = Visibility . Visible ;
761
816
762
817
foreach ( UIElement element in _polygonElements )
763
818
element . Visibility = Visibility . Visible ;
0 commit comments