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); }
private bool isDraggingObject(MouseEventArgs e) { if (e.Button == MouseButtons.Left && __selectedObject != null) { LineEdgePoint line = __selectedObject as LineEdgePoint; SnapBase p = __selectedObject as SnapBase; if (__selectedObject is LineEdgePoint) { Point diff = mouseLocation.current - new Size(mouseLocation.last); line.__start.Location += new Size(diff); line.__end.Location += new Size(diff); } else if (__selectedObject is SnapBase && (p.Type == PointType.start || p.Type == PointType.end || p.Type == PointType.center)) { p.Location = mouseLocation.current; } return(true); } return(false); }
protected bool isSnapChanged(Point e) { bool repaint = false; SnapBase newsnap = __dataModel.FindSnapPoint(e); if (__snap == null && newsnap == null) // not close to any snapPoint { repaint = false; } else if (newsnap != null && !newsnap.Equals(__snap) || // approach new snapPoint (newsnap == null && __snap != null)) // away from old snapPoint need to clear { repaint = true; } //update if ((__snap = newsnap) != null) { mouseLocation.current = Point.Round(__snap.Location); } return(repaint); }