Skip to content

Commit 523b49f

Browse files
committed
Fix text layout after overflow lines
1 parent aaaae40 commit 523b49f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Source/ExcelDna.IntelliSense/ToolTipForm.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ protected override void OnPaint(PaintEventArgs e)
315315
{
316316
base.OnPaint(e);
317317

318-
List<int> lineWidths = new List<int>();
319318
const int maxWidth = 1000; // Should depend on screen width?
320319
const int maxHeight = 500;
321320
const int leftPadding = 6;
@@ -333,6 +332,7 @@ protected override void OnPaint(PaintEventArgs e)
333332
TextFormatFlags.SingleLine |
334333
TextFormatFlags.ExternalLeading;
335334

335+
List<int> lineWidths = new List<int>();
336336
int currentHeight = 0; // Measured from layoutTop, going down
337337
foreach (var line in _text)
338338
{
@@ -359,7 +359,6 @@ protected override void OnPaint(PaintEventArgs e)
359359
{
360360
if (text == "") continue;
361361

362-
// How wide is this part?
363362
var proposedSize = new Size(maxWidth - lineWidth, maxHeight - currentHeight);
364363
var textSize = TextRenderer.MeasureText(e.Graphics, text, font, proposedSize, textFormatFlags);
365364
if (textSize.Width <= proposedSize.Width)
@@ -378,10 +377,10 @@ protected override void OnPaint(PaintEventArgs e)
378377
currentHeight += linePadding;
379378

380379
lineHeight = minLineHeight;
381-
lineWidth = 2; // Little bit of indent on these lines
380+
lineWidth = 2; // Start with a little bit of indent on these lines
382381
}
383-
TextRenderer.DrawText(e.Graphics, text, font, new Rectangle(layoutLeft + lineWidth, layoutTop + currentHeight, maxWidth, maxHeight - currentHeight), color, textFormatFlags |= TextFormatFlags.EndEllipsis);
384-
lineWidth += Math.Min(textSize.Width, maxWidth); // + 1;
382+
TextRenderer.DrawText(e.Graphics, text, font, new Rectangle(layoutLeft + lineWidth, layoutTop + currentHeight, maxWidth, maxHeight - currentHeight), color, textFormatFlags | TextFormatFlags.EndEllipsis);
383+
lineWidth += textSize.Width;
385384
}
386385

387386
if (run.IsLink)

0 commit comments

Comments
 (0)