Dreamine.UI.WinForms
1.0.1
Dreamine.UI.WinForms 사용자 인터페이스 기능과 구성 요소를 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
DreamineListBox.cs
이 파일의 문서화 페이지로 가기
1
using
System.Drawing;
2
using
Dreamine.UI.WinForms
;
3
4
namespace
Dreamine.UI.WinForms.Controls
;
5
14
public
class
DreamineListBox
: UserControl
15
{
24
private
readonly ListBox
_inner
;
33
private
bool
_isFocused
;
34
43
public
ListBox.ObjectCollection
Items
=>
_inner
.Items;
44
53
public
object
?
SelectedItem
54
{
55
get
=>
_inner
.SelectedItem;
56
set
=> _inner.SelectedItem = value;
57
}
58
67
public
int
SelectedIndex
68
{
69
get
=>
_inner
.SelectedIndex;
70
set
=> _inner.SelectedIndex = value;
71
}
72
81
public
object
?
DataSource
82
{
83
get
=>
_inner
.DataSource;
84
set
=> _inner.DataSource = value;
85
}
86
95
public
override
Color
ForeColor
96
{
97
get
=> base.ForeColor;
98
set
{ base.ForeColor = value; _inner.ForeColor = value; }
99
}
100
109
public
new
Font
Font
110
{
111
get
=> base.Font;
112
set
{ base.Font = value; _inner.Font = value; }
113
}
114
123
public
event
EventHandler?
SelectedIndexChanged
;
132
public
new
event
MouseEventHandler?
DoubleClick
133
{
134
add => _inner.MouseDoubleClick += value;
135
remove
=> _inner.MouseDoubleClick -= value;
136
}
137
146
public
bool
AutoScrollToEnd
{
get
;
set
; }
147
156
public
DreamineListBox
()
157
{
158
_inner
=
new
ListBox
159
{
160
BorderStyle = BorderStyle.None,
161
// IntegralHeight=true(기본값)면 마지막 줄이 잘릴 때 빈 띠를 남겨버려서
162
// Dock=Fill로 크기를 강제로 맞추는 우리 사용 패턴과 충돌한다.
163
IntegralHeight =
false
,
164
BackColor =
DreamineTheme
.
InputBackground
,
165
ForeColor
=
DreamineTheme
.
TextPrimary
,
166
Font
=
new
Font
(
"Segoe UI"
, 10f, FontStyle.Regular, GraphicsUnit.Point),
167
Dock = DockStyle.Fill,
168
};
169
170
_inner.GotFocus += (_, _) => {
_isFocused
=
true
; Invalidate(); };
171
_inner.LostFocus += (_, _) => {
_isFocused
=
false
; Invalidate(); };
172
_inner.SelectedIndexChanged += (s, e) =>
173
{
174
SelectedIndexChanged
?.Invoke(
this
, e);
175
if
(
AutoScrollToEnd
&&
_inner
.Items.Count > 0)
176
_inner.TopIndex = _inner.Items.Count - 1;
177
};
178
179
SetStyle(
180
ControlStyles.AllPaintingInWmPaint |
181
ControlStyles.UserPaint |
182
ControlStyles.DoubleBuffer |
183
ControlStyles.ResizeRedraw,
true
);
184
185
BackColor =
DreamineTheme
.
InputBackground
;
186
ForeColor
=
DreamineTheme
.
TextPrimary
;
187
Font
=
_inner
.Font;
188
Padding =
new
Padding(2);
189
190
Controls
.Add(
_inner
);
191
}
192
201
public
void
NotifyItemAdded
()
202
{
203
if
(
AutoScrollToEnd
&&
_inner
.Items.Count > 0)
204
_inner.TopIndex = _inner.Items.Count - 1;
205
}
206
223
protected
override
void
OnPaint
(PaintEventArgs e)
224
{
225
var g = e.Graphics;
226
var rect =
new
Rectangle(0, 0, Width - 1, Height - 1);
227
using
var bgBrush =
new
SolidBrush(BackColor);
228
var borderColor =
_isFocused
?
DreamineTheme.BorderFocus
:
DreamineTheme
.
BorderNormal
;
229
using
var pen =
new
Pen(borderColor, 1.5f);
230
DreamineDrawHelper
.
FillRoundedRect
(g, bgBrush, pen, rect,
DreamineTheme
.
CornerRadiusSmall
);
231
}
232
241
protected
override
Size
DefaultSize
=>
new
(220, 100);
242
}
Dreamine.UI.WinForms
Definition
DreamineButton.cs:6
Dreamine.UI.WinForms.Controls
Definition
DreamineButton.cs:6
Dreamine.UI.WinForms.Controls.DreamineListBox.Items
ListBox.ObjectCollection Items
Definition
DreamineListBox.cs:43
Dreamine.UI.WinForms.Controls.DreamineListBox.ForeColor
override Color ForeColor
Definition
DreamineListBox.cs:96
Dreamine.UI.WinForms.Controls.DreamineListBox.AutoScrollToEnd
bool AutoScrollToEnd
Definition
DreamineListBox.cs:146
Dreamine.UI.WinForms.Controls.DreamineListBox.NotifyItemAdded
void NotifyItemAdded()
Definition
DreamineListBox.cs:201
Dreamine.UI.WinForms.Controls.DreamineListBox.DataSource
object? DataSource
Definition
DreamineListBox.cs:82
Dreamine.UI.WinForms.Controls.DreamineListBox.SelectedItem
object? SelectedItem
Definition
DreamineListBox.cs:54
Dreamine.UI.WinForms.Controls.DreamineListBox.OnPaint
override void OnPaint(PaintEventArgs e)
Definition
DreamineListBox.cs:223
Dreamine.UI.WinForms.Controls.DreamineListBox._inner
readonly ListBox _inner
Definition
DreamineListBox.cs:24
Dreamine.UI.WinForms.Controls.DreamineListBox.DreamineListBox
DreamineListBox()
Definition
DreamineListBox.cs:156
Dreamine.UI.WinForms.Controls.DreamineListBox.DoubleClick
new? MouseEventHandler DoubleClick
Definition
DreamineListBox.cs:133
Dreamine.UI.WinForms.Controls.DreamineListBox.SelectedIndexChanged
EventHandler? SelectedIndexChanged
Definition
DreamineListBox.cs:123
Dreamine.UI.WinForms.Controls.DreamineListBox.Font
new Font Font
Definition
DreamineListBox.cs:110
Dreamine.UI.WinForms.Controls.DreamineListBox._isFocused
bool _isFocused
Definition
DreamineListBox.cs:33
Dreamine.UI.WinForms.Controls.DreamineListBox.SelectedIndex
int SelectedIndex
Definition
DreamineListBox.cs:68
Dreamine.UI.WinForms.Controls.DreamineListBox.DefaultSize
override Size DefaultSize
Definition
DreamineListBox.cs:241
Dreamine.UI.WinForms.DreamineDrawHelper
Definition
DreamineDrawHelper.cs:15
Dreamine.UI.WinForms.DreamineDrawHelper.FillRoundedRect
static void FillRoundedRect(Graphics g, Brush fill, Pen? border, Rectangle rect, float radius)
Definition
DreamineDrawHelper.cs:144
Dreamine.UI.WinForms.DreamineTheme
Definition
DreamineTheme.cs:14
Dreamine.UI.WinForms.DreamineTheme.CornerRadiusSmall
const int CornerRadiusSmall
Definition
DreamineTheme.cs:225
Dreamine.UI.WinForms.DreamineTheme.BorderFocus
static readonly Color BorderFocus
Definition
DreamineTheme.cs:80
Dreamine.UI.WinForms.DreamineTheme.TextPrimary
static readonly Color TextPrimary
Definition
DreamineTheme.cs:91
Dreamine.UI.WinForms.DreamineTheme.BorderNormal
static readonly Color BorderNormal
Definition
DreamineTheme.cs:71
Dreamine.UI.WinForms.DreamineTheme.InputBackground
static readonly Color InputBackground
Definition
DreamineTheme.cs:42
Controls
DreamineListBox.cs
다음에 의해 생성됨 :
1.17.0