UltimateZoneBuilder/Source/Core/Controls/TransparentTrackBar.cs

41 lines
1.1 KiB
C#
Executable file

using System.Drawing;
using System.Windows.Forms;
// [ZZ] this is a copypasted version of TransparentPanel :)
// implements the same functionality, except for a TrackBar, for use in tab controls.
namespace CodeImp.DoomBuilder.Controls
{
public class TransparentTrackBar : TrackBar
{
#region ================== Constructor / Disposer
// Constructor
public TransparentTrackBar()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
}
#endregion
#region ================== Methods
protected override void OnCreateControl()
{
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
if (Parent != null)
BackColor = Parent.BackColor;
base.OnCreateControl();
}
// Disable background drawing by overriding this
protected override void OnPaintBackground(PaintEventArgs e)
{
if (BackColor != Color.Transparent)
e.Graphics.Clear(BackColor);
}
#endregion
}
}