Dreamine.Web 1.0.0.0
WPF와 Blazor를 한 코드 흐름으로 연결하고 반복적인 MVVM 코드를 줄이는 오픈소스 FullKit 공식 웹 애플리케이션입니다.
로딩중...
검색중...
일치하는것 없음
ControlsShowcaseViewModel.cs
이 파일의 문서화 페이지로 가기
1using System.Collections.ObjectModel;
2using Dreamine.MVVM.ViewModels;
3
5
14public sealed class ControlsShowcaseViewModel : ViewModelBase
15{
16 // ── Button ────────────────────────────────────────────
25 public int ClickCount { get; private set; }
34 public ObservableCollection<string> ActivityLog { get; } = new();
35
44 public void ClickMe()
45 {
46 ClickCount++;
47 ActivityLog.Insert(0, $"[{DateTime.Now:HH:mm:ss}] Clicked ({ClickCount})");
48 while (ActivityLog.Count > 8) ActivityLog.RemoveAt(ActivityLog.Count - 1);
49 Raise();
50 }
51
52 // ── CheckBox ──────────────────────────────────────────
61 private bool _check1 = true, _check2, _check3;
70 public bool Check1 { get => _check1; set { _check1 = value; Raise(); } }
79 public bool Check2 { get => _check2; set { _check2 = value; Raise(); } }
88 public bool Check3 { get => _check3; set { _check3 = value; Raise(); } }
89
90 // ── RadioButton ───────────────────────────────────────
99 public string SelectedRadio { get; private set; } = "Option A";
116 public void SelectRadio(string option) { SelectedRadio = option; Raise(); }
117
118 // -- CheckLed (Dreamine signature control) -------------
127 public bool LedIsOn { get; private set; } = true;
136 public bool LedIsPulse { get; private set; }
145 public void ToggleLed() { LedIsOn = !LedIsOn; Raise(); }
154 public void TogglePulse() { LedIsPulse = !LedIsPulse; Raise(); }
155
156 // ── TextBox / PasswordBox ─────────────────────────────
165 private string _textInput = string.Empty;
174 private string _password = string.Empty;
183 public string TextInput { get => _textInput; set { _textInput = value; Raise(); } }
192 public string Password { get => _password; set { _password = value; Raise(); } }
201 public void ClearText() { _textInput = string.Empty; Raise(); }
210 public void ClearPassword() { _password = string.Empty; Raise(); }
211
212 // ── ComboBox ──────────────────────────────────────────
221 public string[] FruitItems { get; } = { "Apple", "Banana", "Cherry", "Grape", "Mango", "Melon" };
230 private string _selectedFruit = "Cherry";
239 public string SelectedFruit { get => _selectedFruit; set { _selectedFruit = value; Raise(); } }
240
241 // ── Expander ──────────────────────────────────────────
250 private bool _isExpanded = true;
259 public bool IsExpanded { get => _isExpanded; set { _isExpanded = value; Raise(); } }
268 public void ToggleExpand() { _isExpanded = !_isExpanded; Raise(); }
269
270 // ── Numeric (0~100 clamp) ─────────────────────────────
279 private double _numericInput = 50;
288 public double NumericInput
289 {
290 get => _numericInput;
291 set { _numericInput = Math.Clamp(value, 0, 100); Raise(); }
292 }
293
294 // -- ListBox (selection + double-click activation) -----
303 public string ListActivated { get; private set; } = "(double-click an item)";
320 public void ActivateListItem(string item) { ListActivated = $"Activated: {item}"; Raise(); }
321
322 // ── Counter ──────────────────────────────────────────
331 private int _count;
340 public int Count => _count;
349 public ObservableCollection<string> CounterLogs { get; } = new();
350
359 public void Increment()
360 {
361 _count++;
362 CounterLogs.Insert(0, $"[{DateTime.Now:HH:mm:ss}] Incremented → {_count}");
363 while (CounterLogs.Count > 10) CounterLogs.RemoveAt(CounterLogs.Count - 1);
364 Raise();
365 }
366
375 public void ResetCounter()
376 {
377 _count = 0;
378 CounterLogs.Insert(0, $"[{DateTime.Now:HH:mm:ss}] Counter reset.");
379 while (CounterLogs.Count > 10) CounterLogs.RemoveAt(CounterLogs.Count - 1);
380 Raise();
381 }
382
383 // -- DataGrid (static demo data) -----------------------
392 public ObservableCollection<GridRow> GridRows { get; } = new()
393 {
394 new() { No = 1, Name = "Device A", Status = "Running" },
395 new() { No = 2, Name = "Device B", Status = "Stopped" },
396 new() { No = 3, Name = "Device C", Status = "Running" },
397 new() { No = 4, Name = "Device D", Status = "Error" },
398 };
399
417 public GridRow? SelectedRow { get => _selectedRow; set { _selectedRow = value; Raise(); } }
418
419 // -- TimeSpinner (time selection) ----------------------
428 private int _hours = 9, _minutes = 30, _seconds = 0;
437 public int Hours { get => _hours; set { _hours = Math.Clamp(value, 0, 23); Raise(); } }
446 public int Minutes { get => _minutes; set { _minutes = Math.Clamp(value, 0, 59); Raise(); } }
455 public int Seconds { get => _seconds; set { _seconds = Math.Clamp(value, 0, 59); Raise(); } }
464 public string TimeDisplay => $"{_hours:D2}:{_minutes:D2}:{_seconds:D2}";
465
466 // -- DreamineImage (clickable image) -------------------
475 public int ImageClickCount { get; private set; }
484 public void ClickImage()
485 {
487 ActivityLog.Insert(0, $"[{DateTime.Now:HH:mm:ss}] Image clicked ({ImageClickCount})");
488 while (ActivityLog.Count > 8) ActivityLog.RemoveAt(ActivityLog.Count - 1);
489 Raise();
490 }
491
500 private void Raise() => OnPropertyChanged(string.Empty);
501}
502
511public class GridRow
512{
521 public int No { get; set; }
530 public string Name { get; set; } = string.Empty;
539 public string Status { get; set; } = string.Empty;
540}