Added arrow drawing support, it is not possible to resize with nodes yet

This commit is contained in:
Jaex 2016-05-05 19:43:42 +03:00
parent 3672146681
commit 18feef96c7
7 changed files with 78 additions and 3 deletions

View file

@ -144,6 +144,8 @@ public enum ShapeType
DrawingRectangle,
[Description("Drawing: Rounded rectangle")]
DrawingRoundedRectangle,
[Description("Drawing: Arrow")]
DrawingArrow,
[Description("Region: Rectangle")]
RegionRectangle,
[Description("Region: Rounded rectangle")]

View file

@ -387,7 +387,7 @@ protected virtual void WriteTips(StringBuilder sb)
{
sb.AppendLine(Resources.RectangleRegion_WriteTips__Hold_Left_click__Start_region_selection);
// TODO: Translate
sb.AppendLine("[Right click] Open region capture menu");
sb.AppendLine("[Right click] Open options menu");
sb.AppendLine(Resources.RectangleRegion_WriteTips__Right_click___Esc__Cancel_capture);
}

View file

@ -519,7 +519,11 @@ public void Update()
newPosition = SnapPosition(PositionOnClick, newPosition);
}
CurrentRectangle = CaptureHelpers.CreateRectangle(PositionOnClick, newPosition);
if (CurrentShape != null)
{
CurrentShape.EndPosition = newPosition;
CurrentShape.Rectangle = CaptureHelpers.CreateRectangle(PositionOnClick, newPosition);
}
}
CheckHover();
@ -637,6 +641,8 @@ private void RegionSelection(Point location)
}
AddRegionShape(rect);
CurrentShape.StartPosition = PositionOnClick;
}
}
@ -730,6 +736,14 @@ public BaseShape CreateRegionShape(Rectangle rect)
Radius = RoundedRectangleRadius
};
break;
case ShapeType.DrawingArrow:
shape = new ArrowDrawingShape()
{
BorderColor = BorderColor,
BorderSize = BorderSize,
FillColor = FillColor
};
break;
}
shape.Rectangle = rect;

View file

@ -34,6 +34,8 @@ public abstract class BaseShape
public abstract ShapeType ShapeType { get; }
public Rectangle Rectangle { get; set; }
public Point StartPosition { get; set; }
public Point EndPosition { get; set; }
public BaseShape()
{

View file

@ -0,0 +1,56 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2016 ShareX Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
namespace ShareX.ScreenCaptureLib
{
public class ArrowDrawingShape : BaseDrawingShape
{
public override ShapeType ShapeType { get; } = ShapeType.DrawingArrow;
public override void Draw(Graphics g)
{
if (BorderColor != Color.Transparent && BorderSize > 0)
{
g.SmoothingMode = SmoothingMode.HighQuality;
using (Pen pen = new Pen(BorderColor, BorderSize))
using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(4, 6))
{
pen.CustomEndCap = arrowCap;
g.DrawLine(pen, StartPosition, EndPosition);
}
g.SmoothingMode = SmoothingMode.None;
}
}
}
}

View file

@ -52,7 +52,7 @@ public override void Draw(Graphics g)
{
Rectangle rect = Rectangle.Offset(BorderSize - 1);
g.DrawRectangleShadow(rect.Offset(1), Color.FromArgb(150, 150, 150), 3, 100, 10, new Padding(1));
//g.DrawRectangleShadow(rect.Offset(1), Color.FromArgb(150, 150, 150), 3, 100, 10, new Padding(1));
using (Pen pen = new Pen(BorderColor, BorderSize) { Alignment = PenAlignment.Inset })
{

View file

@ -81,6 +81,7 @@
<Compile Include="RectangleAnnotateOptions.cs" />
<Compile Include="RegionHelpers\ColorBlinkAnimation.cs" />
<Compile Include="Shapes\BaseShape.cs" />
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
<Compile Include="Shapes\Drawing\BaseDrawingShape.cs" />
<Compile Include="Shapes\Drawing\RectangleDrawingShape.cs" />
<Compile Include="Shapes\Drawing\RoundedRectangleDrawingShape.cs" />