Dreamine.UI.Maui 1.0.1
Windows(WinUI)의 네이티브 `CheckBox`는 `WidthRequest`로 줄일 수 없는 거대한 최소 너비를 가져서 라벨과의 간격이 벌어지는 문제가 있어, 처음부터 직접 그려서 만들었습니다.
로딩중...
검색중...
일치하는것 없음
DreamineMessageBoxPage.xaml.cs
이 파일의 문서화 페이지로 가기
2
19public partial class DreamineMessageBoxPage : ContentPage
20{
29 private readonly TaskCompletionSource<DreamineDialogResult> _tcs = new();
38 private IDispatcherTimer? _autoClickTimer;
65 private string _baseMessage = string.Empty;
66
75 public Task<DreamineDialogResult> ResultTask => _tcs.Task;
76
134 string title,
135 string message,
136 IReadOnlyList<(DreamineDialogResult Result, string Text)> buttons,
138 int autoClickDelaySeconds = 0)
139 {
140 InitializeComponent();
141
142 TitleLabel.Text = title;
143 MessageLabel.Text = message;
144 _autoClickResult = autoClick;
145
146 foreach (var (result, text) in buttons)
147 {
148 var button = new Button
149 {
150 Text = text,
151 BackgroundColor = Color.FromArgb("#0D1B3E"),
152 TextColor = Colors.White,
153 CornerRadius = 6,
154 WidthRequest = 90,
155 HeightRequest = 36
156 };
157 button.Clicked += (_, _) => Complete(result);
158 ButtonRow.Children.Add(button);
159 }
160
161 if (autoClickDelaySeconds > 0 && autoClick != DreamineDialogResult.None)
162 {
163 _autoClickRemainingSeconds = autoClickDelaySeconds;
164 _baseMessage = message;
166
167 _autoClickTimer = Dispatcher.CreateTimer();
168 _autoClickTimer.Interval = TimeSpan.FromSeconds(1);
169 _autoClickTimer.Tick += (_, _) =>
170 {
173 {
174 _autoClickTimer?.Stop();
176 }
177 else
178 {
180 }
181 };
182 _autoClickTimer.Start();
183 }
184 }
185
194 private void UpdateCountdownText()
195 => MessageLabel.Text = $"{_baseMessage}\n\n({_autoClickRemainingSeconds}초 후 자동으로 닫힙니다)";
196
213 private void Complete(DreamineDialogResult result)
214 {
215 _autoClickTimer?.Stop();
216 if (!_tcs.Task.IsCompleted)
217 _tcs.SetResult(result);
218
219 Navigation.PopModalAsync(animated: false);
220 }
221}
readonly TaskCompletionSource< DreamineDialogResult > _tcs
DreamineMessageBoxPage(string title, string message, IReadOnlyList<(DreamineDialogResult Result, string Text)> buttons, DreamineDialogResult autoClick=DreamineDialogResult.None, int autoClickDelaySeconds=0)