2017-09-12 09:51:26 -04:00
|
|
|
|
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
|
|
|
|
|
{
|
2017-10-21 00:51:46 -04:00
|
|
|
|
public bool DropShadow { get; set; }
|
|
|
|
|
|
2017-09-12 09:51:26 -04:00
|
|
|
|
public ClassicLabel()
|
|
|
|
|
{
|
2017-10-21 00:51:46 -04:00
|
|
|
|
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
2017-10-15 11:40:01 -04:00
|
|
|
|
TextChanged += (s, e) => Invalidate();
|
2017-09-12 09:51:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnPaint(e);
|
|
|
|
|
var gfx = e.Graphics;
|
2017-10-21 00:51:46 -04:00
|
|
|
|
if (BackColor != Color.Transparent) gfx.Clear(BackColor);
|
2017-10-29 00:50:08 -04:00
|
|
|
|
StringFormat sf = new StringFormat();
|
|
|
|
|
sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
|
2017-09-12 09:51:26 -04:00
|
|
|
|
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;
|
|
|
|
|
|
2017-10-29 00:50:08 -04:00
|
|
|
|
gfx.DrawString(Text, Font, new SolidBrush(ForeColor), ClientRectangle, sf);
|
2017-09-19 00:04:20 -04:00
|
|
|
|
Height = (int)gfx.MeasureString(Text, Font, ClientRectangle.Width).Height;
|
2017-09-12 09:51:26 -04:00
|
|
|
|
}
|
2017-10-21 00:51:46 -04:00
|
|
|
|
|
|
|
|
|
private const int CS_DROPSHADOW = 0x00020000;
|
|
|
|
|
protected override CreateParams CreateParams
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
CreateParams cp = base.CreateParams;
|
|
|
|
|
if (DropShadow) cp.ClassStyle |= CS_DROPSHADOW;
|
|
|
|
|
return cp;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-12 09:51:26 -04:00
|
|
|
|
}
|
|
|
|
|
}
|