AddShapePath function moved inside BaseRegionShape

This commit is contained in:
Jaex 2016-05-03 10:57:49 +03:00
parent 0709035daf
commit 109d876c41
8 changed files with 24 additions and 23 deletions

View file

@ -263,7 +263,7 @@ protected override void Draw(Graphics g)
{
using (GraphicsPath hoverDrawPath = new GraphicsPath { FillMode = FillMode.Winding })
{
AddShapePath(hoverDrawPath, AreaManager.GetRegionInfo(AreaManager.CurrentHoverArea), -1);
AreaManager.GetRegionInfo(AreaManager.CurrentHoverArea).AddShapePath(hoverDrawPath, -1);
g.DrawPath(borderPen, hoverDrawPath);
g.DrawPath(borderDotPen, hoverDrawPath);
@ -703,20 +703,14 @@ public void UpdateRegionPath()
regionFillPath = new GraphicsPath { FillMode = FillMode.Winding };
regionDrawPath = new GraphicsPath { FillMode = FillMode.Winding };
foreach (BaseRegionShape regionInfo in AreaManager.ValidRegionAreas)
foreach (BaseRegionShape regionShape in AreaManager.ValidRegionAreas)
{
AddShapePath(regionFillPath, regionInfo);
AddShapePath(regionDrawPath, regionInfo, -1);
regionShape.AddShapePath(regionFillPath);
regionShape.AddShapePath(regionFillPath, -1);
}
}
}
protected virtual void AddShapePath(GraphicsPath gp, BaseRegionShape shape, int sizeOffset = 0)
{
Rectangle rect = shape.Rectangle.SizeOffset(sizeOffset);
shape.AddShape(gp, rect);
}
protected override void Dispose(bool disposing)
{
if (bmpSurfaceImage != null)

View file

@ -34,13 +34,13 @@ namespace ShareX.ScreenCaptureLib
{
public class AreaManager
{
public List<BaseShape> Shapesa { get; private set; }
public List<BaseShape> Shapes { get; private set; }
public BaseRegionShape[] Regions
{
get
{
return Shapesa.OfType<BaseRegionShape>().ToArray();
return Shapes.OfType<BaseRegionShape>().ToArray();
}
}
@ -139,7 +139,7 @@ public AreaManager(RectangleRegion surface)
this.surface = surface;
ResizeManager = new ResizeManager(surface, this);
Shapesa = new List<BaseShape>();
Shapes = new List<BaseShape>();
SelectedAreaIndex = -1;
RoundedRectangleRadius = 25;
RoundedRectangleRadiusIncrement = 3;
@ -494,7 +494,7 @@ private void ChangeCurrentShape(BaseShape shape)
private void AddRegionInfo(Rectangle rect)
{
Shapesa.Add(GetRegionInfo(rect));
Shapes.Add(GetRegionInfo(rect));
SelectedAreaIndex = Regions.Length - 1;
}
@ -542,7 +542,7 @@ private void RemoveCurrentArea()
if (shape != null)
{
Shapesa.Remove(shape);
Shapes.Remove(shape);
DeselectArea();
}
}

View file

@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Drawing;
@ -34,11 +35,17 @@ namespace ShareX.ScreenCaptureLib
{
public abstract class BaseRegionShape : BaseShape
{
public abstract void AddShape(GraphicsPath gp, Rectangle rect);
public abstract void AddShapePath(GraphicsPath gp, Rectangle rect);
public void AddShape(GraphicsPath gp)
public void AddShapePath(GraphicsPath gp)
{
AddShape(gp, Rectangle);
AddShapePath(gp, Rectangle);
}
public void AddShapePath(GraphicsPath gp, int sizeOffset)
{
Rectangle rect = Rectangle.SizeOffset(sizeOffset);
AddShapePath(gp, rect);
}
}
}

View file

@ -35,7 +35,7 @@ namespace ShareX.ScreenCaptureLib
{
public class DiamondRegionShape : BaseRegionShape
{
public override void AddShape(GraphicsPath gp, Rectangle rect)
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
{
gp.AddDiamond(rect);
}

View file

@ -34,7 +34,7 @@ namespace ShareX.ScreenCaptureLib
{
public class EllipseRegionShape : BaseRegionShape
{
public override void AddShape(GraphicsPath gp, Rectangle rect)
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
{
gp.AddEllipse(rect);
}

View file

@ -34,7 +34,7 @@ namespace ShareX.ScreenCaptureLib
{
public class RectangleRegionShape : BaseRegionShape
{
public override void AddShape(GraphicsPath gp, Rectangle rect)
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
{
gp.AddRectangle(rect);
}

View file

@ -37,7 +37,7 @@ public class RoundedRectangleRegionShape : BaseRegionShape
{
public float Radius { get; set; }
public override void AddShape(GraphicsPath gp, Rectangle rect)
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
{
gp.AddRoundedRectangle(rect, Radius);
}

View file

@ -37,7 +37,7 @@ public class TriangleRegionShape : BaseRegionShape
{
public TriangleAngle Angle { get; set; }
public override void AddShape(GraphicsPath gp, Rectangle rect)
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
{
gp.AddTriangle(rect, Angle);
}