mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Use int instead of float for nodes
This commit is contained in:
parent
13bde6b875
commit
add923d914
6 changed files with 32 additions and 41 deletions
|
@ -309,9 +309,9 @@ public void Close(RegionResult result)
|
||||||
|
|
||||||
if (obj.Visible)
|
if (obj.Visible)
|
||||||
{
|
{
|
||||||
obj.IsMouseHover = obj.Rectangle.Contains(InputManager.MousePosition0Based);
|
obj.IsCursorHover = obj.Rectangle.Contains(InputManager.MousePosition0Based);
|
||||||
|
|
||||||
if (obj.IsMouseHover)
|
if (obj.IsCursorHover)
|
||||||
{
|
{
|
||||||
if (InputManager.IsMousePressed(MouseButtons.Left))
|
if (InputManager.IsMousePressed(MouseButtons.Left))
|
||||||
{
|
{
|
||||||
|
@ -320,7 +320,7 @@ public void Close(RegionResult result)
|
||||||
|
|
||||||
for (int y = i + 1; y < objects.Count(); y++)
|
for (int y = i + 1; y < objects.Count(); y++)
|
||||||
{
|
{
|
||||||
objects[y].IsMouseHover = false;
|
objects[y].IsCursorHover = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -50,7 +50,7 @@ private void PolygonRegionForm_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButtons.Left)
|
if (e.Button == MouseButtons.Left)
|
||||||
{
|
{
|
||||||
if (drawableObjects.Cast<NodeObject>().Any(node => node.IsMouseHover || node.IsDragging))
|
if (drawableObjects.Cast<NodeObject>().Any(node => node.IsCursorHover || node.IsDragging))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ private void PolygonRegionForm_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (NodeObject node in nodes)
|
foreach (NodeObject node in nodes)
|
||||||
{
|
{
|
||||||
if (node.IsMouseHover)
|
if (node.IsCursorHover)
|
||||||
{
|
{
|
||||||
nodes.Remove(node);
|
nodes.Remove(node);
|
||||||
drawableObjects.Remove(node);
|
drawableObjects.Remove(node);
|
||||||
|
|
|
@ -30,24 +30,14 @@ namespace ShareX.ScreenCaptureLib
|
||||||
public class DrawableObject
|
public class DrawableObject
|
||||||
{
|
{
|
||||||
public bool Visible { get; set; }
|
public bool Visible { get; set; }
|
||||||
public RectangleF Rectangle { get; set; }
|
public Rectangle Rectangle { get; set; }
|
||||||
public bool IsMouseHover { get; set; }
|
public bool IsCursorHover { get; set; }
|
||||||
public bool IsDragging { get; set; }
|
public bool IsDragging { get; set; }
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
|
|
||||||
public void Show()
|
|
||||||
{
|
|
||||||
Visible = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Hide()
|
|
||||||
{
|
|
||||||
Visible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void Draw(Graphics g)
|
public virtual void Draw(Graphics g)
|
||||||
{
|
{
|
||||||
if (IsMouseHover)
|
if (IsCursorHover)
|
||||||
{
|
{
|
||||||
g.FillRectangle(Brushes.Green, Rectangle);
|
g.FillRectangle(Brushes.Green, Rectangle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,9 @@ namespace ShareX.ScreenCaptureLib
|
||||||
{
|
{
|
||||||
internal class NodeObject : DrawableObject
|
internal class NodeObject : DrawableObject
|
||||||
{
|
{
|
||||||
private PointF position;
|
private Point position;
|
||||||
|
|
||||||
public PointF Position
|
public Point Position
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -41,24 +41,25 @@ public PointF Position
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
position = value;
|
position = value;
|
||||||
Rectangle = new RectangleF(position.X - (NodeSize - 1) / 2, position.Y - (NodeSize - 1) / 2, NodeSize, NodeSize);
|
|
||||||
|
Rectangle = new Rectangle(position.X - (NodeSize - 1) / 2, position.Y - (NodeSize - 1) / 2, NodeSize, NodeSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float NodeSize { get; set; }
|
public int NodeSize { get; set; }
|
||||||
|
|
||||||
public NodeShape Shape { get; set; }
|
public NodeShape Shape { get; set; }
|
||||||
|
|
||||||
public NodeObject(float x = 0, float y = 0)
|
public NodeObject(int x = 0, int y = 0)
|
||||||
{
|
{
|
||||||
NodeSize = 13;
|
NodeSize = 13;
|
||||||
Shape = NodeShape.Square;
|
Shape = NodeShape.Square;
|
||||||
Position = new PointF(x, y);
|
Position = new Point(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(Graphics g)
|
public override void Draw(Graphics g)
|
||||||
{
|
{
|
||||||
Rectangle rect = new Rectangle((int)Rectangle.X, (int)Rectangle.Y, (int)Rectangle.Width - 1, (int)Rectangle.Height - 1);
|
Rectangle rect = new Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Width - 1, Rectangle.Height - 1);
|
||||||
|
|
||||||
switch (Shape)
|
switch (Shape)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class AnnotationOptions
|
||||||
|
|
||||||
// Step drawing
|
// Step drawing
|
||||||
public Color StepBorderColor { get; set; } = Color.White;
|
public Color StepBorderColor { get; set; } = Color.White;
|
||||||
public int StepBorderSize { get; set; } = 2;
|
public int StepBorderSize { get; set; } = 0;
|
||||||
public Color StepFillColor { get; set; } = Color.Red;
|
public Color StepFillColor { get; set; } = Color.Red;
|
||||||
|
|
||||||
// Blur effect
|
// Blur effect
|
||||||
|
|
|
@ -262,7 +262,7 @@ private void form_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
|
||||||
public bool IsCursorOnNode()
|
public bool IsCursorOnNode()
|
||||||
{
|
{
|
||||||
return Visible && nodes.Any(node => node.IsMouseHover);
|
return Visible && nodes.Any(node => node.IsCursorHover);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Show()
|
public void Show()
|
||||||
|
@ -287,22 +287,22 @@ private void UpdateNodePositions()
|
||||||
{
|
{
|
||||||
Rectangle rect = shape.Rectangle;
|
Rectangle rect = shape.Rectangle;
|
||||||
|
|
||||||
float xStart = rect.X;
|
int xStart = rect.X;
|
||||||
float xMid = rect.X + rect.Width / 2;
|
int xMid = rect.X + rect.Width / 2;
|
||||||
float xEnd = rect.X + rect.Width - 1;
|
int xEnd = rect.X + rect.Width - 1;
|
||||||
|
|
||||||
float yStart = rect.Y;
|
int yStart = rect.Y;
|
||||||
float yMid = rect.Y + rect.Height / 2;
|
int yMid = rect.Y + rect.Height / 2;
|
||||||
float yEnd = rect.Y + rect.Height - 1;
|
int yEnd = rect.Y + rect.Height - 1;
|
||||||
|
|
||||||
nodes[(int)NodePosition.TopLeft].Position = new PointF(xStart, yStart);
|
nodes[(int)NodePosition.TopLeft].Position = new Point(xStart, yStart);
|
||||||
nodes[(int)NodePosition.Top].Position = new PointF(xMid, yStart);
|
nodes[(int)NodePosition.Top].Position = new Point(xMid, yStart);
|
||||||
nodes[(int)NodePosition.TopRight].Position = new PointF(xEnd, yStart);
|
nodes[(int)NodePosition.TopRight].Position = new Point(xEnd, yStart);
|
||||||
nodes[(int)NodePosition.Right].Position = new PointF(xEnd, yMid);
|
nodes[(int)NodePosition.Right].Position = new Point(xEnd, yMid);
|
||||||
nodes[(int)NodePosition.BottomRight].Position = new PointF(xEnd, yEnd);
|
nodes[(int)NodePosition.BottomRight].Position = new Point(xEnd, yEnd);
|
||||||
nodes[(int)NodePosition.Bottom].Position = new PointF(xMid, yEnd);
|
nodes[(int)NodePosition.Bottom].Position = new Point(xMid, yEnd);
|
||||||
nodes[(int)NodePosition.BottomLeft].Position = new PointF(xStart, yEnd);
|
nodes[(int)NodePosition.BottomLeft].Position = new Point(xStart, yEnd);
|
||||||
nodes[(int)NodePosition.Left].Position = new PointF(xStart, yMid);
|
nodes[(int)NodePosition.Left].Position = new Point(xStart, yMid);
|
||||||
}
|
}
|
||||||
else if (shape.NodeType == NodeType.Line)
|
else if (shape.NodeType == NodeType.Line)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue