2016-05-23 07:19:25 +12:00
|
|
|
|
#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)
|
|
|
|
|
|
2016-11-30 08:47:53 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2016-05-23 07:19:25 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
|
using System.Drawing.Text;
|
|
|
|
|
|
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
|
|
|
|
{
|
2016-11-30 08:47:53 +13:00
|
|
|
|
public class StepDrawingShape : EllipseDrawingShape
|
2016-05-23 07:19:25 +12:00
|
|
|
|
{
|
2016-05-24 03:31:22 +12:00
|
|
|
|
private const int DefaultSize = 30;
|
|
|
|
|
|
2016-05-23 07:19:25 +12:00
|
|
|
|
public override ShapeType ShapeType { get; } = ShapeType.DrawingStep;
|
2016-08-24 01:30:59 +12:00
|
|
|
|
|
2016-05-23 07:19:25 +12:00
|
|
|
|
public int Number { get; set; }
|
|
|
|
|
|
2016-05-23 08:19:13 +12:00
|
|
|
|
public StepDrawingShape()
|
|
|
|
|
{
|
|
|
|
|
Rectangle = new Rectangle(0, 0, DefaultSize, DefaultSize);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-25 01:59:53 +12:00
|
|
|
|
public override void ShowNodes()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-24 01:03:48 +12:00
|
|
|
|
public override void OnCreating()
|
|
|
|
|
{
|
|
|
|
|
Manager.IsMoving = true;
|
|
|
|
|
Point pos = InputManager.MousePosition0Based;
|
|
|
|
|
Rectangle = new Rectangle(new Point(pos.X - Rectangle.Width / 2, pos.Y - Rectangle.Height / 2), Rectangle.Size);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-03 17:35:34 +12:00
|
|
|
|
public override void OnConfigLoad()
|
2016-05-24 03:31:22 +12:00
|
|
|
|
{
|
|
|
|
|
BorderColor = AnnotationOptions.StepBorderColor;
|
|
|
|
|
BorderSize = AnnotationOptions.StepBorderSize;
|
|
|
|
|
FillColor = AnnotationOptions.StepFillColor;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-03 17:35:34 +12:00
|
|
|
|
public override void OnConfigSave()
|
2016-05-24 03:31:22 +12:00
|
|
|
|
{
|
|
|
|
|
AnnotationOptions.StepBorderColor = BorderColor;
|
|
|
|
|
AnnotationOptions.StepBorderSize = BorderSize;
|
|
|
|
|
AnnotationOptions.StepFillColor = FillColor;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-23 07:19:25 +12:00
|
|
|
|
public override void OnDraw(Graphics g)
|
|
|
|
|
{
|
2016-11-30 08:47:53 +13:00
|
|
|
|
base.OnDraw(g);
|
2016-05-23 07:19:25 +12:00
|
|
|
|
|
2016-11-30 08:47:53 +13:00
|
|
|
|
if (Shadow)
|
2016-05-23 07:19:25 +12:00
|
|
|
|
{
|
2016-11-30 08:47:53 +13:00
|
|
|
|
DrawNumber(g, Number, ShadowColor, Rectangle.LocationOffset(ShadowOffset));
|
2016-05-23 07:19:25 +12:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-30 08:47:53 +13:00
|
|
|
|
DrawNumber(g, Number, BorderColor, Rectangle);
|
|
|
|
|
}
|
2016-05-23 08:19:13 +12:00
|
|
|
|
|
2016-11-30 08:47:53 +13:00
|
|
|
|
protected void DrawNumber(Graphics g, int number, Color textColor, Rectangle rect)
|
|
|
|
|
{
|
|
|
|
|
if (rect.Width > 20 && rect.Height > 20)
|
2016-05-23 07:19:25 +12:00
|
|
|
|
{
|
2016-05-23 11:53:10 +12:00
|
|
|
|
int offset;
|
2016-05-23 07:19:25 +12:00
|
|
|
|
|
2016-11-30 08:47:53 +13:00
|
|
|
|
if (number > 99)
|
2016-05-26 07:34:30 +12:00
|
|
|
|
{
|
|
|
|
|
offset = 20;
|
|
|
|
|
}
|
2016-11-30 08:47:53 +13:00
|
|
|
|
else if (number > 9)
|
2016-05-23 11:53:10 +12:00
|
|
|
|
{
|
|
|
|
|
offset = 15;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
offset = 10;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-30 08:47:53 +13:00
|
|
|
|
int fontSize = Math.Min(rect.Width, rect.Height) - offset;
|
2016-05-23 11:53:10 +12:00
|
|
|
|
|
2016-05-25 09:11:24 +12:00
|
|
|
|
using (Font font = new Font(FontFamily.GenericSansSerif, fontSize, FontStyle.Bold, GraphicsUnit.Pixel))
|
2016-05-23 07:19:25 +12:00
|
|
|
|
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
2016-11-30 08:47:53 +13:00
|
|
|
|
using (Brush textBrush = new SolidBrush(textColor))
|
2016-05-23 07:19:25 +12:00
|
|
|
|
{
|
|
|
|
|
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
|
2016-11-30 08:47:53 +13:00
|
|
|
|
g.DrawString(number.ToString(), font, textBrush, rect, sf);
|
2016-05-23 07:19:25 +12:00
|
|
|
|
g.TextRenderingHint = TextRenderingHint.SystemDefault;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-03 21:15:26 +12:00
|
|
|
|
public override void Resize(int x, int y, bool fromBottomRight)
|
|
|
|
|
{
|
2016-08-08 20:46:45 +12:00
|
|
|
|
Move(x, y);
|
2016-08-03 21:15:26 +12:00
|
|
|
|
}
|
2016-05-23 07:19:25 +12:00
|
|
|
|
}
|
|
|
|
|
}
|