blob: 60bd9b7d106422d7852720dbc0f031d51da7dae3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Histacom2.Engine.UI
{
public class ClassicLabel : Control
{
public bool DropShadow { get; set; }
public ClassicLabel()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
TextChanged += (s, e) => Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var gfx = e.Graphics;
if (BackColor != Color.Transparent) gfx.Clear(BackColor);
StringFormat sf = new StringFormat();
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
gfx.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle, sf);
Height = (int)gfx.MeasureString(Text, Font, ClientRectangle.Width).Height;
}
private const int CS_DROPSHADOW = 0x00020000;
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
if (DropShadow) cp.ClassStyle |= CS_DROPSHADOW;
return cp;
}
}
}
}
|