123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- namespace DrawGraph
- {
- public class Node
- {
- public int X { get; set; }
- public int Y { get; set; }
- public Node(int x, int y)
- {
- X = x;
- Y = y;
- }
- public int CenterByX => (X * 2 + (Settings.NodeWidth/2)) / 2;
- public int CenterByY => (Y * 2 + (Settings.NodeHeight / 2)) / 2;
- public static bool Compare(Node v1, Node v2)
- {
- if (Equals(v1, v2))
- return true;
- if (v1 == v2)
- return true;
- if (v1.X == v2.X && v1.Y == v2.Y)
- return true;
- return false;
- }
- public static bool IsNodeOverlaid(Node v1, Node v2)
- {
- var x = v1.X - v2.X;
- var y = v1.Y - v2.Y;
- if(x<=Settings.NodeWidth/2 && x>=0)
- if (y <= Settings.NodeHeight / 2 && y > 0)
- return true;
- x = v2.X - v1.X;
- y = v2.Y - v1.Y;
- if (x <= Settings.NodeWidth / 2 && x >= 0)
- if (y <= Settings.NodeHeight / 2 && y > 0)
- return true;
- return false;
- }
- }
- }
|