public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
{
Size tipSize = Size.Empty;
SizeF tipSizeF = SizeF.Empty;
RectangleF workingArea = GetWorkingArea(control);
PointF screenLocation = control.PointToScreen(Point.Empty);
SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);
if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
graphics.TextRenderingHint =
TextRenderingHint.AntiAliasGridFit;
tipData.SetMaximumSize(maxLayoutSize);
tipSizeF = tipData.GetRequiredSize();
tipData.SetAllocatedSize(tipSizeF);
tipSizeF += new SizeF(HorizontalBorder * 2,
VerticalBorder * 2);
tipSize = Size.Ceiling(tipSizeF);
}
if (control.ClientSize != tipSize) {
control.ClientSize = tipSize;
}
return tipSize;
}