public override bool CalculateCalloutLocation(out PointF location, out CoordinateSystem coordinateSystem) { // if the user has manually positioned the callout, we won't override it if (_manuallyPositionedCallout) { location = PointF.Empty; coordinateSystem = CoordinateSystem.Destination; return(false); } Callout.CoordinateSystem = CoordinateSystem.Destination; AnnotationSubject.CoordinateSystem = CoordinateSystem.Destination; try { var roiBoundingBox = AnnotationSubject.BoundingBox; var clientRectangle = AnnotationSubject.ParentPresentationImage.ClientRectangle; var textSize = Callout.TextBoundingBox.Size; if (textSize.IsEmpty) { textSize = new SizeF(100, 50); } coordinateSystem = CoordinateSystem.Destination; location = new PointF(ComputeCalloutLocationX(textSize, clientRectangle, roiBoundingBox), ComputeCalloutLocationY(textSize, clientRectangle, roiBoundingBox)); } finally { Callout.ResetCoordinateSystem(); AnnotationSubject.ResetCoordinateSystem(); } return(true); }
public override bool CalculateCalloutLocation(out PointF location, out CoordinateSystem coordinateSystem) { // if the user has manually positioned the callout, we won't override it if (_manuallyPositionedCallout || Roi.Points.Count == 0) { location = PointF.Empty; coordinateSystem = CoordinateSystem.Destination; return(false); } Callout.CoordinateSystem = CoordinateSystem.Destination; Roi.CoordinateSystem = CoordinateSystem.Destination; try { var roiPoint1 = Roi.Points[0]; var roiPoint2 = Roi.Points[Roi.Points.Count - 1]; var clientRectangle = Roi.ParentPresentationImage.ClientRectangle; var textSize = Callout.TextBoundingBox.Size; if (textSize.IsEmpty) { textSize = new SizeF(100, 50); } var calloutLocation = new PointF(); calloutLocation.Y = ComputeCalloutLocationY(textSize, clientRectangle, roiPoint1, roiPoint2); calloutLocation.X = ComputeCalloutLocationX(textSize, clientRectangle, roiPoint1, roiPoint2, calloutLocation.Y); coordinateSystem = CoordinateSystem.Destination; location = calloutLocation; } finally { Callout.ResetCoordinateSystem(); Roi.ResetCoordinateSystem(); } return(true); }