public int AddCallout(string name, string text, CalloutStyle style, double x, double y, double width, double height) { CalloutAnnotation calloutAnnotation = new CalloutAnnotation(); if (name.Length > 0) { calloutAnnotation.Name = name; } calloutAnnotation.X = x; calloutAnnotation.Y = y; calloutAnnotation.Width = width; calloutAnnotation.Height = height; calloutAnnotation.Text = text; calloutAnnotation.CalloutStyle = style; return(base.List.Add(calloutAnnotation)); }
private bool LineIntersectRectangle(RectangleF rect, PointF point1, PointF point2) { if (point1.X == point2.X) { if (point1.X >= rect.X && point1.X <= rect.Right) { if (point1.Y < rect.Y && point2.Y < rect.Y) { return(false); } if (point1.Y > rect.Bottom && point2.Y > rect.Bottom) { return(false); } return(true); } return(false); } if (point1.Y == point2.Y) { if (point1.Y >= rect.Y && point1.Y <= rect.Bottom) { if (point1.X < rect.X && point2.X < rect.X) { return(false); } if (point1.X > rect.Right && point2.X > rect.Right) { return(false); } return(true); } return(false); } if (point1.X < rect.X && point2.X < rect.X) { return(false); } if (point1.X > rect.Right && point2.X > rect.Right) { return(false); } if (point1.Y < rect.Y && point2.Y < rect.Y) { return(false); } if (point1.Y > rect.Bottom && point2.Y > rect.Bottom) { return(false); } if (rect.Contains(point1) || rect.Contains(point2)) { return(true); } PointF intersectionY = CalloutAnnotation.GetIntersectionY(point1, point2, rect.Y); if (rect.Contains(intersectionY)) { return(true); } intersectionY = CalloutAnnotation.GetIntersectionY(point1, point2, rect.Bottom); if (rect.Contains(intersectionY)) { return(true); } intersectionY = CalloutAnnotation.GetIntersectionX(point1, point2, rect.X); if (rect.Contains(intersectionY)) { return(true); } intersectionY = CalloutAnnotation.GetIntersectionX(point1, point2, rect.Right); if (rect.Contains(intersectionY)) { return(true); } return(false); }