Beispiel #1
0
        private Rectangle GetSegmentId(Point point1, Point point2)
        {
            if (!MapBounds.ContainsLine(point1, point2) && !MapBounds.IntersectsLine(point1, point2))
            {
                var newPoint1 = WrapPoint(point1);
                var diff      = new Size(point1.X - newPoint1.X, point1.Y - newPoint1.Y);
                point1 = newPoint1;
                point2 = Point.Subtract(point2, diff);
            }

            if (Utils.LineIntersectsLine(point1, point2, _borderPointX, _borderPointEdge))
            {
                point1.X -= Width();
                point2.X -= Width();
            }

            if (Utils.LineIntersectsLine(point1, point2, _borderPointY, _borderPointEdge))
            {
                point1.Y -= Height();
                point2.Y -= Height();
            }

            return(new Rectangle(Math.Min(point1.X, point2.X), Math.Min(point1.Y, point2.Y), Math.Abs(point1.X - point2.X), Math.Abs(point1.Y - point2.Y)));
        }