mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +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)
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -320,7 +320,7 @@ public void Close(RegionResult result)
|
|||
|
||||
for (int y = i + 1; y < objects.Count(); y++)
|
||||
{
|
||||
objects[y].IsMouseHover = false;
|
||||
objects[y].IsCursorHover = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -50,7 +50,7 @@ private void PolygonRegionForm_MouseDown(object sender, MouseEventArgs e)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ private void PolygonRegionForm_MouseDown(object sender, MouseEventArgs e)
|
|||
{
|
||||
foreach (NodeObject node in nodes)
|
||||
{
|
||||
if (node.IsMouseHover)
|
||||
if (node.IsCursorHover)
|
||||
{
|
||||
nodes.Remove(node);
|
||||
drawableObjects.Remove(node);
|
||||
|
|
|
@ -30,24 +30,14 @@ namespace ShareX.ScreenCaptureLib
|
|||
public class DrawableObject
|
||||
{
|
||||
public bool Visible { get; set; }
|
||||
public RectangleF Rectangle { get; set; }
|
||||
public bool IsMouseHover { get; set; }
|
||||
public Rectangle Rectangle { get; set; }
|
||||
public bool IsCursorHover { get; set; }
|
||||
public bool IsDragging { get; set; }
|
||||
public int Order { get; set; }
|
||||
|
||||
public void Show()
|
||||
{
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
public virtual void Draw(Graphics g)
|
||||
{
|
||||
if (IsMouseHover)
|
||||
if (IsCursorHover)
|
||||
{
|
||||
g.FillRectangle(Brushes.Green, Rectangle);
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ namespace ShareX.ScreenCaptureLib
|
|||
{
|
||||
internal class NodeObject : DrawableObject
|
||||
{
|
||||
private PointF position;
|
||||
private Point position;
|
||||
|
||||
public PointF Position
|
||||
public Point Position
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -41,24 +41,25 @@ public PointF Position
|
|||
set
|
||||
{
|
||||
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 NodeObject(float x = 0, float y = 0)
|
||||
public NodeObject(int x = 0, int y = 0)
|
||||
{
|
||||
NodeSize = 13;
|
||||
Shape = NodeShape.Square;
|
||||
Position = new PointF(x, y);
|
||||
Position = new Point(x, y);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AnnotationOptions
|
|||
|
||||
// Step drawing
|
||||
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;
|
||||
|
||||
// Blur effect
|
||||
|
|
|
@ -262,7 +262,7 @@ private void form_KeyUp(object sender, KeyEventArgs e)
|
|||
|
||||
public bool IsCursorOnNode()
|
||||
{
|
||||
return Visible && nodes.Any(node => node.IsMouseHover);
|
||||
return Visible && nodes.Any(node => node.IsCursorHover);
|
||||
}
|
||||
|
||||
public void Show()
|
||||
|
@ -287,22 +287,22 @@ private void UpdateNodePositions()
|
|||
{
|
||||
Rectangle rect = shape.Rectangle;
|
||||
|
||||
float xStart = rect.X;
|
||||
float xMid = rect.X + rect.Width / 2;
|
||||
float xEnd = rect.X + rect.Width - 1;
|
||||
int xStart = rect.X;
|
||||
int xMid = rect.X + rect.Width / 2;
|
||||
int xEnd = rect.X + rect.Width - 1;
|
||||
|
||||
float yStart = rect.Y;
|
||||
float yMid = rect.Y + rect.Height / 2;
|
||||
float yEnd = rect.Y + rect.Height - 1;
|
||||
int yStart = rect.Y;
|
||||
int yMid = rect.Y + rect.Height / 2;
|
||||
int yEnd = rect.Y + rect.Height - 1;
|
||||
|
||||
nodes[(int)NodePosition.TopLeft].Position = new PointF(xStart, yStart);
|
||||
nodes[(int)NodePosition.Top].Position = new PointF(xMid, yStart);
|
||||
nodes[(int)NodePosition.TopRight].Position = new PointF(xEnd, yStart);
|
||||
nodes[(int)NodePosition.Right].Position = new PointF(xEnd, yMid);
|
||||
nodes[(int)NodePosition.BottomRight].Position = new PointF(xEnd, yEnd);
|
||||
nodes[(int)NodePosition.Bottom].Position = new PointF(xMid, yEnd);
|
||||
nodes[(int)NodePosition.BottomLeft].Position = new PointF(xStart, yEnd);
|
||||
nodes[(int)NodePosition.Left].Position = new PointF(xStart, yMid);
|
||||
nodes[(int)NodePosition.TopLeft].Position = new Point(xStart, yStart);
|
||||
nodes[(int)NodePosition.Top].Position = new Point(xMid, yStart);
|
||||
nodes[(int)NodePosition.TopRight].Position = new Point(xEnd, yStart);
|
||||
nodes[(int)NodePosition.Right].Position = new Point(xEnd, yMid);
|
||||
nodes[(int)NodePosition.BottomRight].Position = new Point(xEnd, yEnd);
|
||||
nodes[(int)NodePosition.Bottom].Position = new Point(xMid, yEnd);
|
||||
nodes[(int)NodePosition.BottomLeft].Position = new Point(xStart, yEnd);
|
||||
nodes[(int)NodePosition.Left].Position = new Point(xStart, yMid);
|
||||
}
|
||||
else if (shape.NodeType == NodeType.Line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue