public SnapBase FindSnapPoint(Point hit) { List <SnapBase> candidates = new List <SnapBase>(); foreach (Layer la in LayerCollection.FindAll(la => la.visible)) { SnapBase obj = la.GetHitObject(hit) as SnapBase; if (obj != null) { candidates.Add(obj); } if (candidates.Count > 0) { return(candidates.OrderBy(p => p.Distance2(hit)).First()); } } return(null); }