2015-07-17 03:21:02 +12:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2016-01-04 04:16:01 +13:00
|
|
|
|
Copyright (c) 2007-2016 ShareX Team
|
2015-07-17 03:21:02 +12:00
|
|
|
|
|
|
|
|
|
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-05-03 21:35:10 +12:00
|
|
|
|
using ShareX.HelpersLib;
|
2015-07-17 03:21:02 +12:00
|
|
|
|
using System.Drawing;
|
2016-05-03 21:35:10 +12:00
|
|
|
|
using System.Drawing.Drawing2D;
|
2015-07-17 03:21:02 +12:00
|
|
|
|
|
|
|
|
|
namespace ShareX.ScreenCaptureLib
|
|
|
|
|
{
|
2016-05-03 22:48:37 +12:00
|
|
|
|
public abstract class BaseShape
|
2015-07-17 03:21:02 +12:00
|
|
|
|
{
|
2016-05-24 04:18:09 +12:00
|
|
|
|
protected const int MinimumSize = 3;
|
2016-05-23 11:18:29 +12:00
|
|
|
|
|
2016-05-03 23:06:15 +12:00
|
|
|
|
public abstract ShapeType ShapeType { get; }
|
2016-05-07 01:02:46 +12:00
|
|
|
|
|
2016-05-06 10:15:41 +12:00
|
|
|
|
public virtual NodeType NodeType { get; } = NodeType.Rectangle;
|
2016-05-03 23:06:15 +12:00
|
|
|
|
|
2016-05-03 19:46:45 +12:00
|
|
|
|
public Rectangle Rectangle { get; set; }
|
2016-05-06 11:23:18 +12:00
|
|
|
|
|
2016-05-20 11:53:45 +12:00
|
|
|
|
public ShapeManager Manager { get; set; }
|
|
|
|
|
|
2016-05-21 05:34:45 +12:00
|
|
|
|
protected AnnotationOptions AnnotationOptions
|
2016-05-21 05:01:00 +12:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-05-21 05:34:45 +12:00
|
|
|
|
return Manager.Config.AnnotationOptions;
|
2016-05-21 05:01:00 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-06 11:23:18 +12:00
|
|
|
|
private Point startPosition;
|
|
|
|
|
|
|
|
|
|
public Point StartPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return startPosition;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
startPosition = value;
|
|
|
|
|
|
|
|
|
|
Rectangle = CaptureHelpers.CreateRectangle(StartPosition, EndPosition);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Point endPosition;
|
|
|
|
|
|
|
|
|
|
public Point EndPosition
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return endPosition;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
endPosition = value;
|
|
|
|
|
|
|
|
|
|
Rectangle = CaptureHelpers.CreateRectangle(StartPosition, EndPosition);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-17 03:21:02 +12:00
|
|
|
|
|
2016-05-24 04:18:09 +12:00
|
|
|
|
public virtual bool IsValidShape
|
2016-05-23 11:18:29 +12:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return !Rectangle.IsEmpty && Rectangle.Width >= MinimumSize && Rectangle.Height >= MinimumSize;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-29 22:10:48 +12:00
|
|
|
|
public virtual bool Intersects(Point position)
|
|
|
|
|
{
|
|
|
|
|
return Rectangle.Contains(position);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 10:17:51 +12:00
|
|
|
|
public virtual void AddShapePath(GraphicsPath gp, Rectangle rect)
|
|
|
|
|
{
|
|
|
|
|
gp.AddRectangle(rect);
|
|
|
|
|
}
|
2016-05-03 21:35:10 +12:00
|
|
|
|
|
|
|
|
|
public void AddShapePath(GraphicsPath gp)
|
|
|
|
|
{
|
|
|
|
|
AddShapePath(gp, Rectangle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddShapePath(GraphicsPath gp, int sizeOffset)
|
|
|
|
|
{
|
|
|
|
|
Rectangle rect = Rectangle.SizeOffset(sizeOffset);
|
|
|
|
|
AddShapePath(gp, rect);
|
|
|
|
|
}
|
2016-05-20 10:13:19 +12:00
|
|
|
|
|
2016-05-21 05:01:00 +12:00
|
|
|
|
public virtual void UpdateShapeConfig()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-21 09:09:09 +12:00
|
|
|
|
public virtual void ApplyShapeConfig()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-20 10:13:19 +12:00
|
|
|
|
public virtual void OnShapeCreated()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void OnShapeDoubleClicked()
|
|
|
|
|
{
|
|
|
|
|
}
|
2015-07-17 03:21:02 +12:00
|
|
|
|
}
|
|
|
|
|
}
|