Make a func on the net shape to find the corner opposite from where we clicked

This commit is contained in:
Tim Young 2018-02-28 09:16:01 -06:00
parent 8187cc7a34
commit 46bf7acee0
1 changed files with 30 additions and 0 deletions

View File

@ -83,6 +83,36 @@ namespace EduNetworkBuilder
return tCorners;
}
public bool CornersAreClickedOn(Point ClickPoint)
{
foreach(Rectangle rec in Corners())
{
if (rec.Contains(ClickPoint))
return true;
}
return false;
}
/// <summary>
/// return the opposite point from the one clicked on. This is so we can start
/// dragging from here.
/// </summary>
/// <param name="ClickPoint"></param>
/// <returns></returns>
public Point OppositePoint(Point ClickPoint)
{
int fX = ClickPoint.X;
int fY = ClickPoint.Y;
int halfWidth = InArea.Width / 2;
int halfHeight = InArea.Height / 2;
if (ClickPoint.X < InArea.X + halfWidth) fX = InArea.X;
else fX = InArea.X + InArea.Width;
if (ClickPoint.Y < InArea.Y + halfHeight) fY = InArea.Y;
else fY = InArea.Y + InArea.Height;
return new Point(fX, fY);
}
public void Load(XmlNode theNode)
{
foreach (XmlNode Individual in theNode.ChildNodes)