Removed rounded rectangle region and drawing instead rectangle have corner radius option

Changes to annotation options default values
This commit is contained in:
Jaex 2016-11-30 18:17:12 +03:00
parent b417d31c0c
commit e07d4cb036
12 changed files with 83 additions and 167 deletions

View file

@ -59,11 +59,11 @@ public static void AddRoundedRectangleProper(this GraphicsPath graphicsPath, Rec
}
}
public static void AddRoundedRectangle(this GraphicsPath graphicsPath, RectangleF rect, float radius)
public static void AddRoundedRectangle(this GraphicsPath gp, RectangleF rect, float radius)
{
if (radius <= 0f)
{
graphicsPath.AddRectangle(rect);
gp.AddRectangle(rect);
}
else
{
@ -72,7 +72,7 @@ public static void AddRoundedRectangle(this GraphicsPath graphicsPath, Rectangle
// then return a capsule instead of a lozenge
if (radius >= (Math.Min(rect.Width, rect.Height) / 2.0f))
{
graphicsPath.AddCapsule(rect);
gp.AddCapsule(rect);
}
else
{
@ -83,26 +83,26 @@ public static void AddRoundedRectangle(this GraphicsPath graphicsPath, Rectangle
RectangleF arc = new RectangleF(rect.Location, size);
// Top left arc
graphicsPath.AddArc(arc, 180, 90);
gp.AddArc(arc, 180, 90);
// Top right arc
arc.X = rect.Right - diameter;
graphicsPath.AddArc(arc, 270, 90);
gp.AddArc(arc, 270, 90);
// Bottom right arc
arc.Y = rect.Bottom - diameter;
graphicsPath.AddArc(arc, 0, 90);
gp.AddArc(arc, 0, 90);
// Bottom left arc
arc.X = rect.Left;
graphicsPath.AddArc(arc, 90, 90);
gp.AddArc(arc, 90, 90);
graphicsPath.CloseFigure();
gp.CloseFigure();
}
}
}
public static void AddCapsule(this GraphicsPath graphicsPath, RectangleF rect)
public static void AddCapsule(this GraphicsPath gp, RectangleF rect)
{
float diameter;
RectangleF arc;
@ -115,9 +115,9 @@ public static void AddCapsule(this GraphicsPath graphicsPath, RectangleF rect)
diameter = rect.Height;
SizeF sizeF = new SizeF(diameter, diameter);
arc = new RectangleF(rect.Location, sizeF);
graphicsPath.AddArc(arc, 90, 180);
gp.AddArc(arc, 90, 180);
arc.X = rect.Right - diameter;
graphicsPath.AddArc(arc, 270, 180);
gp.AddArc(arc, 270, 180);
}
else if (rect.Width < rect.Height)
{
@ -125,22 +125,22 @@ public static void AddCapsule(this GraphicsPath graphicsPath, RectangleF rect)
diameter = rect.Width;
SizeF sizeF = new SizeF(diameter, diameter);
arc = new RectangleF(rect.Location, sizeF);
graphicsPath.AddArc(arc, 180, 180);
gp.AddArc(arc, 180, 180);
arc.Y = rect.Bottom - diameter;
graphicsPath.AddArc(arc, 0, 180);
gp.AddArc(arc, 0, 180);
}
else
{
// Circle
graphicsPath.AddEllipse(rect);
gp.AddEllipse(rect);
}
}
catch
{
graphicsPath.AddEllipse(rect);
gp.AddEllipse(rect);
}
graphicsPath.CloseFigure();
gp.CloseFigure();
}
public static void AddDiamond(this GraphicsPath graphicsPath, RectangleF rect)

View file

