-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMoonBox.cs
More file actions
63 lines (59 loc) · 2.32 KB
/
MoonBox.cs
File metadata and controls
63 lines (59 loc) · 2.32 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Drawing;
using System.Windows.Forms;
namespace Mint
{
public class MoonBox : ComboBox
{
private const int WM_PAINT = 0xF;
private int buttonWidth = SystemInformation.HorizontalScrollBarArrowWidth;
private Color borderColor = Color.Blue;
public Color BorderColor
{
get
{
return borderColor;
}
set
{
borderColor = value; Invalidate();
}
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_PAINT && DropDownStyle != ComboBoxStyle.Simple)
{
using (var g = Graphics.FromHwnd(Handle))
{
var adjustMent = 0;
if (FlatStyle == FlatStyle.Popup ||
(FlatStyle == FlatStyle.Flat &&
DropDownStyle == ComboBoxStyle.DropDownList))
adjustMent = 1;
var innerBorderWisth = 3;
var innerBorderColor = BackColor;
if (DropDownStyle == ComboBoxStyle.DropDownList &&
(FlatStyle == FlatStyle.System || FlatStyle == FlatStyle.Standard))
innerBorderColor = Color.FromArgb(0xCCCCCC);
if (DropDownStyle == ComboBoxStyle.DropDownList && !Enabled)
innerBorderColor = SystemColors.Control;
if (DropDownStyle == ComboBoxStyle.DropDownList || Enabled == false)
{
using (var p = new Pen(innerBorderColor, innerBorderWisth))
{
p.Alignment = System.Drawing.Drawing2D.PenAlignment.Inset;
g.DrawRectangle(p, 1, 1,
Width - buttonWidth - adjustMent - 1, Height - 1);
}
}
using (var p = new Pen(BorderColor))
{
g.DrawRectangle(p, 0, 0, Width - 1, Height - 1);
g.DrawLine(p, Width - buttonWidth - adjustMent,
0, Width - buttonWidth - adjustMent, Height);
}
}
}
}
}
}