private static bool GetPoint(string value, out IdentifiablePoint result) { var regex = new Regex(@"\d+"); try { var matches = regex.Matches(value); result = new IdentifiablePoint(new Point(int.Parse(matches[0].Value), int.Parse(matches[1].Value))); return(true); } catch { result = null; return(false); } }
private static IdentifiablePoint GetClosestPoint(int x, int y, List <IdentifiablePoint> points) { int minDistance = int.MaxValue; IdentifiablePoint closestPoint = null; foreach (var point in points) { var distance = GetDistance(x, y, point.X, point.Y); if (distance < minDistance) { minDistance = distance; closestPoint = point; } } return(closestPoint); }