Node.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. namespace DrawGraph
  2. {
  3. public class Node
  4. {
  5. public int X { get; set; }
  6. public int Y { get; set; }
  7. public Node(int x, int y)
  8. {
  9. X = x;
  10. Y = y;
  11. }
  12. public int CenterByX => (X * 2 + (Settings.NodeWidth/2)) / 2;
  13. public int CenterByY => (Y * 2 + (Settings.NodeHeight / 2)) / 2;
  14. public static bool Compare(Node v1, Node v2)
  15. {
  16. if (Equals(v1, v2))
  17. return true;
  18. if (v1 == v2)
  19. return true;
  20. if (v1.X == v2.X && v1.Y == v2.Y)
  21. return true;
  22. return false;
  23. }
  24. public static bool IsNodeOverlaid(Node v1, Node v2)
  25. {
  26. var x = v1.X - v2.X;
  27. var y = v1.Y - v2.Y;
  28. if(x<=Settings.NodeWidth/2 && x>=0)
  29. if (y <= Settings.NodeHeight / 2 && y > 0)
  30. return true;
  31. x = v2.X - v1.X;
  32. y = v2.Y - v1.Y;
  33. if (x <= Settings.NodeWidth / 2 && x >= 0)
  34. if (y <= Settings.NodeHeight / 2 && y > 0)
  35. return true;
  36. return false;
  37. }
  38. }
  39. }