コード例 #1
0
        public SnappableLine CreateLine(Point start, Point end, int gridSize)
        {
            var line = new SnappableLine(start, end, gridSize);

            SnapLineEndIfItIsCloseToAnotherLine(line, start, end);
            _lines.Add(line);
            return(line);
        }
コード例 #2
0
        private void SnapLineEndIfItIsCloseToAnotherLine(SnappableLine line, Point start, Point end)
        {
            foreach (var existingLine in _lines)
            {
                var distance = existingLine.DistanceFrom(end);
                if (!IsCloseEnoughToSnap(distance))
                {
                    continue;
                }

                SnapLineEndToPoint(line, start, distance.ClosestPointInLine);
                return;
            }

            line.Move(start, end);
        }
コード例 #3
0
 private void SnapLineEndToPoint(SnappableLine line, Point start, Point snapPoint)
 {
     line.Move(start, snapPoint, false);
 }
コード例 #4
0
 public void MoveLine(SnappableLine line, Point start, Point end)
 {
     SnapLineEndIfItIsCloseToAnotherLine(line, start, end);
 }