SampleCrossUi.WinForms
1.0.0.0
SampleCrossUi.WinForms 사용 방법을 보여 주는 예제 프로젝트입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
CounterPage.cs
이 파일의 문서화 페이지로 가기
1
using
System.ComponentModel;
2
using
Dreamine.UI.WinForms;
3
using
Dreamine.UI.WinForms.Controls;
4
using
SampleCrossUi.Shared.Services;
5
using
SampleCrossUi.Shared.ViewModels;
6
7
namespace
SampleCrossUi.WinForms.Pages
;
8
17
public
sealed
class
CounterPage
: UserControl
18
{
27
private
Label
_title
=
null
!;
36
private
Label
_countLabel
=
null
!;
45
private
DreamineButton
_btnIncrement
=
null
!;
54
private
DreamineButton
_btnReset
=
null
!;
63
private
FlowLayoutPanel
_btnPanel
=
null
!;
72
private
Label
_logTitle
=
null
!;
81
private
ListBox
_logList
=
null
!;
90
private
FlowLayoutPanel
_layout
=
null
!;
91
100
private
readonly CounterViewModel
_vm
;
101
110
public
CounterPage
() : this(new CounterViewModel(new CounterEvent(new CounterService()))) { }
111
128
public
CounterPage
(CounterViewModel vm)
129
{
130
_vm
= vm;
131
InitializeComponent
();
132
133
_btnIncrement.Click += (_, _) =>
_vm
.IncrementCommand.Execute(
null
);
134
_btnReset.Click += (_, _) =>
_vm
.ResetCommand.Execute(
null
);
135
136
_vm.PropertyChanged +=
OnPropertyChanged
;
137
_vm.Logs.CollectionChanged += (_, _) =>
RefreshLog
();
138
RefreshLog
();
139
}
140
165
private
void
OnPropertyChanged
(
object
? sender, PropertyChangedEventArgs e)
166
{
167
if
(e.PropertyName == nameof(CounterViewModel.Count))
168
_countLabel.Text = $
"Count: {_vm.Count}"
;
169
}
170
179
private
void
RefreshLog
()
180
{
181
_logList
.BeginUpdate();
182
_logList
.Items.Clear();
183
foreach
(var item
in
_vm
.Logs)
184
_logList
.Items.Add($
"[{item.CreatedAt:HH:mm:ss}] {item.Message}"
);
185
_logList
.EndUpdate();
186
}
187
196
private
void
InitializeComponent
()
197
{
198
_title
=
new
Label();
199
_countLabel
=
new
Label();
200
_btnIncrement
=
new
DreamineButton();
201
_btnReset
=
new
DreamineButton();
202
_btnPanel
=
new
FlowLayoutPanel();
203
_logTitle
=
new
Label();
204
_logList
=
new
ListBox();
205
_layout
=
new
FlowLayoutPanel();
206
_layout
.SuspendLayout();
207
SuspendLayout();
208
//
209
// _title
210
//
211
_title.AutoSize =
true
;
212
_title.Font =
new
Font(
"Segoe UI"
, 20F, FontStyle.Bold);
213
_title.ForeColor = Color.White;
214
_title.Location =
new
Point(0, 0);
215
_title.Margin =
new
Padding(0, 0, 0, 16);
216
_title.Name =
"_title"
;
217
_title.Size =
new
Size(120, 37);
218
_title.TabIndex = 0;
219
_title.Text =
"Counter"
;
220
//
221
// _countLabel
222
//
223
_countLabel.AutoSize =
true
;
224
_countLabel.Font =
new
Font(
"Segoe UI"
, 36F, FontStyle.Bold);
225
_countLabel.ForeColor = DreamineTheme.AccentBlue;
226
_countLabel.Location =
new
Point(0, 53);
227
_countLabel.Margin =
new
Padding(0, 0, 0, 16);
228
_countLabel.Name =
"_countLabel"
;
229
_countLabel.Size =
new
Size(218, 65);
230
_countLabel.TabIndex = 1;
231
_countLabel.Text =
"Count: 0"
;
232
//
233
// _btnIncrement
234
//
235
_btnIncrement.Content =
"Increment"
;
236
_btnIncrement.Width = 140;
237
_btnIncrement.Height = 40;
238
_btnIncrement.Margin =
new
Padding(0, 0, 8, 0);
239
_btnIncrement.Name =
"_btnIncrement"
;
240
_btnIncrement.TabIndex = 0;
241
//
242
// _btnReset
243
//
244
_btnReset.Content =
"Reset"
;
245
_btnReset.Width = 100;
246
_btnReset.Height = 40;
247
_btnReset.Name =
"_btnReset"
;
248
_btnReset.TabIndex = 1;
249
//
250
// _btnPanel
251
//
252
_btnPanel.AutoSize =
true
;
253
_btnPanel.FlowDirection = FlowDirection.LeftToRight;
254
_btnPanel.Location =
new
Point(0, 134);
255
_btnPanel.Margin =
new
Padding(0, 0, 0, 24);
256
_btnPanel.Name =
"_btnPanel"
;
257
_btnPanel.Size =
new
Size(0, 0);
258
_btnPanel.TabIndex = 2;
259
_btnPanel
.Controls.Add(
_btnIncrement
);
260
_btnPanel
.Controls.Add(
_btnReset
);
261
//
262
// _logTitle
263
//
264
_logTitle.AutoSize =
true
;
265
_logTitle.Font =
new
Font(
"Segoe UI"
, 10F);
266
_logTitle.Location =
new
Point(0, 158);
267
_logTitle.Margin =
new
Padding(0, 0, 0, 4);
268
_logTitle.Name =
"_logTitle"
;
269
_logTitle.Size =
new
Size(98, 19);
270
_logTitle.TabIndex = 3;
271
_logTitle.Text =
"Operation Log"
;
272
//
273
// _logList
274
//
275
_logList.BorderStyle = BorderStyle.FixedSingle;
276
_logList.Font =
new
Font(
"Segoe UI"
, 9F);
277
_logList.ItemHeight = 15;
278
_logList.Location =
new
Point(3, 184);
279
_logList.Name =
"_logList"
;
280
_logList.Size =
new
Size(400, 197);
281
_logList.TabIndex = 4;
282
//
283
// _layout
284
//
285
_layout.AutoSize =
true
;
286
_layout
.Controls.Add(
_title
);
287
_layout
.Controls.Add(
_countLabel
);
288
_layout
.Controls.Add(
_btnPanel
);
289
_layout
.Controls.Add(
_logTitle
);
290
_layout
.Controls.Add(
_logList
);
291
_layout.Dock = DockStyle.Fill;
292
_layout.FlowDirection = FlowDirection.TopDown;
293
_layout.Location =
new
Point(24, 24);
294
_layout.Name =
"_layout"
;
295
_layout.Size =
new
Size(1133, 1225);
296
_layout.TabIndex = 0;
297
_layout.WrapContents =
false
;
298
//
299
// CounterPage
300
//
301
Controls.Add(
_layout
);
302
Name =
"CounterPage"
;
303
Padding =
new
Padding(24);
304
Size =
new
Size(1181, 1273);
305
_layout
.ResumeLayout(
false
);
306
_layout
.PerformLayout();
307
ResumeLayout(
false
);
308
PerformLayout();
309
}
310
327
protected
override
void
Dispose
(
bool
disposing)
328
{
329
if
(disposing) _vm.PropertyChanged -=
OnPropertyChanged
;
330
base.Dispose(disposing);
331
}
332
}
SampleCrossUi.WinForms.Pages
Definition
ControlsPage.cs:6
SampleCrossUi.WinForms.Pages.CounterPage._btnIncrement
DreamineButton _btnIncrement
Definition
CounterPage.cs:45
SampleCrossUi.WinForms.Pages.CounterPage._vm
readonly CounterViewModel _vm
Definition
CounterPage.cs:100
SampleCrossUi.WinForms.Pages.CounterPage._logTitle
Label _logTitle
Definition
CounterPage.cs:72
SampleCrossUi.WinForms.Pages.CounterPage.InitializeComponent
void InitializeComponent()
Definition
CounterPage.cs:196
SampleCrossUi.WinForms.Pages.CounterPage.Dispose
override void Dispose(bool disposing)
Definition
CounterPage.cs:327
SampleCrossUi.WinForms.Pages.CounterPage._countLabel
Label _countLabel
Definition
CounterPage.cs:36
SampleCrossUi.WinForms.Pages.CounterPage._btnReset
DreamineButton _btnReset
Definition
CounterPage.cs:54
SampleCrossUi.WinForms.Pages.CounterPage._title
Label _title
Definition
CounterPage.cs:27
SampleCrossUi.WinForms.Pages.CounterPage.OnPropertyChanged
void OnPropertyChanged(object? sender, PropertyChangedEventArgs e)
Definition
CounterPage.cs:165
SampleCrossUi.WinForms.Pages.CounterPage.RefreshLog
void RefreshLog()
Definition
CounterPage.cs:179
SampleCrossUi.WinForms.Pages.CounterPage.CounterPage
CounterPage(CounterViewModel vm)
Definition
CounterPage.cs:128
SampleCrossUi.WinForms.Pages.CounterPage.CounterPage
CounterPage()
Definition
CounterPage.cs:110
SampleCrossUi.WinForms.Pages.CounterPage._btnPanel
FlowLayoutPanel _btnPanel
Definition
CounterPage.cs:63
SampleCrossUi.WinForms.Pages.CounterPage._layout
FlowLayoutPanel _layout
Definition
CounterPage.cs:90
SampleCrossUi.WinForms.Pages.CounterPage._logList
ListBox _logList
Definition
CounterPage.cs:81
Pages
CounterPage.cs
다음에 의해 생성됨 :
1.17.0