mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-01 04:30:49 +12:00
Merge pull request #6529 from ShareX/freehand-arrow
Added freehand arrow tool
This commit is contained in:
commit
ab9a80fa35
|
@ -3598,6 +3598,15 @@ internal class Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Freehand arrow.
|
||||||
|
/// </summary>
|
||||||
|
internal static string ShapeType_DrawingFreehandArrow {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ShapeType_DrawingFreehandArrow", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Image (File).
|
/// Looks up a localized string similar to Image (File).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -1493,4 +1493,7 @@ Would you like to download and install it?</value>
|
||||||
<data name="HotkeyType_PauseScreenRecording_Category" xml:space="preserve">
|
<data name="HotkeyType_PauseScreenRecording_Category" xml:space="preserve">
|
||||||
<value>Screen record</value>
|
<value>Screen record</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ShapeType_DrawingFreehandArrow" xml:space="preserve">
|
||||||
|
<value>Freehand arrow</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
|
@ -276,6 +276,7 @@ public enum ShapeType // Localized
|
||||||
DrawingRectangle,
|
DrawingRectangle,
|
||||||
DrawingEllipse,
|
DrawingEllipse,
|
||||||
DrawingFreehand,
|
DrawingFreehand,
|
||||||
|
DrawingFreehandArrow,
|
||||||
DrawingLine,
|
DrawingLine,
|
||||||
DrawingArrow,
|
DrawingArrow,
|
||||||
DrawingTextOutline,
|
DrawingTextOutline,
|
||||||
|
|
|
@ -1252,6 +1252,16 @@ internal class Resources {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap pencil__arrow {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("pencil__arrow", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Pixelate.
|
/// Looks up a localized string similar to Pixelate.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -808,4 +808,7 @@ X: {4} Y: {5}</value>
|
||||||
<data name="table_delete_column" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="table_delete_column" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\table-delete-column.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\table-delete-column.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="pencil__arrow" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\pencil--arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
BIN
ShareX.ScreenCaptureLib/Resources/pencil--arrow.png
Normal file
BIN
ShareX.ScreenCaptureLib/Resources/pencil--arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,85 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (c) 2007-2022 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 ShareX.HelpersLib;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
|
||||||
|
namespace ShareX.ScreenCaptureLib
|
||||||
|
{
|
||||||
|
public class FreehandArrowDrawingShape : FreehandDrawingShape
|
||||||
|
{
|
||||||
|
public override ShapeType ShapeType { get; } = ShapeType.DrawingFreehandArrow;
|
||||||
|
|
||||||
|
public ArrowHeadDirection ArrowHeadDirection { get; set; }
|
||||||
|
|
||||||
|
public override void OnConfigLoad()
|
||||||
|
{
|
||||||
|
base.OnConfigLoad();
|
||||||
|
ArrowHeadDirection = AnnotationOptions.ArrowHeadDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnConfigSave()
|
||||||
|
{
|
||||||
|
base.OnConfigSave();
|
||||||
|
AnnotationOptions.ArrowHeadDirection = ArrowHeadDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Pen CreatePen(Color borderColor, int borderSize, BorderStyle borderStyle)
|
||||||
|
{
|
||||||
|
using (GraphicsPath gp = new GraphicsPath())
|
||||||
|
{
|
||||||
|
int arrowWidth = 2, arrowHeight = 6, arrowCurve = 1;
|
||||||
|
gp.AddLine(new Point(0, 0), new Point(-arrowWidth, -arrowHeight));
|
||||||
|
gp.AddCurve(new Point[] { new Point(-arrowWidth, -arrowHeight), new Point(0, -arrowHeight + arrowCurve), new Point(arrowWidth, -arrowHeight) });
|
||||||
|
gp.CloseFigure();
|
||||||
|
|
||||||
|
CustomLineCap lineCap = new CustomLineCap(gp, null)
|
||||||
|
{
|
||||||
|
BaseInset = arrowHeight - arrowCurve
|
||||||
|
};
|
||||||
|
|
||||||
|
Pen pen = new Pen(borderColor, borderSize);
|
||||||
|
|
||||||
|
if (ArrowHeadDirection == ArrowHeadDirection.Both && MathHelpers.Distance(positions[0], positions[positions.Count - 1]) > arrowHeight * borderSize * 2)
|
||||||
|
{
|
||||||
|
pen.CustomEndCap = pen.CustomStartCap = lineCap;
|
||||||
|
}
|
||||||
|
else if (ArrowHeadDirection == ArrowHeadDirection.Start)
|
||||||
|
{
|
||||||
|
pen.CustomStartCap = lineCap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pen.CustomEndCap = lineCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
pen.LineJoin = LineJoin.Round;
|
||||||
|
pen.DashStyle = (DashStyle)borderStyle;
|
||||||
|
return pen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,7 +60,7 @@ public PointF LastPosition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PointF> positions = new List<PointF>();
|
protected List<PointF> positions = new List<PointF>();
|
||||||
private bool isPolygonMode;
|
private bool isPolygonMode;
|
||||||
|
|
||||||
public override void ShowNodes()
|
public override void ShowNodes()
|
||||||
|
@ -145,13 +145,8 @@ protected void DrawFreehand(Graphics g, Color borderColor, int borderSize, Borde
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
using (Pen pen = new Pen(borderColor, borderSize))
|
using (Pen pen = CreatePen(borderColor, borderSize, borderStyle))
|
||||||
{
|
{
|
||||||
pen.StartCap = LineCap.Round;
|
|
||||||
pen.EndCap = LineCap.Round;
|
|
||||||
pen.LineJoin = LineJoin.Round;
|
|
||||||
pen.DashStyle = (DashStyle)borderStyle;
|
|
||||||
|
|
||||||
g.DrawLines(pen, points.ToArray());
|
g.DrawLines(pen, points.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,6 +155,16 @@ protected void DrawFreehand(Graphics g, Color borderColor, int borderSize, Borde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual Pen CreatePen(Color borderColor, int borderSize, BorderStyle borderStyle)
|
||||||
|
{
|
||||||
|
Pen pen = new Pen(borderColor, borderSize);
|
||||||
|
pen.StartCap = LineCap.Round;
|
||||||
|
pen.EndCap = LineCap.Round;
|
||||||
|
pen.LineJoin = LineJoin.Round;
|
||||||
|
pen.DashStyle = (DashStyle)borderStyle;
|
||||||
|
return pen;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Move(float x, float y)
|
public override void Move(float x, float y)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < positions.Count; i++)
|
for (int i = 0; i < positions.Count; i++)
|
||||||
|
|
|
@ -1153,6 +1153,9 @@ private BaseShape CreateShape(ShapeType shapeType)
|
||||||
case ShapeType.DrawingFreehand:
|
case ShapeType.DrawingFreehand:
|
||||||
shape = new FreehandDrawingShape();
|
shape = new FreehandDrawingShape();
|
||||||
break;
|
break;
|
||||||
|
case ShapeType.DrawingFreehandArrow:
|
||||||
|
shape = new FreehandArrowDrawingShape();
|
||||||
|
break;
|
||||||
case ShapeType.DrawingLine:
|
case ShapeType.DrawingLine:
|
||||||
shape = new LineDrawingShape();
|
shape = new LineDrawingShape();
|
||||||
break;
|
break;
|
||||||
|
@ -1288,6 +1291,7 @@ private BaseShape CheckHover()
|
||||||
{
|
{
|
||||||
case ShapeType.RegionFreehand:
|
case ShapeType.RegionFreehand:
|
||||||
case ShapeType.DrawingFreehand:
|
case ShapeType.DrawingFreehand:
|
||||||
|
case ShapeType.DrawingFreehandArrow:
|
||||||
case ShapeType.DrawingLine:
|
case ShapeType.DrawingLine:
|
||||||
case ShapeType.DrawingArrow:
|
case ShapeType.DrawingArrow:
|
||||||
case ShapeType.DrawingTextOutline:
|
case ShapeType.DrawingTextOutline:
|
||||||
|
|
|
@ -251,6 +251,9 @@ internal void CreateToolbar()
|
||||||
case ShapeType.DrawingFreehand:
|
case ShapeType.DrawingFreehand:
|
||||||
img = Resources.pencil;
|
img = Resources.pencil;
|
||||||
break;
|
break;
|
||||||
|
case ShapeType.DrawingFreehandArrow:
|
||||||
|
img = Resources.pencil__arrow;
|
||||||
|
break;
|
||||||
case ShapeType.DrawingLine:
|
case ShapeType.DrawingLine:
|
||||||
img = ShareXResources.IsDarkTheme ? Resources.layer_shape_line_white : Resources.layer_shape_line;
|
img = ShareXResources.IsDarkTheme ? Resources.layer_shape_line_white : Resources.layer_shape_line;
|
||||||
break;
|
break;
|
||||||
|
@ -1492,6 +1495,7 @@ private void UpdateMenu()
|
||||||
case ShapeType.DrawingRectangle:
|
case ShapeType.DrawingRectangle:
|
||||||
case ShapeType.DrawingEllipse:
|
case ShapeType.DrawingEllipse:
|
||||||
case ShapeType.DrawingFreehand:
|
case ShapeType.DrawingFreehand:
|
||||||
|
case ShapeType.DrawingFreehandArrow:
|
||||||
case ShapeType.DrawingLine:
|
case ShapeType.DrawingLine:
|
||||||
case ShapeType.DrawingArrow:
|
case ShapeType.DrawingArrow:
|
||||||
case ShapeType.DrawingTextOutline:
|
case ShapeType.DrawingTextOutline:
|
||||||
|
@ -1523,6 +1527,7 @@ private void UpdateMenu()
|
||||||
case ShapeType.DrawingRectangle:
|
case ShapeType.DrawingRectangle:
|
||||||
case ShapeType.DrawingEllipse:
|
case ShapeType.DrawingEllipse:
|
||||||
case ShapeType.DrawingFreehand:
|
case ShapeType.DrawingFreehand:
|
||||||
|
case ShapeType.DrawingFreehandArrow:
|
||||||
case ShapeType.DrawingLine:
|
case ShapeType.DrawingLine:
|
||||||
case ShapeType.DrawingArrow:
|
case ShapeType.DrawingArrow:
|
||||||
case ShapeType.DrawingTextOutline:
|
case ShapeType.DrawingTextOutline:
|
||||||
|
@ -1572,6 +1577,7 @@ private void UpdateMenu()
|
||||||
case ShapeType.DrawingRectangle:
|
case ShapeType.DrawingRectangle:
|
||||||
case ShapeType.DrawingEllipse:
|
case ShapeType.DrawingEllipse:
|
||||||
case ShapeType.DrawingFreehand:
|
case ShapeType.DrawingFreehand:
|
||||||
|
case ShapeType.DrawingFreehandArrow:
|
||||||
case ShapeType.DrawingLine:
|
case ShapeType.DrawingLine:
|
||||||
case ShapeType.DrawingArrow:
|
case ShapeType.DrawingArrow:
|
||||||
case ShapeType.DrawingMagnify:
|
case ShapeType.DrawingMagnify:
|
||||||
|
@ -1580,7 +1586,7 @@ private void UpdateMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
tslnudCenterPoints.Visible = shapeType == ShapeType.DrawingLine || shapeType == ShapeType.DrawingArrow;
|
tslnudCenterPoints.Visible = shapeType == ShapeType.DrawingLine || shapeType == ShapeType.DrawingArrow;
|
||||||
tscbArrowHeadDirection.Visible = shapeType == ShapeType.DrawingArrow;
|
tscbArrowHeadDirection.Visible = shapeType == ShapeType.DrawingArrow || shapeType == ShapeType.DrawingFreehandArrow;
|
||||||
tscbImageInterpolationMode.Visible = shapeType == ShapeType.DrawingImage || shapeType == ShapeType.DrawingImageScreen || shapeType == ShapeType.DrawingMagnify;
|
tscbImageInterpolationMode.Visible = shapeType == ShapeType.DrawingImage || shapeType == ShapeType.DrawingImageScreen || shapeType == ShapeType.DrawingMagnify;
|
||||||
tslnudStartingStepValue.Visible = shapeType == ShapeType.DrawingStep;
|
tslnudStartingStepValue.Visible = shapeType == ShapeType.DrawingStep;
|
||||||
tslnudStepFontSize.Visible = tscbStepType.Visible = shapeType == ShapeType.DrawingStep;
|
tslnudStepFontSize.Visible = tscbStepType.Visible = shapeType == ShapeType.DrawingStep;
|
||||||
|
|
|
@ -158,6 +158,7 @@
|
||||||
<Compile Include="Animations\OpacityAnimation.cs" />
|
<Compile Include="Animations\OpacityAnimation.cs" />
|
||||||
<Compile Include="Shapes\BaseShape.cs" />
|
<Compile Include="Shapes\BaseShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
|
||||||
|
<Compile Include="Shapes\Drawing\FreehandArrowDrawingShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\SmartEraserDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\SmartEraserDrawingShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\ImageFileDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\ImageFileDrawingShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\MagnifyDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\MagnifyDrawingShape.cs" />
|
||||||
|
@ -982,6 +983,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\table-delete-column.png" />
|
<None Include="Resources\table-delete-column.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\pencil--arrow.png" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
Loading…
Reference in a new issue