protected override void OnMaximumSizeChanged() { base.OnMaximumSizeChanged(); float num = 0f; float num2 = 0f; SizeF maximumSize = base.MaximumSize; for (int i = 0; i < this.tipSections.Length; i++) { TipSection tipSection = this.tipSections[i]; tipSection.SetMaximumSize(maximumSize); SizeF requiredSize = tipSection.GetRequiredSize(); this.offsets[i] = num; if (this.isHorizontal) { float num3 = (float)Math.Ceiling((double)requiredSize.Width); num += num3; maximumSize.Width = Math.Max(0f, maximumSize.Width - num3); num2 = Math.Max(num2, requiredSize.Height); } else { float num3 = (float)Math.Ceiling((double)requiredSize.Height); num += num3; maximumSize.Height = Math.Max(0f, maximumSize.Height - num3); num2 = Math.Max(num2, requiredSize.Width); } } TipSection[] array = this.tipSections; for (int j = 0; j < array.Length; j++) { TipSection tipSection2 = array[j]; if (this.isHorizontal) { tipSection2.SetAllocatedSize(new SizeF(tipSection2.GetRequiredSize().Width, num2)); } else { tipSection2.SetAllocatedSize(new SizeF(num2, tipSection2.GetRequiredSize().Height)); } } if (this.isHorizontal) { base.SetRequiredSize(new SizeF(num, num2)); return; } base.SetRequiredSize(new SizeF(num2, num)); }
public static Size DrawTip(Control control, Graphics graphics, TipSection tipData) { Size size = Size.Empty; SizeF sizeF = SizeF.Empty; PointF pointF = control.PointToScreen(Point.Empty); if (TipPainter.workingArea == RectangleF.Empty) { Form form = control.FindForm(); if (form.Owner != null) { form = form.Owner; } TipPainter.workingArea = Screen.GetWorkingArea(form); } SizeF maximumSize = new SizeF(TipPainter.workingArea.Right - pointF.X - 4f, TipPainter.workingArea.Bottom - pointF.Y - 2f); if (maximumSize.Width > 0f && maximumSize.Height > 0f) { graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; tipData.SetMaximumSize(maximumSize); sizeF = tipData.GetRequiredSize(); tipData.SetAllocatedSize(sizeF); sizeF += new SizeF(4f, 2f); size = Size.Ceiling(sizeF); } if (control.ClientSize != size) { control.ClientSize = size; } if (size != Size.Empty) { Rectangle rect = new Rectangle(Point.Empty, size - new Size(1, 1)); new RectangleF(2f, 1f, sizeF.Width - 4f, sizeF.Height - 2f); graphics.DrawRectangle(SystemPens.WindowFrame, rect); tipData.Draw(new PointF(2f, 1f)); } return(size); }