|
@@ -3,6 +3,8 @@ using Avalonia.Media.Imaging;
|
|
|
using PicView.Avalonia.UI;
|
|
|
using PicView.Avalonia.ViewModels;
|
|
|
using PicView.Avalonia.Views.UC;
|
|
|
+using PicView.Avalonia.WindowBehavior;
|
|
|
+using PicView.Core.Gallery;
|
|
|
using PicView.Core.Localization;
|
|
|
|
|
|
namespace PicView.Avalonia.Crop;
|
|
@@ -12,7 +14,7 @@ public static class CropFunctions
|
|
|
public static bool IsCropping {get; private set;}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Initializes 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.
|
|
|
/// </summary>
|
|
|
/// <param name="vm">The main view model instance containing image properties and state.</param>
|
|
@@ -21,7 +23,7 @@ public static class CropFunctions
|
|
|
/// If conditions are met, it configures the crop control with the appropriate dimensions
|
|
|
/// and updates the view model's title and tooltip to reflect the cropping state.
|
|
|
/// </remarks>
|
|
|
- public static void Init(MainViewModel vm)
|
|
|
+ public static void StartCropControl(MainViewModel vm)
|
|
|
{
|
|
|
if (!DetermineIfShouldBeEnabled(vm))
|
|
|
{
|
|
@@ -31,6 +33,15 @@ public static class CropFunctions
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ // Hide bottom gallery when entering crop mode
|
|
|
+ if (Settings.Gallery.IsBottomGalleryShown)
|
|
|
+ {
|
|
|
+ vm.GalleryMode = GalleryMode.Closed;
|
|
|
+ // Reset setting before resizing
|
|
|
+ Settings.Gallery.IsBottomGalleryShown = false;
|
|
|
+ WindowResizing.SetSize(vm);
|
|
|
+ Settings.Gallery.IsBottomGalleryShown = true;
|
|
|
+ }
|
|
|
var size = new Size(vm.ImageWidth, vm.ImageHeight);
|
|
|
var cropperViewModel = new ImageCropperViewModel(bitmap)
|
|
|
{
|
|
@@ -43,8 +54,9 @@ public static class CropFunctions
|
|
|
DataContext = cropperViewModel,
|
|
|
Width = size.Width,
|
|
|
Height = size.Height,
|
|
|
+ Margin = new Thickness(0)
|
|
|
};
|
|
|
- UIHelper.GetMainView.MainGrid.Children.Add(cropControl);
|
|
|
+ vm.CurrentView = cropControl;
|
|
|
|
|
|
IsCropping = true;
|
|
|
vm.Title = TranslationHelper.Translation.CropMessage;
|
|
@@ -53,7 +65,13 @@ public static class CropFunctions
|
|
|
|
|
|
public static void CloseCropControl(MainViewModel vm)
|
|
|
{
|
|
|
- UIHelper.GetMainView.MainGrid.Children.Remove(UIHelper.GetMainView.MainGrid.Children.OfType<CropControl>().First());
|
|
|
+ if (Settings.Gallery.IsBottomGalleryShown)
|
|
|
+ {
|
|
|
+ vm.GalleryMode = GalleryMode.ClosedToBottom;
|
|
|
+ WindowResizing.SetSize(vm);
|
|
|
+ }
|
|
|
+
|
|
|
+ vm.CurrentView = vm.ImageViewer;
|
|
|
IsCropping = false;
|
|
|
SetTitleHelper.RefreshTitle(vm);
|
|
|
}
|