From 8aca1c82828b5a8df785423763cd8edcbde1c8f8 Mon Sep 17 00:00:00 2001 From: Christian Schulz <32000301+Christian-Schulz@users.noreply.github.com> Date: Wed, 13 Apr 2022 09:53:46 +0200 Subject: [PATCH] DrawableContainer extended to indicate if confirm/cancel is available. #397 (#399) --- .../Interfaces/Drawing/IDrawableContainer.cs | 5 +++++ src/Greenshot.Editor/Drawing/CropContainer.cs | 13 +++++++++++-- src/Greenshot.Editor/Drawing/DrawableContainer.cs | 5 ++++- src/Greenshot.Editor/Drawing/Surface.cs | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Greenshot.Base/Interfaces/Drawing/IDrawableContainer.cs b/src/Greenshot.Base/Interfaces/Drawing/IDrawableContainer.cs index 2363b7ac9..b42192916 100644 --- a/src/Greenshot.Base/Interfaces/Drawing/IDrawableContainer.cs +++ b/src/Greenshot.Base/Interfaces/Drawing/IDrawableContainer.cs @@ -93,6 +93,11 @@ namespace Greenshot.Base.Interfaces.Drawing /// IList Adorners { get; } + /// + /// Is confirm/cancel possible for this container + /// + bool IsConfirmable { get; } + /// /// Adjust UI elements to the supplied DPI settings /// diff --git a/src/Greenshot.Editor/Drawing/CropContainer.cs b/src/Greenshot.Editor/Drawing/CropContainer.cs index 936a1a2c8..f33045b61 100644 --- a/src/Greenshot.Editor/Drawing/CropContainer.cs +++ b/src/Greenshot.Editor/Drawing/CropContainer.cs @@ -264,9 +264,18 @@ namespace Greenshot.Editor.Drawing Invalidate(); return true; } - - /// + /// + /// + /// /// Make sure this container is not undoable + /// public override bool IsUndoable => false; + + /// + /// + /// + /// See dedicated confirm method + /// + public override bool IsConfirmable => true; } } diff --git a/src/Greenshot.Editor/Drawing/DrawableContainer.cs b/src/Greenshot.Editor/Drawing/DrawableContainer.cs index f8a14052b..7ae58bfe6 100644 --- a/src/Greenshot.Editor/Drawing/DrawableContainer.cs +++ b/src/Greenshot.Editor/Drawing/DrawableContainer.cs @@ -480,9 +480,12 @@ namespace Greenshot.Editor.Drawing g.DrawRectangle(pen, rect); } - /// + /// public virtual bool IsUndoable => true; + /// + public virtual bool IsConfirmable => false; + /// /// Make a following bounds change on this drawablecontainer undoable! /// diff --git a/src/Greenshot.Editor/Drawing/Surface.cs b/src/Greenshot.Editor/Drawing/Surface.cs index 8eb2a872e..ead40e74f 100644 --- a/src/Greenshot.Editor/Drawing/Surface.cs +++ b/src/Greenshot.Editor/Drawing/Surface.cs @@ -2108,7 +2108,7 @@ namespace Greenshot.Editor.Drawing { // create new collection so that we can iterate safely (selectedElements might change due with confirm/cancel) List selectedDCs = new List(selectedElements); - foreach (IDrawableContainer dc in selectedDCs) + foreach (IDrawableContainer dc in selectedDCs.Where(c => c.IsConfirmable)) { throw new NotImplementedException($"No confirm/cancel defined for Container type {dc.GetType()}"); }