mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 12:08:37 +08:00
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using mRemoteNG.Themes;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Drawing.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace mRemoteNG.UI.Controls.Base
|
|
{
|
|
//Themable label to overide the winforms behavior of drawing the forecolor of disabled with a system color
|
|
[ToolboxBitmap(typeof(Label))]
|
|
public class NGLabel : Label
|
|
{
|
|
|
|
private ThemeManager _themeManager;
|
|
|
|
protected override void OnCreateControl()
|
|
{
|
|
base.OnCreateControl();
|
|
if (!Tools.DesignModeTest.IsInDesignMode(this))
|
|
_themeManager = ThemeManager.getInstance();
|
|
}
|
|
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
if (Tools.DesignModeTest.IsInDesignMode(this))
|
|
{
|
|
base.OnPaint(e);
|
|
return;
|
|
}
|
|
|
|
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
|
|
if (Enabled)
|
|
{
|
|
TextRenderer.DrawText(e.Graphics, this.Text, Font, ClientRectangle, ForeColor, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
|
|
}
|
|
else
|
|
{
|
|
Color disabledtextLabel = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Disabled_Foreground");
|
|
TextRenderer.DrawText(e.Graphics, this.Text, Font, ClientRectangle, disabledtextLabel, TextFormatFlags.Left | TextFormatFlags.VerticalCenter);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|