Skip to content

Commit

Permalink
Each region have its own angle and radius info and changeable in sele…
Browse files Browse the repository at this point in the history
…cted region
  • Loading branch information
Jaex committed Jul 16, 2015
1 parent bddbb2b commit 5b9cf79
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 342 deletions.
39 changes: 0 additions & 39 deletions ShareX.ScreenCaptureLib/Forms/DiamondRegion.cs

This file was deleted.

38 changes: 0 additions & 38 deletions ShareX.ScreenCaptureLib/Forms/EllipseRegion.cs

This file was deleted.

81 changes: 12 additions & 69 deletions ShareX.ScreenCaptureLib/Forms/RectangleRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public class RectangleRegion : Surface
{
public AreaManager AreaManager { get; private set; }

public float RoundedRectangleRadius { get; set; }
public int RoundedRectangleRadiusIncrement { get; set; }
public TriangleAngle TriangleAngle { get; set; }

#region Screen color picker

public bool ScreenColorPickerMode { get; set; }
Expand Down Expand Up @@ -77,10 +73,6 @@ public RectangleRegion()
{
AreaManager = new AreaManager(this);

RoundedRectangleRadius = 25;
RoundedRectangleRadiusIncrement = 3;
TriangleAngle = TriangleAngle.Top;

KeyDown += RectangleRegion_KeyDown;
MouseDown += RectangleRegion_MouseDown;
MouseWheel += RectangleRegion_MouseWheel;
Expand Down Expand Up @@ -114,57 +106,6 @@ private void RectangleRegion_KeyDown(object sender, KeyEventArgs e)
case Keys.Control | Keys.C:
CopyAreaInfo();
break;
case Keys.NumPad1:
AreaManager.CurrentShape = RegionShape.Rectangle;
break;
case Keys.NumPad2:
AreaManager.CurrentShape = RegionShape.RoundedRectangle;
break;
case Keys.NumPad3:
AreaManager.CurrentShape = RegionShape.Ellipse;
break;
case Keys.NumPad4:
AreaManager.CurrentShape = RegionShape.Triangle;
break;
case Keys.NumPad5:
AreaManager.CurrentShape = RegionShape.Diamond;
break;
case Keys.Add:
switch (AreaManager.CurrentShape)
{
case RegionShape.RoundedRectangle:
RoundedRectangleRadius += RoundedRectangleRadiusIncrement;
break;
case RegionShape.Triangle:
if (TriangleAngle == TriangleAngle.Left)
{
TriangleAngle = TriangleAngle.Top;
}
else
{
TriangleAngle++;
}
break;
}
break;
case Keys.Subtract:
switch (AreaManager.CurrentShape)
{
case RegionShape.RoundedRectangle:
RoundedRectangleRadius = Math.Max(0, RoundedRectangleRadius - RoundedRectangleRadiusIncrement);
break;
case RegionShape.Triangle:
if (TriangleAngle == TriangleAngle.Top)
{
TriangleAngle = TriangleAngle.Left;
}
else
{
TriangleAngle--;
}
break;
}
break;
}
}

Expand Down Expand Up @@ -288,7 +229,7 @@ protected override void Draw(Graphics g)
{
using (GraphicsPath hoverDrawPath = new GraphicsPath { FillMode = FillMode.Winding })
{
AddShapePath(hoverDrawPath, AreaManager.CurrentHoverArea.SizeOffset(-1), AreaManager.CurrentShape);
AddShapePath(hoverDrawPath, AreaManager.GetRegionInfo(AreaManager.CurrentHoverArea), -1);

g.DrawPath(borderPen, hoverDrawPath);
g.DrawPath(borderDotPen, hoverDrawPath);
Expand Down Expand Up @@ -679,30 +620,32 @@ public void UpdateRegionPath()

foreach (RegionInfo regionInfo in AreaManager.ValidAreas)
{
AddShapePath(regionFillPath, regionInfo.Area, regionInfo.Shape);
AddShapePath(regionDrawPath, regionInfo.Area.SizeOffset(-1), regionInfo.Shape);
AddShapePath(regionFillPath, regionInfo);
AddShapePath(regionDrawPath, regionInfo, -1);
}
}

protected virtual void AddShapePath(GraphicsPath graphicsPath, Rectangle rect, RegionShape shape)
protected virtual void AddShapePath(GraphicsPath graphicsPath, RegionInfo regionInfo, int sizeOffset = 0)
{
switch (shape)
Rectangle area = regionInfo.Area.SizeOffset(sizeOffset);

switch (regionInfo.Shape)
{
default:
case RegionShape.Rectangle:
graphicsPath.AddRectangle(rect);
graphicsPath.AddRectangle(area);
break;
case RegionShape.RoundedRectangle:
graphicsPath.AddRoundedRectangle(rect, RoundedRectangleRadius);
graphicsPath.AddRoundedRectangle(area, regionInfo.RoundedRectangleRadius);
break;
case RegionShape.Ellipse:
graphicsPath.AddEllipse(rect);
graphicsPath.AddEllipse(area);
break;
case RegionShape.Triangle:
graphicsPath.AddTriangle(rect, TriangleAngle);
graphicsPath.AddTriangle(area, regionInfo.TriangleAngle);
break;
case RegionShape.Diamond:
graphicsPath.AddDiamond(rect);
graphicsPath.AddDiamond(area);
break;
}
}
Expand Down
71 changes: 0 additions & 71 deletions ShareX.ScreenCaptureLib/Forms/RoundedRectangleRegion.cs

This file was deleted.

82 changes: 0 additions & 82 deletions ShareX.ScreenCaptureLib/Forms/TriangleRegion.cs

This file was deleted.

Loading

0 comments on commit 5b9cf79

Please sign in to comment.