From 46bf7acee0a02660add3a63cf774161a9096edd0 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 28 Feb 2018 09:16:01 -0600 Subject: [PATCH] Make a func on the net shape to find the corner opposite from where we clicked --- EduNetworkBuilder/NetShape.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/EduNetworkBuilder/NetShape.cs b/EduNetworkBuilder/NetShape.cs index 111189c..8b853ce 100644 --- a/EduNetworkBuilder/NetShape.cs +++ b/EduNetworkBuilder/NetShape.cs @@ -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; + } + + /// + /// return the opposite point from the one clicked on. This is so we can start + /// dragging from here. + /// + /// + /// + 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)