Add GUI configuration for cut out tool

This commit is contained in:
Niels Martin Hansen 2022-08-17 21:46:45 +02:00
parent 8ca64af596
commit b784ebe0c7
5 changed files with 59 additions and 4 deletions

View file

@ -284,6 +284,24 @@ internal class Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Cut cut effect size.
/// </summary>
internal static string CutOutEffectSize {
get {
return ResourceManager.GetString("CutOutEffectSize", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cut out effect.
/// </summary>
internal static string CutOutEffectType {
get {
return ResourceManager.GetString("CutOutEffectType", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View file

@ -805,4 +805,10 @@ X: {4} Y: {5}</value>
<value>CRF:</value>
<comment>@Invariant</comment>
</data>
<data name="CutOutEffectSize" xml:space="preserve">
<value>Cut cut effect size</value>
</data>
<data name="CutOutEffectType" xml:space="preserve">
<value>Cut out effect</value>
</data>
</root>

View file

@ -106,5 +106,9 @@ public class AnnotationOptions
// Highlight effect
public Color HighlightColor { get; set; } = Color.Yellow;
// Cut Out tool
public CutOutEffectType CutOutEffectType { get; set; } = CutOutEffectType.None;
public int CutOutEffectSize { get; set; } = 5;
}
}

View file

@ -1929,12 +1929,12 @@ public void CutOut(RectangleF rect)
if (isHorizontal && cropRect.Width > 0)
{
CollapseAllHorizontal(rect.X, rect.Width);
UpdateCanvas(ImageHelpers.CutOutBitmapMiddle(Form.Canvas, Orientation.Horizontal, cropRect.X, cropRect.Width, CutOutEffectType.ZigZag, 5));
UpdateCanvas(ImageHelpers.CutOutBitmapMiddle(Form.Canvas, Orientation.Horizontal, cropRect.X, cropRect.Width, AnnotationOptions.CutOutEffectType, AnnotationOptions.CutOutEffectSize));
}
else if (!isHorizontal && cropRect.Height > 0)
{
CollapseAllVertical(rect.Y, rect.Height);
UpdateCanvas(ImageHelpers.CutOutBitmapMiddle(Form.Canvas, Orientation.Vertical, cropRect.Y, cropRect.Height, CutOutEffectType.ZigZag, 5));
UpdateCanvas(ImageHelpers.CutOutBitmapMiddle(Form.Canvas, Orientation.Vertical, cropRect.Y, cropRect.Height, AnnotationOptions.CutOutEffectType, AnnotationOptions.CutOutEffectSize));
}
}

View file

@ -51,9 +51,9 @@ internal partial class ShapeManager
private ToolStripMenuItem tsmiShadow, tsmiShadowColor, tsmiUndo, tsmiDuplicate, tsmiDelete, tsmiDeleteAll,
tsmiMoveTop, tsmiMoveUp, tsmiMoveDown, tsmiMoveBottom, tsmiRegionCapture, tsmiQuickCrop, tsmiShowMagnifier;
private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudCenterPoints, tslnudBlurRadius, tslnudPixelateSize, tslnudStepFontSize,
tslnudMagnifierPixelCount, tslnudStartingStepValue, tslnudMagnifyStrength;
tslnudMagnifierPixelCount, tslnudStartingStepValue, tslnudMagnifyStrength, tslnudCutOutEffectSize;
private ToolStripLabel tslDragLeft, tslDragRight;
private ToolStripLabeledComboBox tscbBorderStyle, tscbArrowHeadDirection, tscbImageInterpolationMode, tscbCursorTypes, tscbStepType;
private ToolStripLabeledComboBox tscbBorderStyle, tscbArrowHeadDirection, tscbImageInterpolationMode, tscbCursorTypes, tscbStepType, tscbCutOutEffectType;
internal void CreateToolbar()
{
@ -642,6 +642,26 @@ internal void CreateToolbar()
};
tsddbShapeOptions.DropDownItems.Add(tsmiShadowColor);
tscbCutOutEffectType = new ToolStripLabeledComboBox(Resources.CutOutEffectType);
tscbCutOutEffectType.Content.AddRange(Helpers.GetLocalizedEnumDescriptions<CutOutEffectType>());
tscbCutOutEffectType.Content.SelectedIndexChanged += (sender, e) =>
{
AnnotationOptions.CutOutEffectType = (CutOutEffectType)tscbCutOutEffectType.Content.SelectedIndex;
tscbCutOutEffectType.Invalidate();
UpdateCurrentShape();
};
tsddbShapeOptions.DropDownItems.Add(tscbCutOutEffectType);
tslnudCutOutEffectSize = new ToolStripLabeledNumericUpDown(Resources.CutOutEffectSize);
tslnudCutOutEffectSize.Content.Minimum = 3;
tslnudCutOutEffectSize.Content.Maximum = 100;
tslnudCutOutEffectSize.Content.ValueChanged = (sender, e) =>
{
AnnotationOptions.CutOutEffectSize = (int)tslnudCutOutEffectSize.Content.Value;
UpdateCurrentShape();
};
tsddbShapeOptions.DropDownItems.Add(tslnudCutOutEffectSize);
// In dropdown menu if only last item is visible then menu opens at 0, 0 position on first open, so need to add dummy item to solve this weird bug...
tsddbShapeOptions.DropDownItems.Add(new ToolStripSeparator() { Visible = false });
@ -1456,6 +1476,10 @@ private void UpdateMenu()
tscbArrowHeadDirection.Content.SelectedIndex = (int)AnnotationOptions.ArrowHeadDirection;
tscbCutOutEffectType.Content.SelectedIndex = (int)AnnotationOptions.CutOutEffectType;
tslnudCutOutEffectSize.Content.Value = AnnotationOptions.CutOutEffectSize;
switch (shapeType)
{
default:
@ -1477,6 +1501,7 @@ private void UpdateMenu()
case ShapeType.DrawingCursor:
case ShapeType.EffectBlur:
case ShapeType.EffectPixelate:
case ShapeType.ToolCutOut:
tsddbShapeOptions.Visible = true;
break;
}
@ -1561,6 +1586,8 @@ private void UpdateMenu()
tslnudBlurRadius.Visible = shapeType == ShapeType.EffectBlur;
tslnudPixelateSize.Visible = shapeType == ShapeType.EffectPixelate;
tsbHighlightColor.Visible = shapeType == ShapeType.EffectHighlight;
tscbCutOutEffectType.Visible = shapeType == ShapeType.ToolCutOut;
tslnudCutOutEffectSize.Visible = shapeType == ShapeType.ToolCutOut;
if (tsmiRegionCapture != null)
{