DrawableContainer extended to indicate if confirm/cancel is available. #397 (#399)

This commit is contained in:
Christian Schulz 2022-04-13 09:53:46 +02:00 committed by GitHub
commit 8aca1c8282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View file

@ -93,6 +93,11 @@ namespace Greenshot.Base.Interfaces.Drawing
/// </summary>
IList<IAdorner> Adorners { get; }
/// <summary>
/// Is confirm/cancel possible for this container
/// </summary>
bool IsConfirmable { get; }
/// <summary>
/// Adjust UI elements to the supplied DPI settings
/// </summary>

View file

@ -264,9 +264,18 @@ namespace Greenshot.Editor.Drawing
Invalidate();
return true;
}
/// <inheritdoc cref="IDrawableContainer"/>
/// <summary>
/// <inheritdoc />
/// <para/>
/// Make sure this container is not undoable
/// </summary>
public override bool IsUndoable => false;
/// <summary>
/// <inheritdoc />
/// <para/>
/// See dedicated confirm method <see cref="Surface.ConfirmCrop(bool)"/>
/// </summary>
public override bool IsConfirmable => true;
}
}

View file

@ -480,9 +480,12 @@ namespace Greenshot.Editor.Drawing
g.DrawRectangle(pen, rect);
}
/// <inheritdoc cref="IDrawableContainer"/>
/// <inheritdoc/>
public virtual bool IsUndoable => true;
/// <inheritdoc/>
public virtual bool IsConfirmable => false;
/// <summary>
/// Make a following bounds change on this drawablecontainer undoable!
/// </summary>

View file

@ -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<IDrawableContainer> selectedDCs = new List<IDrawableContainer>(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()}");
}