@ -182,11 +182,9 @@ public enum ShapeCategory
public enum ShapeType // Localized
{
RegionRectangle,
RegionRoundedRectangle,
RegionEllipse,
RegionFreehand,
DrawingRectangle,
DrawingRoundedRectangle,
DrawingEllipse,
DrawingFreehand,
DrawingLine,

View file

@ -763,20 +763,16 @@ private void WriteTips(StringBuilder sb)
sb.AppendLine(Resources.RectangleRegionForm_WriteTips__Ctrl___Mouse_wheel__Change_magnifier_size);
if (ShapeManager.CurrentShapeType == ShapeType.RegionRectangle) sb.Append("-> ");
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 0", ShapeType.RegionRectangle.GetLocalizedDescription()));
if (ShapeManager.CurrentShapeType == ShapeType.RegionRoundedRectangle) sb.Append("-> ");
sb.AppendLine(ShapeType.RegionRoundedRectangle.GetLocalizedDescription());
if (ShapeManager.CurrentShapeType == ShapeType.RegionEllipse) sb.Append("-> ");
sb.AppendLine(ShapeType.RegionEllipse.GetLocalizedDescription());
if (ShapeManager.CurrentShapeType == ShapeType.RegionFreehand) sb.Append("-> ");
sb.AppendLine(ShapeType.RegionFreehand.GetLocalizedDescription());
if (ShapeManager.CurrentShapeType == ShapeType.DrawingRectangle) sb.Append("-> ");
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 1", ShapeType.DrawingRectangle.GetLocalizedDescription()));
if (ShapeManager.CurrentShapeType == ShapeType.DrawingRoundedRectangle) sb.Append("-> ");
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 2", ShapeType.DrawingRoundedRectangle.GetLocalizedDescription()));
if (ShapeManager.CurrentShapeType == ShapeType.DrawingEllipse) sb.Append("-> ");
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 3", ShapeType.DrawingEllipse.GetLocalizedDescription()));
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 2", ShapeType.DrawingEllipse.GetLocalizedDescription()));
if (ShapeManager.CurrentShapeType == ShapeType.DrawingFreehand) sb.Append("-> ");
sb.AppendLine(ShapeType.DrawingFreehand.GetLocalizedDescription());
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 3", ShapeType.DrawingFreehand.GetLocalizedDescription()));
if (ShapeManager.CurrentShapeType == ShapeType.DrawingLine) sb.Append("-> ");
sb.AppendLine(string.Format("[{0}] {1}", "Numpad 4", ShapeType.DrawingLine.GetLocalizedDescription()));
if (ShapeManager.CurrentShapeType == ShapeType.DrawingArrow) sb.Append("-> ");

View file

@ -29,26 +29,30 @@ namespace ShareX.ScreenCaptureLib
{
public class AnnotationOptions
{
// Drawing
public Color BorderColor { get; set; } = Color.Red;
public int BorderSize { get; set; } = 5;
public Color FillColor { get; set; } = Color.FromArgb(0, 0, 0, 0);
public bool Shadow { get; set; } = true;
public static readonly Color PrimaryColor = Color.Red;
public static readonly Color SecondaryColor = Color.White;
public static readonly Color TransparentColor = Color.FromArgb(0, 0, 0, 0);
// Rounded rectangle region, rounded rectangle drawing
public int RoundedRectangleRadius { get; set; } = 8;
// Region
public int RegionCornerRadius { get; set; } = 0;
// Drawing
public Color BorderColor { get; set; } = PrimaryColor;
public int BorderSize { get; set; } = 5;
public Color FillColor { get; set; } = TransparentColor;
public int DrawingCornerRadius { get; set; } = 3;
public bool Shadow { get; set; } = true;
// Text drawing
public TextDrawingOptions TextOptions { get; set; } = new TextDrawingOptions();
public Color TextBorderColor { get; set; } = Color.White;
public int TextBorderSize { get; set; } = 0;
public Color TextFillColor { get; set; } = Color.FromArgb(150, Color.Black);
public int TextCornerRadius { get; set; } = 0;
public Color TextBorderColor { get; set; } = SecondaryColor;
public int TextBorderSize { get; set; } = 2;
public Color TextFillColor { get; set; } = PrimaryColor;
// Step drawing
public Color StepBorderColor { get; set; } = Color.White;
public Color StepBorderColor { get; set; } = SecondaryColor;
public int StepBorderSize { get; set; } = 2;
public Color StepFillColor { get; set; } = Color.Red;
public Color StepFillColor { get; set; } = PrimaryColor;
// Blur effect
public int BlurRadius { get; set; } = 15;

View file

@ -35,6 +35,18 @@ public class RectangleDrawingShape : BaseDrawingShape
public int CornerRadius { get; set; }
public override void OnConfigLoad()
{
base.OnConfigLoad();
CornerRadius = AnnotationOptions.DrawingCornerRadius;
}
public override void OnConfigSave()
{
base.OnConfigSave();
AnnotationOptions.DrawingCornerRadius = CornerRadius;
}
public override void OnDraw(Graphics g)
{
DrawRectangle(g);

View file

@ -1,44 +0,0 @@
#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)
namespace ShareX.ScreenCaptureLib
{
public class RoundedRectangleDrawingShape : RectangleDrawingShape
{
public override ShapeType ShapeType { get; } = ShapeType.DrawingRoundedRectangle;
public override void OnConfigLoad()
{
base.OnConfigLoad();
CornerRadius = AnnotationOptions.RoundedRectangleRadius;
}
public override void OnConfigSave()
{
base.OnConfigSave();
AnnotationOptions.RoundedRectangleRadius = CornerRadius;
}
}
}

View file

@ -42,7 +42,7 @@ public override void OnConfigLoad()
BorderColor = AnnotationOptions.TextBorderColor;
BorderSize = AnnotationOptions.TextBorderSize;
FillColor = AnnotationOptions.TextFillColor;
CornerRadius = AnnotationOptions.TextCornerRadius;
CornerRadius = AnnotationOptions.DrawingCornerRadius;
Shadow = AnnotationOptions.Shadow;
}
@ -52,7 +52,7 @@ public override void OnConfigSave()
AnnotationOptions.TextBorderColor = BorderColor;
AnnotationOptions.TextBorderSize = BorderSize;
AnnotationOptions.TextFillColor = FillColor;
AnnotationOptions.TextCornerRadius = CornerRadius;
AnnotationOptions.DrawingCornerRadius = CornerRadius;
AnnotationOptions.Shadow = Shadow;
}

View file

@ -23,10 +23,31 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace ShareX.ScreenCaptureLib
{
public class RectangleRegionShape : BaseRegionShape
{
public override ShapeType ShapeType { get; } = ShapeType.RegionRectangle;
public int CornerRadius { get; set; }
public override void OnConfigLoad()
{
CornerRadius = AnnotationOptions.RegionCornerRadius;
}
public override void OnConfigSave()
{
AnnotationOptions.RegionCornerRadius = CornerRadius;
}
public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, CornerRadius);
}
}
}

