-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserControlCheckBox.cs
More file actions
48 lines (43 loc) · 1.41 KB
/
Copy pathUserControlCheckBox.cs
File metadata and controls
48 lines (43 loc) · 1.41 KB
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
48
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ASCOM.ST4Commander
{
public partial class UserControlCheckBox : CheckBox
{
public UserControlCheckBox()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
if (!Enabled)
{
using (CheckBox temp = new CheckBox())
using (Bitmap bitmap = new Bitmap(Width, Height))
{
// Copy the relevant properties
temp.BackColor = BackColor;
temp.ForeColor = System.Drawing.Color.DarkGray;
temp.AutoSize = AutoSize;
temp.Size = Size;
temp.Width += 50;
temp.Text = Text;
//temp.ForeColor = Color.Red; // the new disabled color
temp.DrawToBitmap(bitmap, temp.ClientRectangle); // (1) draw the temporary label to a bitmap, and then
e.Graphics.DrawImage(bitmap, Point.Empty); // (2) draw that bitmap instead of the label object
}
}
else
{
base.OnPaint(e);
}
}
}
}