mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
#2955: Support old resize node style
This commit is contained in:
parent
ccf5a4b1e5
commit
dcbe2ab4fe
6 changed files with 73 additions and 4 deletions
|
@ -64,6 +64,7 @@ public class RegionCaptureOptions
|
|||
public int MagnifierPixelCount = 15; // Must be odd number like 11, 13, 15 etc.
|
||||
public int MagnifierPixelSize = 10;
|
||||
public bool ShowCrosshair = false;
|
||||
public bool UseSimpleNodeDesign = true;
|
||||
public bool EnableAnimations = true;
|
||||
public bool IsFixedSize = false;
|
||||
public Size FixedSize = new Size(250, 250);
|
||||
|
|
|
@ -24,6 +24,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.Drawing;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
|
@ -50,7 +51,33 @@ public Point Position
|
|||
|
||||
public int Size { get; set; }
|
||||
|
||||
public NodeShape Shape { get; set; }
|
||||
public bool AutoSetSize { get; set; } = true;
|
||||
|
||||
private NodeShape shape;
|
||||
|
||||
public NodeShape Shape
|
||||
{
|
||||
get
|
||||
{
|
||||
return shape;
|
||||
}
|
||||
set
|
||||
{
|
||||
shape = value;
|
||||
|
||||
if (AutoSetSize)
|
||||
{
|
||||
if (shape == NodeShape.CustomNode && CustomNodeImage != null)
|
||||
{
|
||||
Size = Math.Max(CustomNodeImage.Width, CustomNodeImage.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
Size = DefaultSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Image CustomNodeImage { get; private set; }
|
||||
|
||||
|
@ -58,14 +85,12 @@ public ResizeNode(int x = 0, int y = 0)
|
|||
{
|
||||
Shape = NodeShape.Square;
|
||||
Position = new Point(x, y);
|
||||
Size = DefaultSize;
|
||||
}
|
||||
|
||||
public void SetCustomNode(Image customNodeImage)
|
||||
{
|
||||
Shape = NodeShape.CustomNode;
|
||||
CustomNodeImage = customNodeImage;
|
||||
Size = CustomNodeImage.Width;
|
||||
Shape = NodeShape.CustomNode;
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics g)
|
||||
|
@ -78,6 +103,7 @@ public override void OnDraw(Graphics g)
|
|||
g.DrawRectangle(Pens.White, rect.Offset(-1));
|
||||
g.DrawRectangle(Pens.Black, rect);
|
||||
break;
|
||||
default:
|
||||
case NodeShape.Circle:
|
||||
g.DrawEllipse(Pens.White, rect.Offset(-1));
|
||||
g.DrawEllipse(Pens.Black, rect);
|
||||
|
|
|
@ -109,8 +109,34 @@ public virtual bool Intersects(Point position)
|
|||
return Rectangle.Contains(position);
|
||||
}
|
||||
|
||||
internal void ChangeNodeShape(NodeShape nodeShape)
|
||||
{
|
||||
foreach (ResizeNode node in Manager.ResizeNodes)
|
||||
{
|
||||
node.Shape = nodeShape;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UseSimpleNodeShape()
|
||||
{
|
||||
ChangeNodeShape(NodeShape.Square);
|
||||
}
|
||||
|
||||
protected void UpdateNodeShape()
|
||||
{
|
||||
if (Options.UseSimpleNodeDesign)
|
||||
{
|
||||
UseSimpleNodeShape();
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeNodeShape(NodeShape.CustomNode);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ShowNodes()
|
||||
{
|
||||
UpdateNodeShape();
|
||||
Manager.NodesVisible = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,11 @@ public class LineDrawingShape : BaseDrawingShape
|
|||
|
||||
public override bool IsValidShape => Rectangle.Width > 1 || Rectangle.Height > 1;
|
||||
|
||||
protected override void UseSimpleNodeShape()
|
||||
{
|
||||
ChangeNodeShape(NodeShape.Circle);
|
||||
}
|
||||
|
||||
private void AdjustPoints(int centerPointCount)
|
||||
{
|
||||
Point[] newPoints = new Point[2 + centerPointCount];
|
||||
|
|
|
@ -63,6 +63,12 @@ public override void OnCreated()
|
|||
TailPosition = Rectangle.Location.Add(0, Rectangle.Height + 30);
|
||||
}
|
||||
|
||||
protected override void UseSimpleNodeShape()
|
||||
{
|
||||
ChangeNodeShape(NodeShape.Square);
|
||||
Manager.ResizeNodes[(int)NodePosition.Extra].Shape = NodeShape.Circle;
|
||||
}
|
||||
|
||||
public override void OnNodeVisible()
|
||||
{
|
||||
base.OnNodeVisible();
|
||||
|
|
|
@ -57,6 +57,11 @@ public Point LastPosition
|
|||
private List<Point> points = new List<Point>();
|
||||
private bool isPolygonMode;
|
||||
|
||||
protected override void UseSimpleNodeShape()
|
||||
{
|
||||
ChangeNodeShape(NodeShape.Circle);
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
if (Manager.IsCreating)
|
||||
|
|
Loading…
Reference in a new issue