diff --git a/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs b/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs index 2a5df19318..575d7e0510 100644 --- a/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs +++ b/NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs @@ -126,6 +126,7 @@ protected override void CreateToolbarsAndMenus() Commands.RotateLeft, Commands.RotateRight, Commands.Flip, + Commands.AltFlip, Commands.Deskew, Commands.CustomRotate, new SeparatorMenuItem(), diff --git a/NAPS2.Lib.Mac/EtoForms/Ui/MacPreviewForm.cs b/NAPS2.Lib.Mac/EtoForms/Ui/MacPreviewForm.cs index 78fb0a1d7a..245a4f2756 100644 --- a/NAPS2.Lib.Mac/EtoForms/Ui/MacPreviewForm.cs +++ b/NAPS2.Lib.Mac/EtoForms/Ui/MacPreviewForm.cs @@ -58,6 +58,7 @@ protected override void UpdatePage() .Append(Commands.RotateLeft) .Append(Commands.RotateRight) .Append(Commands.Flip) + .Append(Commands.AltFlip) .Append(Commands.Deskew) .Append(Commands.CustomRotate)), MacToolbarItems.Create("crop", Commands.Crop), diff --git a/NAPS2.Lib/Config/InternalDefaults.cs b/NAPS2.Lib/Config/InternalDefaults.cs index 0911470d33..7c3cda5c8c 100644 --- a/NAPS2.Lib/Config/InternalDefaults.cs +++ b/NAPS2.Lib/Config/InternalDefaults.cs @@ -168,6 +168,7 @@ public static CommonConfig GetCommonConfig() => ImageSharpen = "", RotateLeft = "", RotateRight = "", + AltFlip = "", RotateFlip = "", RotateCustom = "", MoveUp = "Ctrl+Up", diff --git a/NAPS2.Lib/Config/KeyboardShortcuts.cs b/NAPS2.Lib/Config/KeyboardShortcuts.cs index 21a306ba24..65cc4a9524 100644 --- a/NAPS2.Lib/Config/KeyboardShortcuts.cs +++ b/NAPS2.Lib/Config/KeyboardShortcuts.cs @@ -54,6 +54,7 @@ public class KeyboardShortcuts public string? RotateLeft { get; set; } public string? RotateRight { get; set; } public string? RotateFlip { get; set; } + public string? AltFlip { get; set; } public string? RotateCustom { get; set; } public string? MoveUp { get; set; } diff --git a/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs b/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs index 9753232db6..3a3f8ceb1d 100644 --- a/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs +++ b/NAPS2.Lib/EtoForms/Desktop/DesktopKeyboardShortcuts.cs @@ -1,5 +1,6 @@ using Eto.Forms; using NAPS2.EtoForms.Ui; +using System.Runtime.InteropServices; namespace NAPS2.EtoForms.Desktop; @@ -84,6 +85,7 @@ public void Assign(DesktopCommands commands) _ksm.Assign(ks.RotateFlip, commands.Flip); _ksm.Assign(ks.RotateLeft, commands.RotateLeft); _ksm.Assign(ks.RotateRight, commands.RotateRight); + _ksm.Assign(ks.AltFlip, commands.AltFlip); _ksm.Assign(ks.SaveImages, commands.SaveImages); _ksm.Assign(ks.SaveImagesAll, commands.SaveAllImages); _ksm.Assign(ks.SaveImagesSelected, commands.SaveSelectedImages); diff --git a/NAPS2.Lib/EtoForms/Desktop/ImageListActions.cs b/NAPS2.Lib/EtoForms/Desktop/ImageListActions.cs index 3390862d36..10781cead8 100644 --- a/NAPS2.Lib/EtoForms/Desktop/ImageListActions.cs +++ b/NAPS2.Lib/EtoForms/Desktop/ImageListActions.cs @@ -70,6 +70,9 @@ public async Task RotateRight() => public async Task Flip() => await _imageList.MutateAsync(new ImageListMutation.RotateFlip(180), Selection); + public async Task AltFlip() => + await _imageList.MutateAsync(new ImageListMutation.AltFlip(), Selection); + public void DocumentCorrection() => _imageList.Mutate(new ImageListMutation.AddTransforms([new CorrectionTransform(CorrectionMode.Document)]), Selection); diff --git a/NAPS2.Lib/EtoForms/Ui/DesktopCommands.cs b/NAPS2.Lib/EtoForms/Ui/DesktopCommands.cs index fba199c430..b3878fc59b 100644 --- a/NAPS2.Lib/EtoForms/Ui/DesktopCommands.cs +++ b/NAPS2.Lib/EtoForms/Ui/DesktopCommands.cs @@ -220,6 +220,10 @@ public DesktopCommands(DesktopController desktopController, DesktopScanControlle Text = UiStrings.Flip, Image = iconProvider.GetIcon("arrow_switch_small") }; + AltFlip = new ActionCommand(imageListActions.AltFlip) + { + Text = UiStrings.AltFlip + }; Deskew = new ActionCommand(imageListActions.Deskew) { Text = UiStrings.Deskew @@ -396,6 +400,7 @@ public DesktopCommands WithSelection(Func> selectionFunc) public ActionCommand RotateLeft { get; set; } public ActionCommand RotateRight { get; set; } public ActionCommand Flip { get; set; } + public ActionCommand AltFlip { get; set; } public ActionCommand Deskew { get; set; } public ActionCommand CustomRotate { get; set; } public ActionCommand MoveUp { get; set; } diff --git a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs index fc30f09cd2..139eb9cd71 100644 --- a/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/DesktopForm.cs @@ -360,6 +360,7 @@ protected MenuProvider GetRotateMenuProvider() => .Append(Commands.RotateLeft) .Append(Commands.RotateRight) .Append(Commands.Flip) + .Append(Commands.AltFlip) .Append(Commands.Deskew) .Append(Commands.CustomRotate); diff --git a/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs b/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs index 9572a7edbf..f6058478c5 100644 --- a/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs +++ b/NAPS2.Lib/EtoForms/Ui/PreviewForm.cs @@ -214,6 +214,7 @@ protected virtual void CreateToolbar() { Commands.RotateLeft, Commands.RotateRight, + Commands.AltFlip, Commands.Flip, Commands.Deskew, Commands.CustomRotate @@ -370,6 +371,7 @@ private void AssignKeyboardShortcuts() _ksm.Assign(ks.RotateFlip, Commands.Flip); _ksm.Assign(ks.RotateLeft, Commands.RotateLeft); _ksm.Assign(ks.RotateRight, Commands.RotateRight); + _ksm.Assign(ks.AltFlip, Commands.AltFlip); _ksm.Assign(ks.SaveImages, Commands.SaveSelectedImages); _ksm.Assign(ks.SavePDF, Commands.SaveSelectedPdf); } diff --git a/NAPS2.Lib/Images/ImageListMutation.cs b/NAPS2.Lib/Images/ImageListMutation.cs index f03b408671..0d546f2cf8 100644 --- a/NAPS2.Lib/Images/ImageListMutation.cs +++ b/NAPS2.Lib/Images/ImageListMutation.cs @@ -16,6 +16,25 @@ public override void Apply(List list, ref ListSelection select } } + public class AltFlip() : ImageListMutation + { + public override void Apply(List list, ref ListSelection selection) + { + bool toggle = false; + foreach (UiImage img in selection) + { + if (toggle) + { + var transform = new RotationTransform(180); + var thumb = img.GetThumbnailClone(); + var updatedThumb = thumb?.PerformTransform(transform); + img.AddTransform(transform, updatedThumb); + } + toggle = !toggle; + } + } + } + public class AddTransforms(List transforms, Dictionary? updatedThumbnails = null) : ListMutation { diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs b/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs index b538a6d0db..5689a0f436 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs +++ b/NAPS2.Lib/Lang/Resources/UiStrings.Designer.cs @@ -176,6 +176,15 @@ internal static string AltDeinterleave { } } + /// + /// Looks up a localized string similar to Flip every 2nd image. + /// + internal static string AltFlip { + get { + return ResourceManager.GetString("AltFlip", resourceCulture); + } + } + /// /// Looks up a localized string similar to Alternate Interleave. /// diff --git a/NAPS2.Lib/Lang/Resources/UiStrings.resx b/NAPS2.Lib/Lang/Resources/UiStrings.resx index b6cc03583c..d3184da475 100644 --- a/NAPS2.Lib/Lang/Resources/UiStrings.resx +++ b/NAPS2.Lib/Lang/Resources/UiStrings.resx @@ -252,6 +252,9 @@ Flip + + Flip every 2nd image + Deskew diff --git a/NAPS2.Setup/appsettings.xml b/NAPS2.Setup/appsettings.xml index 35b58047fe..a2405ad1e8 100644 --- a/NAPS2.Setup/appsettings.xml +++ b/NAPS2.Setup/appsettings.xml @@ -125,6 +125,7 @@ + Ctrl+Up Ctrl+Down