From 73f5bbb012282bb00f4cc0cdb08ae1965a196a9c Mon Sep 17 00:00:00 2001 From: Alberto Aldegheri Date: Fri, 5 Aug 2022 12:06:56 +0200 Subject: [PATCH] Fix wrong user intention (clipboard or save) detection on edit for. --- src/Greenshot.Editor/Forms/ImageEditorForm.cs | 4 ++-- src/Greenshot/Destinations/ClipboardDestination.cs | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Greenshot.Editor/Forms/ImageEditorForm.cs b/src/Greenshot.Editor/Forms/ImageEditorForm.cs index 5d21dc682..83c738f88 100644 --- a/src/Greenshot.Editor/Forms/ImageEditorForm.cs +++ b/src/Greenshot.Editor/Forms/ImageEditorForm.cs @@ -935,7 +935,8 @@ namespace Greenshot.Editor.Forms // Make sure the editor is visible WindowDetails.ToForeground(Handle); - bool saveToClipboard = _surface.CaptureDetails.CaptureMode == CaptureMode.Clipboard; + // If the user choose the clipboard as destination, just keep it also on close + bool saveToClipboard = _surface.CaptureDetails.CaptureDestinations.SingleOrDefault()?.Designation == nameof(WellKnownDestinations.Clipboard); MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel; // Dissallow "CANCEL" if the application needs to shutdown @@ -958,7 +959,6 @@ namespace Greenshot.Editor.Forms if (result.Equals(DialogResult.Yes)) { - // If the user choose the clipboard as destination, just keep it also on close if (saveToClipboard) { BtnClipboardClick(sender, e); diff --git a/src/Greenshot/Destinations/ClipboardDestination.cs b/src/Greenshot/Destinations/ClipboardDestination.cs index 41722b231..7c93a2f9a 100644 --- a/src/Greenshot/Destinations/ClipboardDestination.cs +++ b/src/Greenshot/Destinations/ClipboardDestination.cs @@ -20,6 +20,7 @@ */ using System; +using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using Greenshot.Base; @@ -82,11 +83,17 @@ namespace Greenshot.Destinations public override void OnExportedNotificationClick(SurfaceMessageEventArgs e) { Log.Info(Designation + " Notification Clicked!"); + + var captureDetails = new CaptureDetails + { + CaptureMode = CaptureMode.Clipboard, + CaptureDestinations = new List { DestinationHelper.GetDestination(Designation) } + }; - var surface = new Surface((Image)e.Image.Clone()) { CaptureDetails = new CaptureDetails { CaptureMode = CaptureMode.Clipboard } }; + var surface = new Surface((Image)e.Image.Clone()) { CaptureDetails = captureDetails }; DestinationHelper.GetDestination(EditorDestination.DESIGNATION) - .ExportCapture(true, surface, new CaptureDetails { CaptureMode = CaptureMode.Clipboard }); + .ExportCapture(true, surface, captureDetails); } } } \ No newline at end of file