mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-06 05:05:42 +13:00
Each region have its own angle and radius info and changeable in selected region
This commit is contained in:
parent
bddbb2b136
commit
5b9cf79f48
10 changed files with 126 additions and 342 deletions
|
@ -1,39 +0,0 @@
|
||||||
#region License Information (GPL v3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
|
||||||
Copyright © 2007-2015 ShareX Developers
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
|
|
||||||
namespace ShareX.ScreenCaptureLib
|
|
||||||
{
|
|
||||||
public class DiamondRegion : RectangleRegion
|
|
||||||
{
|
|
||||||
protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect, RegionShape shape)
|
|
||||||
{
|
|
||||||
graphicsPath.AddDiamond(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
#region License Information (GPL v3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
|
||||||
Copyright © 2007-2015 ShareX Developers
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
|
|
||||||
namespace ShareX.ScreenCaptureLib
|
|
||||||
{
|
|
||||||
public class EllipseRegion : RectangleRegion
|
|
||||||
{
|
|
||||||
protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect, RegionShape shape)
|
|
||||||
{
|
|
||||||
graphicsPath.AddEllipse(rect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -38,10 +38,6 @@ public class RectangleRegion : Surface
|
||||||
{
|
{
|
||||||
public AreaManager AreaManager { get; private set; }
|
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
|
#region Screen color picker
|
||||||
|
|
||||||
public bool ScreenColorPickerMode { get; set; }
|
public bool ScreenColorPickerMode { get; set; }
|
||||||
|
@ -77,10 +73,6 @@ public RectangleRegion()
|
||||||
{
|
{
|
||||||
AreaManager = new AreaManager(this);
|
AreaManager = new AreaManager(this);
|
||||||
|
|
||||||
RoundedRectangleRadius = 25;
|
|
||||||
RoundedRectangleRadiusIncrement = 3;
|
|
||||||
TriangleAngle = TriangleAngle.Top;
|
|
||||||
|
|
||||||
KeyDown += RectangleRegion_KeyDown;
|
KeyDown += RectangleRegion_KeyDown;
|
||||||
MouseDown += RectangleRegion_MouseDown;
|
MouseDown += RectangleRegion_MouseDown;
|
||||||
MouseWheel += RectangleRegion_MouseWheel;
|
MouseWheel += RectangleRegion_MouseWheel;
|
||||||
|
@ -114,57 +106,6 @@ private void RectangleRegion_KeyDown(object sender, KeyEventArgs e)
|
||||||
case Keys.Control | Keys.C:
|
case Keys.Control | Keys.C:
|
||||||
CopyAreaInfo();
|
CopyAreaInfo();
|
||||||
break;
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +229,7 @@ protected override void Draw(Graphics g)
|
||||||
{
|
{
|
||||||
using (GraphicsPath hoverDrawPath = new GraphicsPath { FillMode = FillMode.Winding })
|
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(borderPen, hoverDrawPath);
|
||||||
g.DrawPath(borderDotPen, hoverDrawPath);
|
g.DrawPath(borderDotPen, hoverDrawPath);
|
||||||
|
@ -679,30 +620,32 @@ public void UpdateRegionPath()
|
||||||
|
|
||||||
foreach (RegionInfo regionInfo in AreaManager.ValidAreas)
|
foreach (RegionInfo regionInfo in AreaManager.ValidAreas)
|
||||||
{
|
{
|
||||||
AddShapePath(regionFillPath, regionInfo.Area, regionInfo.Shape);
|
AddShapePath(regionFillPath, regionInfo);
|
||||||
AddShapePath(regionDrawPath, regionInfo.Area.SizeOffset(-1), regionInfo.Shape);
|
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:
|
default:
|
||||||
case RegionShape.Rectangle:
|
case RegionShape.Rectangle:
|
||||||
graphicsPath.AddRectangle(rect);
|
graphicsPath.AddRectangle(area);
|
||||||
break;
|
break;
|
||||||
case RegionShape.RoundedRectangle:
|
case RegionShape.RoundedRectangle:
|
||||||
graphicsPath.AddRoundedRectangle(rect, RoundedRectangleRadius);
|
graphicsPath.AddRoundedRectangle(area, regionInfo.RoundedRectangleRadius);
|
||||||
break;
|
break;
|
||||||
case RegionShape.Ellipse:
|
case RegionShape.Ellipse:
|
||||||
graphicsPath.AddEllipse(rect);
|
graphicsPath.AddEllipse(area);
|
||||||
break;
|
break;
|
||||||
case RegionShape.Triangle:
|
case RegionShape.Triangle:
|
||||||
graphicsPath.AddTriangle(rect, TriangleAngle);
|
graphicsPath.AddTriangle(area, regionInfo.TriangleAngle);
|
||||||
break;
|
break;
|
||||||
case RegionShape.Diamond:
|
case RegionShape.Diamond:
|
||||||
graphicsPath.AddDiamond(rect);
|
graphicsPath.AddDiamond(area);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
#region License Information (GPL v3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
|
||||||
Copyright © 2007-2015 ShareX Developers
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ShareX.ScreenCaptureLib
|
|
||||||
{
|
|
||||||
public class RoundedRectangleRegion : RectangleRegion
|
|
||||||
{
|
|
||||||
public float Radius { get; set; }
|
|
||||||
public int RadiusIncrement { get; set; }
|
|
||||||
|
|
||||||
public RoundedRectangleRegion()
|
|
||||||
{
|
|
||||||
Radius = 25;
|
|
||||||
RadiusIncrement = 3;
|
|
||||||
KeyDown += RoundedRectangleRegion_KeyDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RoundedRectangleRegion_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.KeyData == Keys.Add)
|
|
||||||
{
|
|
||||||
Radius += RadiusIncrement;
|
|
||||||
}
|
|
||||||
else if (e.KeyData == Keys.Subtract)
|
|
||||||
{
|
|
||||||
Radius = Math.Max(0, Radius - RadiusIncrement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect, RegionShape shape)
|
|
||||||
{
|
|
||||||
graphicsPath.AddRoundedRectangle(rect, Radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WriteTips(StringBuilder sb)
|
|
||||||
{
|
|
||||||
base.WriteTips(sb);
|
|
||||||
|
|
||||||
sb.AppendLine("[Numpad +] [Numpad -] Change corner radius");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
#region License Information (GPL v3)
|
|
||||||
|
|
||||||
/*
|
|
||||||
ShareX - A program that allows you to take screenshots and share any file type
|
|
||||||
Copyright © 2007-2015 ShareX Developers
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Drawing2D;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ShareX.ScreenCaptureLib
|
|
||||||
{
|
|
||||||
public class TriangleRegion : RectangleRegion
|
|
||||||
{
|
|
||||||
public TriangleAngle Angle { get; set; }
|
|
||||||
|
|
||||||
public TriangleRegion()
|
|
||||||
{
|
|
||||||
Angle = TriangleAngle.Top;
|
|
||||||
KeyDown += TriangleRegion_KeyDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TriangleRegion_KeyDown(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.KeyData == Keys.Add)
|
|
||||||
{
|
|
||||||
if (Angle == TriangleAngle.Left)
|
|
||||||
{
|
|
||||||
Angle = TriangleAngle.Top;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Angle++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (e.KeyData == Keys.Subtract)
|
|
||||||
{
|
|
||||||
if (Angle == TriangleAngle.Top)
|
|
||||||
{
|
|
||||||
Angle = TriangleAngle.Left;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Angle--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void AddShapePath(GraphicsPath graphicsPath, Rectangle rect, RegionShape shape)
|
|
||||||
{
|
|
||||||
graphicsPath.AddTriangle(rect, Angle);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WriteTips(StringBuilder sb)
|
|
||||||
{
|
|
||||||
base.WriteTips(sb);
|
|
||||||
|
|
||||||
sb.AppendLine("[Numpad +] [Numpad -] Change triangle angle");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using ShareX.HelpersLib;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -33,8 +34,6 @@ namespace ShareX.ScreenCaptureLib
|
||||||
{
|
{
|
||||||
public class AreaManager
|
public class AreaManager
|
||||||
{
|
{
|
||||||
public RegionShape CurrentShape { get; set; }
|
|
||||||
|
|
||||||
public List<RegionInfo> Areas { get; private set; }
|
public List<RegionInfo> Areas { get; private set; }
|
||||||
|
|
||||||
public RegionInfo[] ValidAreas
|
public RegionInfo[] ValidAreas
|
||||||
|
@ -47,6 +46,19 @@ public RegionInfo[] ValidAreas
|
||||||
|
|
||||||
public int SelectedAreaIndex { get; private set; }
|
public int SelectedAreaIndex { get; private set; }
|
||||||
|
|
||||||
|
public RegionInfo CurrentRegionInfo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (SelectedAreaIndex > -1)
|
||||||
|
{
|
||||||
|
return Areas[SelectedAreaIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Rectangle CurrentArea
|
public Rectangle CurrentArea
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -85,6 +97,11 @@ public bool IsCurrentHoverAreaValid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RegionShape CurrentShape { get; set; }
|
||||||
|
public float RoundedRectangleRadius { get; set; }
|
||||||
|
public int RoundedRectangleRadiusIncrement { get; set; }
|
||||||
|
public TriangleAngle TriangleAngle { get; set; }
|
||||||
|
|
||||||
public ResizeManager ResizeManager { get; private set; }
|
public ResizeManager ResizeManager { get; private set; }
|
||||||
public bool IsCreating { get; private set; }
|
public bool IsCreating { get; private set; }
|
||||||
public bool IsMoving { get; private set; }
|
public bool IsMoving { get; private set; }
|
||||||
|
@ -112,9 +129,12 @@ public AreaManager(RectangleRegion surface)
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
ResizeManager = new ResizeManager(surface, this);
|
ResizeManager = new ResizeManager(surface, this);
|
||||||
|
|
||||||
CurrentShape = RegionShape.Rectangle;
|
|
||||||
Areas = new List<RegionInfo>();
|
Areas = new List<RegionInfo>();
|
||||||
SelectedAreaIndex = -1;
|
SelectedAreaIndex = -1;
|
||||||
|
CurrentShape = RegionShape.Rectangle;
|
||||||
|
RoundedRectangleRadius = 25;
|
||||||
|
RoundedRectangleRadiusIncrement = 3;
|
||||||
|
TriangleAngle = TriangleAngle.Top;
|
||||||
MinimumSize = 10;
|
MinimumSize = 10;
|
||||||
|
|
||||||
surface.MouseDown += surface_MouseDown;
|
surface.MouseDown += surface_MouseDown;
|
||||||
|
@ -125,9 +145,64 @@ public AreaManager(RectangleRegion surface)
|
||||||
|
|
||||||
private void surface_KeyDown(object sender, KeyEventArgs e)
|
private void surface_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyCode == Keys.ShiftKey)
|
switch (e.KeyData)
|
||||||
{
|
{
|
||||||
proportionalResizing = true;
|
case Keys.ShiftKey:
|
||||||
|
proportionalResizing = true;
|
||||||
|
break;
|
||||||
|
case Keys.NumPad1:
|
||||||
|
ChangeCurrentShape(RegionShape.Rectangle);
|
||||||
|
break;
|
||||||
|
case Keys.NumPad2:
|
||||||
|
ChangeCurrentShape(RegionShape.RoundedRectangle);
|
||||||
|
break;
|
||||||
|
case Keys.NumPad3:
|
||||||
|
ChangeCurrentShape(RegionShape.Ellipse);
|
||||||
|
break;
|
||||||
|
case Keys.NumPad4:
|
||||||
|
ChangeCurrentShape(RegionShape.Triangle);
|
||||||
|
break;
|
||||||
|
case Keys.NumPad5:
|
||||||
|
ChangeCurrentShape(RegionShape.Diamond);
|
||||||
|
break;
|
||||||
|
case Keys.Add:
|
||||||
|
switch (CurrentShape)
|
||||||
|
{
|
||||||
|
case RegionShape.RoundedRectangle:
|
||||||
|
RoundedRectangleRadius += RoundedRectangleRadiusIncrement;
|
||||||
|
break;
|
||||||
|
case RegionShape.Triangle:
|
||||||
|
if (TriangleAngle == TriangleAngle.Left)
|
||||||
|
{
|
||||||
|
TriangleAngle = TriangleAngle.Top;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TriangleAngle++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UpdateCurrentRegionInfo();
|
||||||
|
break;
|
||||||
|
case Keys.Subtract:
|
||||||
|
switch (CurrentShape)
|
||||||
|
{
|
||||||
|
case RegionShape.RoundedRectangle:
|
||||||
|
RoundedRectangleRadius = Math.Max(0, RoundedRectangleRadius - RoundedRectangleRadiusIncrement);
|
||||||
|
break;
|
||||||
|
case RegionShape.Triangle:
|
||||||
|
if (TriangleAngle == TriangleAngle.Top)
|
||||||
|
{
|
||||||
|
TriangleAngle = TriangleAngle.Left;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TriangleAngle--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UpdateCurrentRegionInfo();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,8 +304,7 @@ private void surface_MouseDown(object sender, MouseEventArgs e)
|
||||||
rect = new Rectangle(e.Location, new Size(1, 1));
|
rect = new Rectangle(e.Location, new Size(1, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
Areas.Add(new RegionInfo(rect, CurrentShape));
|
AddRegionInfo(rect);
|
||||||
SelectedAreaIndex = Areas.Count - 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,8 +336,7 @@ private void surface_MouseUp(object sender, MouseEventArgs e)
|
||||||
|
|
||||||
if (!CurrentHoverArea.IsEmpty)
|
if (!CurrentHoverArea.IsEmpty)
|
||||||
{
|
{
|
||||||
Areas.Add(new RegionInfo(CurrentHoverArea, CurrentShape));
|
AddRegionInfo(CurrentHoverArea);
|
||||||
SelectedAreaIndex = Areas.Count - 1;
|
|
||||||
|
|
||||||
if (surface.Config.QuickCrop)
|
if (surface.Config.QuickCrop)
|
||||||
{
|
{
|
||||||
|
@ -292,6 +365,34 @@ private void surface_MouseUp(object sender, MouseEventArgs e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ChangeCurrentShape(RegionShape shape)
|
||||||
|
{
|
||||||
|
CurrentShape = shape;
|
||||||
|
UpdateCurrentRegionInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddRegionInfo(Rectangle rect)
|
||||||
|
{
|
||||||
|
Areas.Add(GetRegionInfo(rect));
|
||||||
|
SelectedAreaIndex = Areas.Count - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionInfo GetRegionInfo(Rectangle rect)
|
||||||
|
{
|
||||||
|
RegionInfo regionInfo = new RegionInfo(rect, CurrentShape);
|
||||||
|
regionInfo.RoundedRectangleRadius = RoundedRectangleRadius;
|
||||||
|
regionInfo.TriangleAngle = TriangleAngle;
|
||||||
|
return regionInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateCurrentRegionInfo()
|
||||||
|
{
|
||||||
|
RegionInfo regionInfo = CurrentRegionInfo;
|
||||||
|
regionInfo.Shape = CurrentShape;
|
||||||
|
regionInfo.RoundedRectangleRadius = RoundedRectangleRadius;
|
||||||
|
regionInfo.TriangleAngle = TriangleAngle;
|
||||||
|
}
|
||||||
|
|
||||||
private void SelectArea()
|
private void SelectArea()
|
||||||
{
|
{
|
||||||
if (!CurrentArea.IsEmpty && !surface.Config.IsFixedSize)
|
if (!CurrentArea.IsEmpty && !surface.Config.IsFixedSize)
|
||||||
|
|
|
@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using ShareX.HelpersLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
@ -35,6 +36,8 @@ public class RegionInfo
|
||||||
{
|
{
|
||||||
public Rectangle Area { get; set; }
|
public Rectangle Area { get; set; }
|
||||||
public RegionShape Shape { get; set; }
|
public RegionShape Shape { get; set; }
|
||||||
|
public float RoundedRectangleRadius { get; set; }
|
||||||
|
public TriangleAngle TriangleAngle { get; set; }
|
||||||
|
|
||||||
public RegionInfo(Rectangle area, RegionShape shape)
|
public RegionInfo(Rectangle area, RegionShape shape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,12 +83,6 @@
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="RegionHelpers\AreaManager.cs" />
|
<Compile Include="RegionHelpers\AreaManager.cs" />
|
||||||
<Compile Include="RegionHelpers\DrawObject.cs" />
|
<Compile Include="RegionHelpers\DrawObject.cs" />
|
||||||
<Compile Include="Forms\DiamondRegion.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms\EllipseRegion.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms\FreeHandRegion.cs">
|
<Compile Include="Forms\FreeHandRegion.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -98,12 +92,6 @@
|
||||||
<Compile Include="Forms\RectangleRegion.cs">
|
<Compile Include="Forms\RectangleRegion.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Forms\RoundedRectangleRegion.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms\TriangleRegion.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="RegionHelpers\InputManager.cs" />
|
<Compile Include="RegionHelpers\InputManager.cs" />
|
||||||
<Compile Include="RegionHelpers\MouseState.cs" />
|
<Compile Include="RegionHelpers\MouseState.cs" />
|
||||||
<Compile Include="RegionHelpers\NodeObject.cs" />
|
<Compile Include="RegionHelpers\NodeObject.cs" />
|
||||||
|
|
|
@ -120,10 +120,6 @@ public enum CaptureType
|
||||||
ActiveWindow,
|
ActiveWindow,
|
||||||
RectangleWindow,
|
RectangleWindow,
|
||||||
Rectangle,
|
Rectangle,
|
||||||
RoundedRectangle,
|
|
||||||
Ellipse,
|
|
||||||
Triangle,
|
|
||||||
Diamond,
|
|
||||||
Polygon,
|
Polygon,
|
||||||
Freehand,
|
Freehand,
|
||||||
CustomRegion,
|
CustomRegion,
|
||||||
|
|
|
@ -1660,10 +1660,6 @@ public void CaptureScreenshot(CaptureType captureType, TaskSettings taskSettings
|
||||||
break;
|
break;
|
||||||
case CaptureType.Rectangle:
|
case CaptureType.Rectangle:
|
||||||
case CaptureType.RectangleWindow:
|
case CaptureType.RectangleWindow:
|
||||||
case CaptureType.RoundedRectangle:
|
|
||||||
case CaptureType.Ellipse:
|
|
||||||
case CaptureType.Triangle:
|
|
||||||
case CaptureType.Diamond:
|
|
||||||
case CaptureType.Polygon:
|
case CaptureType.Polygon:
|
||||||
case CaptureType.Freehand:
|
case CaptureType.Freehand:
|
||||||
CaptureRegion(captureType, taskSettings, autoHideForm);
|
CaptureRegion(captureType, taskSettings, autoHideForm);
|
||||||
|
@ -1757,8 +1753,7 @@ private void AfterCapture(Image img, CaptureType captureType, TaskSettings taskS
|
||||||
|
|
||||||
private bool IsRegionCapture(CaptureType captureType)
|
private bool IsRegionCapture(CaptureType captureType)
|
||||||
{
|
{
|
||||||
return captureType.HasFlagAny(CaptureType.RectangleWindow, CaptureType.Rectangle, CaptureType.RoundedRectangle, CaptureType.Ellipse,
|
return captureType.HasFlagAny(CaptureType.RectangleWindow, CaptureType.Rectangle, CaptureType.Polygon, CaptureType.Freehand, CaptureType.LastRegion);
|
||||||
CaptureType.Triangle, CaptureType.Diamond, CaptureType.Polygon, CaptureType.Freehand, CaptureType.LastRegion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureActiveWindow(TaskSettings taskSettings, bool autoHideForm = true)
|
private void CaptureActiveWindow(TaskSettings taskSettings, bool autoHideForm = true)
|
||||||
|
@ -1848,18 +1843,6 @@ private void CaptureRegion(CaptureType captureType, TaskSettings taskSettings, b
|
||||||
rectangleRegion.AreaManager.IncludeControls = true;
|
rectangleRegion.AreaManager.IncludeControls = true;
|
||||||
surface = rectangleRegion;
|
surface = rectangleRegion;
|
||||||
break;
|
break;
|
||||||
case CaptureType.RoundedRectangle:
|
|
||||||
surface = new RoundedRectangleRegion();
|
|
||||||
break;
|
|
||||||
case CaptureType.Ellipse:
|
|
||||||
surface = new EllipseRegion();
|
|
||||||
break;
|
|
||||||
case CaptureType.Triangle:
|
|
||||||
surface = new TriangleRegion();
|
|
||||||
break;
|
|
||||||
case CaptureType.Diamond:
|
|
||||||
surface = new DiamondRegion();
|
|
||||||
break;
|
|
||||||
case CaptureType.Polygon:
|
case CaptureType.Polygon:
|
||||||
surface = new PolygonRegion();
|
surface = new PolygonRegion();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue