SampleCrossUi.Shared 1.0.0.0
SampleCrossUi.Shared 사용 방법을 보여 주는 예제 프로젝트입니다.
로딩중...
검색중...
일치하는것 없음
ControlsEvent.cs
이 파일의 문서화 페이지로 가기
1using System;
2using System.Collections.ObjectModel;
3
5
14public sealed class ControlsEvent
15{
24 public event EventHandler? Changed;
25
42 private void Raise(string status)
43 {
44 StatusMessage = status;
45 Changed?.Invoke(this, EventArgs.Empty);
46 }
47
48 // ── Button ────────────────────────────────────────────
57 public int ClickCount { get; private set; }
58
67 public ObservableCollection<string> ActivityLog { get; } = new();
68
77 public void ClickMe()
78 {
79 ClickCount++;
80 ActivityLog.Add($"[{DateTime.Now:HH:mm:ss}] Clicked ({ClickCount})");
81 Raise($"Button clicked {ClickCount} time(s)");
82 }
83
84 // ── RadioButton ───────────────────────────────────────
93 public string SelectedRadio { get; private set; } = "Option A";
94
111 public void SelectRadio(string? option)
112 {
113 SelectedRadio = option ?? string.Empty;
114 Raise($"Radio selected: {SelectedRadio}");
115 }
116
117 // ── CheckLed ──────────────────────────────────────────
126 public bool LedIsOn { get; private set; } = true;
135 public bool LedIsPulse { get; private set; }
136
145 public void ToggleLed()
146 {
147 LedIsOn = !LedIsOn;
148 Raise($"LED is {(LedIsOn ? "ON" : "OFF")}");
149 }
150
159 public void TogglePulse()
160 {
162 Raise($"Pulse is {(LedIsPulse ? "ON" : "OFF")}");
163 }
164
165 // ── TextBox / PasswordBox ─────────────────────────────
166 // 사용자가 직접 타이핑하는 값이라 Changed 이벤트로 묶지 않고
167 // ViewModel 래퍼 프로퍼티가 개별적으로 OnPropertyChanged를 호출한다(타이핑 중 포커스/캐럿 튐 방지).
176 public string TextInput { get; set; } = string.Empty;
185 public string Password { get; set; } = string.Empty;
186
195 public void ClearText()
196 {
197 TextInput = string.Empty;
198 Raise("TextBox cleared");
199 }
200
209 public void ClearPassword()
210 {
211 Password = string.Empty;
212 Raise("Password cleared");
213 }
214
215 // ── ListBox 활성화(더블클릭) ───────────────────────────
232 public void ListBoxActivated(string? item)
233 {
234 Raise($"List item activated: {item}");
235 }
236
237 // ── Status ────────────────────────────────────────────
246 public string StatusMessage { get; private set; } = "Ready";
247}
ObservableCollection< string > ActivityLog