지정한 설정으로 LightBulbPage 클래스의 새 인스턴스를 초기화합니다.
127 {
128 _vm = vm;
129
130 BackColor = DreamineTheme.AppBackground;
131 Dock = DockStyle.Fill;
132
133 var layout = new TableLayoutPanel
134 {
135 Dock = DockStyle.Fill,
136 ColumnCount = 1,
137 RowCount = 6,
138 Padding = new Padding(24),
139 };
140 layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
141 layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
142 layout.RowStyles.Add(new RowStyle(SizeType.Absolute, 180));
143 layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
144 layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
145 layout.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
146
147 _title = new Label
148 {
149 Text = "Light Bulb",
150 AutoSize = true,
151 ForeColor = Color.White,
152 Font = new Font("Segoe UI", 22f, FontStyle.Bold),
153 Anchor = AnchorStyles.None,
154 Margin = new Padding(0, 0, 0, 8)
155 };
156
157 _description = new Label
158 {
159 Text = "A button command and a checkbox binding drive the same shared state.",
160 AutoSize = true,
161 ForeColor = Color.FromArgb(184, 198, 221),
162 Font = new Font("Segoe UI", 10f),
163 Anchor = AnchorStyles.None,
164 Margin = new Padding(0, 0, 0, 18)
165 };
166
167 _bulb = new DreamineLightBulb
168 {
169 Width = 160,
170 Height = 170,
171 Diameter = 112,
172 Anchor = AnchorStyles.None,
173 BackColor = DreamineTheme.AppBackground,
174 Margin = new Padding(0, 0, 0, 6)
175 };
176
177 _status = new Label
178 {
179 AutoSize = true,
180 ForeColor = Color.FromArgb(141, 203, 255),
181 Font = new Font("Consolas", 10f, FontStyle.Bold),
182 Anchor = AnchorStyles.None,
183 Margin = new Padding(0, 0, 0, 18)
184 };
185
186 var row = new FlowLayoutPanel
187 {
188 AutoSize = true,
189 Anchor = AnchorStyles.None,
190 FlowDirection = FlowDirection.LeftToRight,
191 WrapContents = false,
192 };
193
194 _toggleButton = new DreamineButton
195 {
196 Content = "Toggle",
197 Width = 110,
198 Height = 40,
199 Margin = new Padding(0, 0, 14, 0),
200 };
201
202 _powerCheckBox = new CheckBox
203 {
204 Text = "Power",
205 AutoSize = true,
206 ForeColor = Color.White,
207 BackColor = DreamineTheme.AppBackground,
208 Margin = new Padding(0, 10, 14, 0),
209 };
210
211 _count = new Label
212 {
213 AutoSize = true,
214 ForeColor = Color.FromArgb(217, 227, 241),
215 Font = new Font("Consolas", 9f),
216 Margin = new Padding(0, 12, 0, 0),
217 };
218
219 row.Controls.Add(_toggleButton);
220 row.Controls.Add(_powerCheckBox);
221 row.Controls.Add(_count);
222
223 layout.Controls.Add(_title, 0, 0);
224 layout.Controls.Add(_description, 0, 1);
225 layout.Controls.Add(_bulb, 0, 2);
226 layout.Controls.Add(_status, 0, 3);
227 layout.Controls.Add(row, 0, 4);
228 Controls.Add(layout);
229
230 _toggleButton.Click += (_, _) => _vm.ToggleCommand.Execute(null);
231 _powerCheckBox.CheckedChanged += (_, _) =>
232 {
233 if (_refreshing || _vm.IsOn == _powerCheckBox.Checked) return;
234 _vm.ToggleCommand.Execute(null);
235 };
236 _vm.PropertyChanged += OnViewModelPropertyChanged;
237
238 RefreshState();
239 }