mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added line drawing
This commit is contained in:
parent
18feef96c7
commit
a9b446e15e
6 changed files with 82 additions and 30 deletions
|
@ -144,6 +144,8 @@ public enum ShapeType
|
|||
DrawingRectangle,
|
||||
[Description("Drawing: Rounded rectangle")]
|
||||
DrawingRoundedRectangle,
|
||||
[Description("Drawing: Line")]
|
||||
DrawingLine,
|
||||
[Description("Drawing: Arrow")]
|
||||
DrawingArrow,
|
||||
[Description("Region: Rectangle")]
|
||||
|
|
|
@ -103,7 +103,9 @@ private void InitializeComponent()
|
|||
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
|
||||
Text = "ShareX - " + Resources.Surface_InitializeComponent_Region_capture;
|
||||
ShowInTaskbar = false;
|
||||
#if !DEBUG
|
||||
TopMost = true;
|
||||
#endif
|
||||
Shown += Surface_Shown;
|
||||
KeyUp += Surface_KeyUp;
|
||||
MouseDoubleClick += Surface_MouseDoubleClick;
|
||||
|
|
|
@ -720,34 +720,32 @@ public BaseShape CreateRegionShape(Rectangle rect)
|
|||
shape = new DiamondRegionShape();
|
||||
break;
|
||||
case ShapeType.DrawingRectangle:
|
||||
shape = new RectangleDrawingShape()
|
||||
{
|
||||
BorderColor = BorderColor,
|
||||
BorderSize = BorderSize,
|
||||
FillColor = FillColor
|
||||
};
|
||||
shape = new RectangleDrawingShape();
|
||||
break;
|
||||
case ShapeType.DrawingRoundedRectangle:
|
||||
shape = new RoundedRectangleDrawingShape()
|
||||
{
|
||||
BorderColor = BorderColor,
|
||||
BorderSize = BorderSize,
|
||||
FillColor = FillColor,
|
||||
Radius = RoundedRectangleRadius
|
||||
};
|
||||
break;
|
||||
case ShapeType.DrawingArrow:
|
||||
shape = new ArrowDrawingShape()
|
||||
{
|
||||
BorderColor = BorderColor,
|
||||
BorderSize = BorderSize,
|
||||
FillColor = FillColor
|
||||
};
|
||||
shape = new ArrowDrawingShape();
|
||||
break;
|
||||
case ShapeType.DrawingLine:
|
||||
shape = new LineDrawingShape();
|
||||
break;
|
||||
}
|
||||
|
||||
shape.Rectangle = rect;
|
||||
|
||||
if (shape is BaseDrawingShape)
|
||||
{
|
||||
BaseDrawingShape baseDrawingShape = (BaseDrawingShape)shape;
|
||||
baseDrawingShape.BorderColor = BorderColor;
|
||||
baseDrawingShape.BorderSize = BorderSize;
|
||||
baseDrawingShape.FillColor = FillColor;
|
||||
}
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,25 +32,15 @@ You should have received a copy of the GNU General Public License
|
|||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
public class ArrowDrawingShape : BaseDrawingShape
|
||||
public class ArrowDrawingShape : LineDrawingShape
|
||||
{
|
||||
public override ShapeType ShapeType { get; } = ShapeType.DrawingArrow;
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
public override Pen CreatePen()
|
||||
{
|
||||
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;
|
||||
}
|
||||
Pen pen = base.CreatePen();
|
||||
pen.CustomEndCap = new AdjustableArrowCap(4, 6);
|
||||
return pen;
|
||||
}
|
||||
}
|
||||
}
|
59
ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs
Normal file
59
ShareX.ScreenCaptureLib/Shapes/Drawing/LineDrawingShape.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
#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 LineDrawingShape : BaseDrawingShape
|
||||
{
|
||||
public override ShapeType ShapeType { get; } = ShapeType.DrawingLine;
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
if (BorderColor != Color.Transparent && BorderSize > 0)
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
using (Pen pen = CreatePen())
|
||||
{
|
||||
g.DrawLine(pen, StartPosition, EndPosition);
|
||||
}
|
||||
|
||||
g.SmoothingMode = SmoothingMode.None;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Pen CreatePen()
|
||||
{
|
||||
return new Pen(BorderColor, BorderSize);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@
|
|||
<Compile Include="Shapes\BaseShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\BaseDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\LineDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\RectangleDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\RoundedRectangleDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Region\DiamondRegionShape.cs" />
|
||||
|
|
Loading…
Reference in a new issue