Removed corner radius setting from rectangle drawing, don't override OnDraw in rounded rectangle shape to use rectangle shape with corner radius assigned, don't show corner radius setting for speech balloon until it can be resolved

This commit is contained in:
Jaex 2016-09-03 11:26:02 +03:00
parent 85752b1193
commit 84b25135fb
5 changed files with 15 additions and 70 deletions

View file

@ -34,9 +34,6 @@ public class AnnotationOptions
public int BorderSize { get; set; } = 2;
public Color FillColor { get; set; } = Color.FromArgb(0, 0, 0, 0);
// Rectangle
public int RectangleCornerRadius { get; set; } = 0;
// Rounded rectangle region, rounded rectangle drawing
public int RoundedRectangleRadius { get; set; } = 15;

View file

@ -33,19 +33,7 @@ public class RectangleDrawingShape : BaseDrawingShape
{
public override ShapeType ShapeType { get; } = ShapeType.DrawingRectangle;
public float CornerRadius { get; set; }
public override void OnConfigLoad()
{
base.OnConfigLoad();
CornerRadius = AnnotationOptions.RectangleCornerRadius;
}
public override void OnConfigSave()
{
base.OnConfigSave();
AnnotationOptions.RectangleCornerRadius = (int)CornerRadius;
}
public int CornerRadius { get; set; }
public override void OnDraw(Graphics g)
{
@ -85,5 +73,10 @@ public override void OnDraw(Graphics g)
if (pen != null) pen.Dispose();
}
}
public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, CornerRadius);
}
}
}

View file

@ -29,55 +29,20 @@ You should have received a copy of the GNU General Public License
namespace ShareX.ScreenCaptureLib
{
public class RoundedRectangleDrawingShape : BaseDrawingShape
public class RoundedRectangleDrawingShape : RectangleDrawingShape
{
public override ShapeType ShapeType { get; } = ShapeType.DrawingRoundedRectangle;
public float Radius { get; set; }
public override void OnConfigLoad()
{
base.OnConfigLoad();
Radius = AnnotationOptions.RoundedRectangleRadius;
CornerRadius = AnnotationOptions.RoundedRectangleRadius;
}
public override void OnConfigSave()
{
base.OnConfigSave();
AnnotationOptions.RoundedRectangleRadius = (int)Radius;
}
public override void OnDraw(Graphics g)
{
Brush brush = null;
Pen pen = null;
try
{
if (FillColor.A > 0)
{
brush = new SolidBrush(FillColor);
}
if (BorderSize > 0 && BorderColor.A > 0)
{
pen = new Pen(BorderColor, BorderSize);
}
g.SmoothingMode = SmoothingMode.HighQuality;
g.DrawRoundedRectangle(brush, pen, Rectangle, Radius);
g.SmoothingMode = SmoothingMode.None;
}
finally
{
if (brush != null) brush.Dispose();
if (pen != null) pen.Dispose();
}
}
public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, Radius);
AnnotationOptions.RoundedRectangleRadius = CornerRadius;
}
}
}

View file

@ -33,21 +33,21 @@ public class RoundedRectangleRegionShape : BaseRegionShape
{
public override ShapeType ShapeType { get; } = ShapeType.RegionRoundedRectangle;
public float Radius { get; set; }
public int CornerRadius { get; set; }
public override void OnConfigLoad()
{
Radius = AnnotationOptions.RoundedRectangleRadius;
CornerRadius = AnnotationOptions.RoundedRectangleRadius;
}
public override void OnConfigSave()
{
AnnotationOptions.RoundedRectangleRadius = (int)Radius;
AnnotationOptions.RoundedRectangleRadius = CornerRadius;
}
public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, Radius);
gp.AddRoundedRectangle(rect, CornerRadius);
}
}
}

View file

@ -511,11 +511,7 @@ private void CreateContextMenu()
{
AnnotationOptions.RoundedRectangleRadius = (int)tslnudCornerRadius.Content.Value;
}
else if (shapeType == ShapeType.DrawingRectangle)
{
AnnotationOptions.RectangleCornerRadius = (int)tslnudCornerRadius.Content.Value;
}
else if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
else if (shapeType == ShapeType.DrawingText)
{
AnnotationOptions.TextCornerRadius = (int)tslnudCornerRadius.Content.Value;
}
@ -766,11 +762,7 @@ private void UpdateContextMenu()
{
cornerRadius = AnnotationOptions.RoundedRectangleRadius;
}
else if (shapeType == ShapeType.DrawingRectangle)
{
cornerRadius = AnnotationOptions.RectangleCornerRadius;
}
else if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
else if (shapeType == ShapeType.DrawingText)
{
cornerRadius = AnnotationOptions.TextCornerRadius;
}
@ -848,9 +840,7 @@ private void UpdateContextMenu()
break;
case ShapeType.RegionRoundedRectangle:
case ShapeType.DrawingRoundedRectangle:
case ShapeType.DrawingRectangle:
case ShapeType.DrawingText:
case ShapeType.DrawingSpeechBalloon:
tslnudCornerRadius.Visible = true;
break;
}