Added center points option to toolbar

This commit is contained in:
Jaex 2017-08-02 18:32:51 +03:00
parent 3de63379f8
commit c40e77298b
3 changed files with 47 additions and 5 deletions

View file

@ -44,6 +44,9 @@ public class AnnotationOptions
public int DrawingCornerRadius { get; set; } = 3;
public bool Shadow { get; set; } = true;
// Line, arrow drawing
public int LineCenterPointCount { get; set; } = 1;
// Text (Outline) drawing
public TextDrawingOptions TextOutlineOptions { get; set; } = new TextDrawingOptions()
{

View file

@ -32,16 +32,33 @@ namespace ShareX.ScreenCaptureLib
{
public class LineDrawingShape : BaseDrawingShape
{
private const int MaximumCenterPointCount = 3;
public const int MaximumCenterPointCount = 5;
public override ShapeType ShapeType { get; } = ShapeType.DrawingLine;
public bool CenterNodeActive { get; set; }
public Point[] CenterPoints { get; set; } = new Point[MaximumCenterPointCount];
public int CenterPointCount { get; set; } = 3;
public int CenterPointCount { get; set; }
public override bool IsValidShape => StartPosition != EndPosition;
public override void OnConfigLoad()
{
base.OnConfigLoad();
CenterPointCount = AnnotationOptions.LineCenterPointCount;
if (Manager.NodesVisible)
{
OnNodeVisible();
}
}
public override void OnConfigSave()
{
base.OnConfigSave();
AnnotationOptions.LineCenterPointCount = CenterPointCount;
}
public override void OnUpdate()
{
base.OnUpdate();
@ -110,7 +127,10 @@ private List<Point> CreatePoints()
points.Add(StartPosition);
if (CenterNodeActive)
{
points.AddRange(CenterPoints);
for (int i = 0; i < CenterPointCount; i++)
{
points.Add(CenterPoints[i]);
}
}
points.Add(EndPosition);
return points;
@ -151,9 +171,15 @@ public override void Resize(int x, int y, bool fromBottomRight)
public override void OnNodeVisible()
{
for (int i = 0; i < 8; i++)
{
ResizeNode node = Manager.ResizeNodes[i];
node.Shape = NodeShape.Circle;
node.Visible = false;
}
for (int i = 0; i < 2 + CenterPointCount; i++)
{
Manager.ResizeNodes[i].Shape = NodeShape.Circle;
Manager.ResizeNodes[i].Visible = true;
}
}

View file

@ -49,7 +49,7 @@ internal partial class ShapeManager
private ToolStripButton tsbBorderColor, tsbFillColor, tsbHighlightColor;
private ToolStripDropDownButton tsddbShapeOptions;
private ToolStripMenuItem tsmiShadow, tsmiUndo, tsmiDelete, tsmiDeleteAll, tsmiMoveTop, tsmiMoveUp, tsmiMoveDown, tsmiMoveBottom, tsmiRegionCapture, tsmiQuickCrop, tsmiTips;
private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudBlurRadius, tslnudPixelateSize;
private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudCenterPoints, tslnudBlurRadius, tslnudPixelateSize;
private ToolStripLabel tslDragLeft;
private void CreateToolbar()
@ -494,6 +494,16 @@ private void CreateToolbar()
};
tsddbShapeOptions.DropDownItems.Add(tslnudPixelateSize);
tslnudCenterPoints = new ToolStripLabeledNumericUpDown("Center points:");
tslnudCenterPoints.Content.Minimum = 0;
tslnudCenterPoints.Content.Maximum = LineDrawingShape.MaximumCenterPointCount;
tslnudCenterPoints.Content.ValueChanged = (sender, e) =>
{
AnnotationOptions.LineCenterPointCount = (int)tslnudCenterPoints.Content.Value;
UpdateCurrentShape();
};
tsddbShapeOptions.DropDownItems.Add(tslnudCenterPoints);
tsmiShadow = new ToolStripMenuItem(Resources.ShapeManager_CreateToolbar_DropShadow);
tsmiShadow.Checked = true;
tsmiShadow.CheckOnClick = true;
@ -1046,6 +1056,8 @@ private void UpdateMenu()
tsmiShadow.Checked = AnnotationOptions.Shadow;
tslnudCenterPoints.Content.Value = AnnotationOptions.LineCenterPointCount;
switch (shapeType)
{
default:
@ -1118,6 +1130,7 @@ private void UpdateMenu()
break;
}
tslnudCenterPoints.Visible = shapeType == ShapeType.DrawingLine || shapeType == ShapeType.DrawingArrow;
tslnudBlurRadius.Visible = shapeType == ShapeType.EffectBlur;
tslnudPixelateSize.Visible = shapeType == ShapeType.EffectPixelate;
tsbHighlightColor.Visible = shapeType == ShapeType.EffectHighlight;