/
LabalBold.cs
20 lines (19 loc) · 984 Bytes
/
LabalBold.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class BoldLabel : Label {
protected override void OnPaint(PaintEventArgs e) {
Point drawPoint = new(0, 0);
string[] array = Text.Split(new char[] { '|' });
if (array.Length == 2) {
Font normalFont = this.Font;
Font boldFont = new(normalFont, FontStyle.Bold);
Size boldSize = TextRenderer.MeasureText(array[0], boldFont);
Size normalSize = TextRenderer.MeasureText(array[1], normalFont);
Rectangle boldRect = new(drawPoint, boldSize);
Rectangle normalRect = new(boldRect.Right, boldRect.Top, normalSize.Width, normalSize.Height);
TextRenderer.DrawText(e.Graphics, array[0], boldFont, boldRect, ForeColor);
TextRenderer.DrawText(e.Graphics, array[1], normalFont, normalRect, ForeColor);
} else {
TextRenderer.DrawText(e.Graphics, Text, Font, drawPoint, ForeColor);
}
}
}
//https://pt.stackoverflow.com/q/5536/101