mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using mRemoteNG.Themes;
|
|
using System;
|
|
using System.Windows.Forms;
|
|
|
|
namespace mRemoteNG.UI.Controls.Base
|
|
{
|
|
//This class is only minimally themed as textboxes onPaint are hard to theme (system wm paint control most of the drawing process
|
|
//There are some glitches on the initial draw of some controls
|
|
public class NGTextBox : TextBox
|
|
{
|
|
private ThemeManager _themeManager;
|
|
|
|
public NGTextBox()
|
|
{
|
|
ThemeManager.getInstance().ThemeChanged += OnCreateControl;
|
|
}
|
|
|
|
protected override void OnCreateControl()
|
|
{
|
|
base.OnCreateControl();
|
|
if (Tools.DesignModeTest.IsInDesignMode(this)) return;
|
|
_themeManager = ThemeManager.getInstance();
|
|
if (!_themeManager.ThemingActive) return;
|
|
ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Foreground");
|
|
BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Background");
|
|
Invalidate();
|
|
}
|
|
|
|
|
|
|
|
protected override void OnEnabledChanged(EventArgs e)
|
|
{
|
|
if (!Tools.DesignModeTest.IsInDesignMode(this))
|
|
{
|
|
_themeManager = ThemeManager.getInstance();
|
|
if(_themeManager.ThemingActive)
|
|
{
|
|
if (Enabled)
|
|
{
|
|
ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Foreground");
|
|
BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Background");
|
|
}
|
|
else
|
|
{
|
|
BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TextBox_Disabled_Background");
|
|
}
|
|
}
|
|
}
|
|
base.OnEnabledChanged(e);
|
|
Invalidate();
|
|
}
|
|
|
|
|
|
}
|
|
}
|