Dreamine.UI.Wpf.Controls 1.0.1
Dreamine.UI.Wpf.Controls 사용자 인터페이스 기능과 구성 요소를 제공합니다.
로딩중...
검색중...
일치하는것 없음
DreamineCheckSelector.xaml.cs
이 파일의 문서화 페이지로 가기
1using System.Windows;
2using System.Windows.Controls;
3using System.Windows.Input;
4
6{
15 public partial class DreamineCheckSelector : UserControl
16 {
17 // ---------------------------------------------------------------------
18 // \brief Command
19 // ---------------------------------------------------------------------
20
29 public static readonly DependencyProperty CommandProperty =
30 DependencyProperty.Register(
31 nameof(Command),
32 typeof(ICommand),
34 new PropertyMetadata(null));
35
44 public ICommand? Command
45 {
46 get => (ICommand?)GetValue(CommandProperty);
47 set => SetValue(CommandProperty, value);
48 }
49
50 // -- Remembers the last State of the Left/Right radio buttons
59 private bool _lastLeftChecked = true;
68 private bool _lastRightChecked = false;
69
78 public event RoutedEventHandler ValueChanged = null!;
79
89 {
90 InitializeComponent();
91
92 PART_CheckBox.Checked += (s, e) => OnCheckedChanged(true);
93 PART_CheckBox.Unchecked += (s, e) => OnCheckedChanged(false);
94
95 PART_RadioLeft.Checked += (s, e) => { RememberRadio(true); RaiseValueChanged(); };
96 PART_RadioRight.Checked += (s, e) => { RememberRadio(false); RaiseValueChanged(); };
97
98 PART_AxisMaxBox.LostFocus += (s, e) => RaiseValueChanged();
99 PART_AxisMaxBox.KeyDown += (s, e) => { if (((KeyEventArgs)e).Key == Key.Enter) RaiseValueChanged(); };
100 }
101
118 private void OnCheckedChanged(bool isChecked)
119 {
120 if (isChecked)
121 {
123 {
126 }
127 else
128 {
131 }
132 }
133 else
134 {
137
138 IsLeftChecked = false;
139 IsRightChecked = false;
140 }
142 }
143
160 private void RememberRadio(bool left)
161 {
162 _lastLeftChecked = left;
163 _lastRightChecked = !left;
164 }
165
174 private void RaiseValueChanged()
175 {
176 // 기존 RoutedEvent
177 ValueChanged?.Invoke(this, new RoutedEventArgs());
178
179 // MVVM Command 실행
180 if (Command?.CanExecute(this) == true)
181 Command.Execute(this);
182 }
183
184
193 public static readonly DependencyProperty IsCheckedProperty =
194 DependencyProperty.Register(nameof(IsChecked), typeof(bool), typeof(DreamineCheckSelector), new PropertyMetadata(false));
195
204 public bool IsChecked
205 {
206 get => (bool)GetValue(IsCheckedProperty);
207 set => SetValue(IsCheckedProperty, value);
208 }
209
218 public static readonly DependencyProperty IsLeftCheckedProperty =
219 DependencyProperty.Register(nameof(IsLeftChecked), typeof(bool), typeof(DreamineCheckSelector), new PropertyMetadata(false));
220
229 public bool IsLeftChecked
230 {
231 get => (bool)GetValue(IsLeftCheckedProperty);
232 set => SetValue(IsLeftCheckedProperty, value);
233 }
234
243 public static readonly DependencyProperty IsRightCheckedProperty =
244 DependencyProperty.Register(nameof(IsRightChecked), typeof(bool), typeof(DreamineCheckSelector), new PropertyMetadata(false));
245
254 public bool IsRightChecked
255 {
256 get => (bool)GetValue(IsRightCheckedProperty);
257 set => SetValue(IsRightCheckedProperty, value);
258 }
259
268 public static readonly DependencyProperty CheckTextProperty =
269 DependencyProperty.Register(nameof(CheckText), typeof(string), typeof(DreamineCheckSelector), new PropertyMetadata("체크"));
270
279 public string CheckText
280 {
281 get => (string)GetValue(CheckTextProperty);
282 set => SetValue(CheckTextProperty, value);
283 }
284
293 public static readonly DependencyProperty LeftRadioTextProperty =
294 DependencyProperty.Register(nameof(LeftRadioText), typeof(string), typeof(DreamineCheckSelector), new PropertyMetadata("LEFT"));
295
304 public string LeftRadioText
305 {
306 get => (string)GetValue(LeftRadioTextProperty);
307 set => SetValue(LeftRadioTextProperty, value);
308 }
309
318 public static readonly DependencyProperty RightRadioTextProperty =
319 DependencyProperty.Register(nameof(RightRadioText), typeof(string), typeof(DreamineCheckSelector), new PropertyMetadata("RIGHT"));
320
329 public string RightRadioText
330 {
331 get => (string)GetValue(RightRadioTextProperty);
332 set => SetValue(RightRadioTextProperty, value);
333 }
334
343 public static readonly DependencyProperty GroupNameProperty =
344 DependencyProperty.Register(nameof(GroupName), typeof(string), typeof(DreamineCheckSelector), new PropertyMetadata("AxisSelectorGroup"));
345
354 public string GroupName
355 {
356 get => (string)GetValue(GroupNameProperty);
357 set => SetValue(GroupNameProperty, value);
358 }
359
368 public static readonly DependencyProperty AxisMaxProperty =
369 DependencyProperty.Register(nameof(AxisMax), typeof(string), typeof(DreamineCheckSelector), new PropertyMetadata("20"));
370
379 public string AxisMax
380 {
381 get => (string)GetValue(AxisMaxProperty);
382 set => SetValue(AxisMaxProperty, value);
383 }
384 }
385}