View file

@ -1,53 +0,0 @@
#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 ShareX.HelpersLib;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace ShareX.ScreenCaptureLib
{
public class RoundedRectangleRegionShape : BaseRegionShape
{
public override ShapeType ShapeType { get; } = ShapeType.RegionRoundedRectangle;
public int CornerRadius { get; set; }
public override void OnConfigLoad()
{
CornerRadius = AnnotationOptions.RoundedRectangleRadius;
}
public override void OnConfigSave()
{
AnnotationOptions.RoundedRectangleRadius = CornerRadius;
}
public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, CornerRadius);
}
}
}

View file

@ -401,10 +401,10 @@ private void form_KeyDown(object sender, KeyEventArgs e)
CurrentShapeType = ShapeType.DrawingRectangle;
break;
case Keys.NumPad2:
CurrentShapeType = ShapeType.DrawingRoundedRectangle;
CurrentShapeType = ShapeType.DrawingEllipse;
break;
case Keys.NumPad3:
CurrentShapeType = ShapeType.DrawingEllipse;
CurrentShapeType = ShapeType.DrawingFreehand;
break;
case Keys.NumPad4:
CurrentShapeType = ShapeType.DrawingLine;
@ -693,9 +693,6 @@ private BaseShape CreateShape(ShapeType shapeType)
case ShapeType.RegionRectangle:
shape = new RectangleRegionShape();
break;
case ShapeType.RegionRoundedRectangle:
shape = new RoundedRectangleRegionShape();
break;
case ShapeType.RegionEllipse:
shape = new EllipseRegionShape();
break;
@ -705,9 +702,6 @@ private BaseShape CreateShape(ShapeType shapeType)
case ShapeType.DrawingRectangle:
shape = new RectangleDrawingShape();
break;
case ShapeType.DrawingRoundedRectangle:
shape = new RoundedRectangleDrawingShape();
break;
case ShapeType.DrawingEllipse:
shape = new EllipseDrawingShape();
break;
@ -1017,7 +1011,6 @@ private bool IsShapeTypeRegion(ShapeType shapeType)
switch (shapeType)
{
case ShapeType.RegionRectangle:
case ShapeType.RegionRoundedRectangle:
case ShapeType.RegionEllipse:
case ShapeType.RegionFreehand:
return true;

View file

@ -184,9 +184,6 @@ private void CreateToolbar()
case ShapeType.RegionRectangle:
img = Resources.layer_shape_region;
break;
case ShapeType.RegionRoundedRectangle:
img = Resources.layer_shape_round_region;
break;
case ShapeType.RegionEllipse:
img = Resources.layer_shape_ellipse_region;
break;
@ -196,9 +193,6 @@ private void CreateToolbar()
case ShapeType.DrawingRectangle:
img = Resources.layer_shape;
break;
case ShapeType.DrawingRoundedRectangle:
img = Resources.layer_shape_round;
break;
case ShapeType.DrawingEllipse:
img = Resources.layer_shape_ellipse;
break;
@ -409,13 +403,13 @@ private void CreateToolbar()
{
ShapeType shapeType = CurrentShapeType;
if (shapeType == ShapeType.RegionRoundedRectangle || shapeType == ShapeType.DrawingRoundedRectangle)
if (shapeType == ShapeType.RegionRectangle)
{
AnnotationOptions.RoundedRectangleRadius = (int)tslnudCornerRadius.Content.Value;
AnnotationOptions.RegionCornerRadius = (int)tslnudCornerRadius.Content.Value;
}
else if (shapeType == ShapeType.DrawingText)
else if (shapeType == ShapeType.DrawingRectangle || shapeType == ShapeType.DrawingText)
{
AnnotationOptions.TextCornerRadius = (int)tslnudCornerRadius.Content.Value;
AnnotationOptions.DrawingCornerRadius = (int)tslnudCornerRadius.Content.Value;
}
UpdateCurrentShape();
@ -893,13 +887,13 @@ private void UpdateMenu()
int cornerRadius = 0;
if (shapeType == ShapeType.RegionRoundedRectangle || shapeType == ShapeType.DrawingRoundedRectangle)
if (shapeType == ShapeType.RegionRectangle)
{
cornerRadius = AnnotationOptions.RoundedRectangleRadius;
cornerRadius = AnnotationOptions.RegionCornerRadius;
}
else if (shapeType == ShapeType.DrawingText)
else if (shapeType == ShapeType.DrawingRectangle || shapeType == ShapeType.DrawingText)
{
cornerRadius = AnnotationOptions.TextCornerRadius;
cornerRadius = AnnotationOptions.DrawingCornerRadius;
}
tslnudCornerRadius.Content.Value = cornerRadius;
@ -918,9 +912,8 @@ private void UpdateMenu()
default:
tsddbShapeOptions.Visible = false;
break;
case ShapeType.RegionRoundedRectangle:
case ShapeType.RegionRectangle:
case ShapeType.DrawingRectangle:
case ShapeType.DrawingRoundedRectangle:
case ShapeType.DrawingEllipse:
case ShapeType.DrawingFreehand:
case ShapeType.DrawingLine:
@ -944,7 +937,6 @@ private void UpdateMenu()
tsmiShadow.Visible = false;
break;
case ShapeType.DrawingRectangle:
case ShapeType.DrawingRoundedRectangle:
case ShapeType.DrawingEllipse:
case ShapeType.DrawingFreehand:
case ShapeType.DrawingLine:
@ -964,7 +956,6 @@ private void UpdateMenu()
tsbFillColor.Visible = false;
break;
case ShapeType.DrawingRectangle:
case ShapeType.DrawingRoundedRectangle:
case ShapeType.DrawingEllipse:
case ShapeType.DrawingText:
case ShapeType.DrawingSpeechBalloon:
@ -978,8 +969,8 @@ private void UpdateMenu()
default:
tslnudCornerRadius.Visible = false;
break;
case ShapeType.RegionRoundedRectangle:
case ShapeType.DrawingRoundedRectangle:
case ShapeType.RegionRectangle:
case ShapeType.DrawingRectangle:
case ShapeType.DrawingText:
tslnudCornerRadius.Visible = true;
break;

View file

@ -106,7 +106,6 @@
<Compile Include="Shapes\Drawing\LineDrawingShape.cs" />
<Compile Include="Shapes\Effect\PixelateEffectShape.cs" />
<Compile Include="Shapes\Drawing\RectangleDrawingShape.cs" />
<Compile Include="Shapes\Drawing\RoundedRectangleDrawingShape.cs" />
<Compile Include="Shapes\Effect\BaseEffectShape.cs" />
<Compile Include="Shapes\Region\EllipseRegionShape.cs" />
<Compile Include="Shapes\Region\RectangleRegionShape.cs" />
@ -140,7 +139,6 @@
<Compile Include="RegionHelpers\ResizeNode.cs" />
<Compile Include="RegionCaptureTasks.cs" />
<Compile Include="ScrollingCaptureOptions.cs" />
<Compile Include="Shapes\Region\RoundedRectangleRegionShape.cs" />
<Compile Include="RegionHelpers\SimpleWindowInfo.cs" />
<Compile Include="RegionHelpers\SnapSize.cs" />
<Compile Include="RegionCaptureOptions.cs" />