|
@@ -14,8 +14,8 @@ namespace PicView.Avalonia.Crop;
|
|
|
|
|
|
public static class CropFunctions
|
|
public static class CropFunctions
|
|
{
|
|
{
|
|
- public static bool IsCropping {get; private set;}
|
|
|
|
-
|
|
|
|
|
|
+ public static bool IsCropping { get; private set; }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Starts the cropping functionality by setting up the ImageCropperViewModel
|
|
/// Starts the cropping functionality by setting up the ImageCropperViewModel
|
|
/// and adding the CropControl to the main view.
|
|
/// and adding the CropControl to the main view.
|
|
@@ -32,10 +32,12 @@ public static class CropFunctions
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (vm?.PicViewer.ImageSource is not Bitmap bitmap)
|
|
if (vm?.PicViewer.ImageSource is not Bitmap bitmap)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
var isBottomGalleryShown = Settings.Gallery.IsBottomGalleryShown;
|
|
var isBottomGalleryShown = Settings.Gallery.IsBottomGalleryShown;
|
|
// Hide bottom gallery when entering crop mode
|
|
// Hide bottom gallery when entering crop mode
|
|
if (isBottomGalleryShown)
|
|
if (isBottomGalleryShown)
|
|
@@ -45,6 +47,7 @@ public static class CropFunctions
|
|
Settings.Gallery.IsBottomGalleryShown = false;
|
|
Settings.Gallery.IsBottomGalleryShown = false;
|
|
await WindowResizing.SetSizeAsync(vm);
|
|
await WindowResizing.SetSizeAsync(vm);
|
|
}
|
|
}
|
|
|
|
+
|
|
var size = new Size(vm.PicViewer.ImageWidth, vm.PicViewer.ImageHeight);
|
|
var size = new Size(vm.PicViewer.ImageWidth, vm.PicViewer.ImageHeight);
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
{
|
|
{
|
|
@@ -63,19 +66,19 @@ public static class CropFunctions
|
|
};
|
|
};
|
|
vm.CurrentView = cropControl;
|
|
vm.CurrentView = cropControl;
|
|
});
|
|
});
|
|
-
|
|
|
|
|
|
+
|
|
IsCropping = true;
|
|
IsCropping = true;
|
|
vm.PicViewer.Title = TranslationManager.Translation.CropMessage;
|
|
vm.PicViewer.Title = TranslationManager.Translation.CropMessage;
|
|
vm.PicViewer.TitleTooltip = TranslationManager.Translation.CropMessage;
|
|
vm.PicViewer.TitleTooltip = TranslationManager.Translation.CropMessage;
|
|
-
|
|
|
|
|
|
+
|
|
await FunctionsMapper.CloseMenus();
|
|
await FunctionsMapper.CloseMenus();
|
|
-
|
|
|
|
|
|
+
|
|
if (isBottomGalleryShown)
|
|
if (isBottomGalleryShown)
|
|
{
|
|
{
|
|
Settings.Gallery.IsBottomGalleryShown = true;
|
|
Settings.Gallery.IsBottomGalleryShown = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static void CloseCropControl(MainViewModel vm)
|
|
public static void CloseCropControl(MainViewModel vm)
|
|
{
|
|
{
|
|
if (Settings.Gallery.IsBottomGalleryShown)
|
|
if (Settings.Gallery.IsBottomGalleryShown)
|
|
@@ -87,7 +90,7 @@ public static class CropFunctions
|
|
vm.CurrentView = vm.ImageViewer;
|
|
vm.CurrentView = vm.ImageViewer;
|
|
IsCropping = false;
|
|
IsCropping = false;
|
|
TitleManager.SetTitle(vm);
|
|
TitleManager.SetTitle(vm);
|
|
-
|
|
|
|
|
|
+
|
|
// Reset image type to fix issue with animated images
|
|
// Reset image type to fix issue with animated images
|
|
switch (vm.PicViewer.ImageType)
|
|
switch (vm.PicViewer.ImageType)
|
|
{
|
|
{
|
|
@@ -110,13 +113,8 @@ public static class CropFunctions
|
|
{
|
|
{
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if (vm?.PicViewer.ImageSource is not Bitmap)
|
|
|
|
- {
|
|
|
|
- vm.ShouldCropBeEnabled = false;
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (Settings.ImageScaling.ShowImageSideBySide)
|
|
|
|
|
|
+ if (vm?.PicViewer.ImageSource is not Bitmap || Settings.ImageScaling.ShowImageSideBySide)
|
|
{
|
|
{
|
|
vm.ShouldCropBeEnabled = false;
|
|
vm.ShouldCropBeEnabled = false;
|
|
return false;
|
|
return false;
|
|
@@ -137,8 +135,8 @@ public static class CropFunctions
|
|
vm.ShouldCropBeEnabled = true;
|
|
vm.ShouldCropBeEnabled = true;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
vm.ShouldCropBeEnabled = false;
|
|
vm.ShouldCropBeEnabled = false;
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|