Added step shadow

This commit is contained in:
Jaex 2016-11-29 22:47:53 +03:00
parent 37c3b7aa18
commit a6192aa76a
4 changed files with 18 additions and 33 deletions

View file

@ -43,7 +43,7 @@ public override void OnDraw(Graphics g)
DrawEllipse(g, BorderColor, BorderSize, FillColor, Rectangle);
}
private void DrawEllipse(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect)
protected void DrawEllipse(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect)
{
g.SmoothingMode = SmoothingMode.HighQuality;

View file

@ -117,7 +117,7 @@ public override void OnDraw(Graphics g)
DrawFreehand(g, BorderColor, BorderSize, positions.ToArray());
}
private void DrawFreehand(Graphics g, Color borderColor, int borderSize, Point[] points)
protected void DrawFreehand(Graphics g, Color borderColor, int borderSize, Point[] points)
{
if (points.Length > 0 && borderSize > 0 && borderColor.A > 0)
{

View file

@ -45,7 +45,7 @@ public override void OnDraw(Graphics g)
DrawRectangle(g, BorderColor, BorderSize, FillColor, Rectangle, CornerRadius);
}
private void DrawRectangle(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect, int cornerRadius)
protected void DrawRectangle(Graphics g, Color borderColor, int borderSize, Color fillColor, Rectangle rect, int cornerRadius)
{
Brush brush = null;
Pen pen = null;

View file

@ -23,6 +23,7 @@
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -30,7 +31,7 @@
namespace ShareX.ScreenCaptureLib
{
public class StepDrawingShape : BaseDrawingShape
public class StepDrawingShape : EllipseDrawingShape
{
private const int DefaultSize = 30;
@ -70,37 +71,27 @@ public override void OnConfigSave()
public override void OnDraw(Graphics g)
{
g.SmoothingMode = SmoothingMode.HighQuality;
base.OnDraw(g);
if (FillColor.A > 0)
if (Shadow)
{
using (Brush brush = new SolidBrush(FillColor))
{
g.FillEllipse(brush, Rectangle);
}
DrawNumber(g, Number, ShadowColor, Rectangle.LocationOffset(ShadowOffset));
}
if (BorderSize > 0 && BorderColor.A > 0)
{
//g.DrawEllipse(Pens.Black, Rectangle.LocationOffset(0, 1));
DrawNumber(g, Number, BorderColor, Rectangle);
}
using (Pen pen = new Pen(BorderColor, BorderSize))
{
g.DrawEllipse(pen, Rectangle);
}
}
g.SmoothingMode = SmoothingMode.None;
if (Rectangle.Width > 20 && Rectangle.Height > 20)
protected void DrawNumber(Graphics g, int number, Color textColor, Rectangle rect)
{
if (rect.Width > 20 && rect.Height > 20)
{
int offset;
if (Number > 99)
if (number > 99)
{
offset = 20;
}
else if (Number > 9)
else if (number > 9)
{
offset = 15;
}
@ -109,25 +100,19 @@ public override void OnDraw(Graphics g)
offset = 10;
}
int fontSize = Math.Min(Rectangle.Width, Rectangle.Height) - offset;
int fontSize = Math.Min(rect.Width, rect.Height) - offset;
using (Font font = new Font(FontFamily.GenericSansSerif, fontSize, FontStyle.Bold, GraphicsUnit.Pixel))
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
using (Brush textBrush = new SolidBrush(BorderColor))
using (Brush textBrush = new SolidBrush(textColor))
{
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
//g.DrawString(Number.ToString(), font, Brushes.Black, Rectangle.LocationOffset(1, 1), sf);
g.DrawString(Number.ToString(), font, textBrush, Rectangle, sf);
g.DrawString(number.ToString(), font, textBrush, rect, sf);
g.TextRenderingHint = TextRenderingHint.SystemDefault;
}
}
}
public override void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
{
gp.AddEllipse(rect);
}
public override void Resize(int x, int y, bool fromBottomRight)
{
Move(x, y);