-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddTaskWindow.xaml.cs
More file actions
630 lines (538 loc) · 26.5 KB
/
AddTaskWindow.xaml.cs
File metadata and controls
630 lines (538 loc) · 26.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows;
using System.Windows.Input; // Required for MouseButtonEventArgs, MouseButtonState
using System.Windows.Controls;
using System.Threading.Tasks; // For async operations
namespace TimeTask
{
// Removed duplicate namespace declaration
public partial class AddTaskWindow : Window
{
public sealed class DraftSmartSuggestion
{
public string NormalizedDescription { get; set; }
public double TaskLikelihoodScore { get; set; }
public bool IsPotentialTask { get; set; }
public string Importance { get; set; }
public string Urgency { get; set; }
public int SuggestedQuadrantIndex { get; set; } = -1;
public DateTime? SuggestedReminderTime { get; set; }
}
private LlmService _llmService;
private DatabaseService _databaseService;
private bool _isClarificationRound = false; // State for clarification
private string _originalTaskDescription = string.Empty; // To store original task if clarification is needed
private bool _isLlmConfigErrorNotified = false; // Flag to track if user has been notified of LLM config error
private readonly IntentRecognizer _intentRecognizer = new IntentRecognizer();
private bool _reminderEditedByUser;
private bool _quadrantEditedByUser;
private bool _isUpdatingReminderControls;
private bool _isUpdatingQuadrantSelection;
private bool _autoReminderApplied;
public string TaskDescription { get; private set; }
public int SelectedListIndex { get; private set; } // 0-indexed
public bool TaskAdded { get; private set; } = false; // Renamed from IsTaskAdded for clarity
public ItemGrid NewTask { get; private set; } // The newly created task object
// 预填充任务描述(用于从草稿添加)
private string _preFilledDescription = null;
private string _preFilledQuadrant = null;
private bool _skipClarificationForPrefilled = true;
// 兼容旧版本的构造函数
public AddTaskWindow(DatabaseService databaseService, LlmService llmService, int? defaultQuadrantIndex = null)
{
InitializeComponent();
_databaseService = databaseService ?? throw new ArgumentNullException(nameof(databaseService));
_llmService = llmService ?? throw new ArgumentNullException(nameof(llmService));
InitializeCombobox(defaultQuadrantIndex);
}
// 兼容旧版本:只传 LlmService
public AddTaskWindow(LlmService llmService, int? defaultQuadrantIndex = null)
{
InitializeComponent();
_llmService = llmService ?? throw new ArgumentNullException(nameof(llmService));
_databaseService = null;
InitializeCombobox(defaultQuadrantIndex);
}
private void InitializeCombobox(int? defaultQuadrantIndex)
{
// Populate ComboBox
ListSelectorComboBox.ItemsSource = new List<string> {
I18n.T("Quadrant_ImportantUrgent"),
I18n.T("Quadrant_ImportantNotUrgent"),
I18n.T("Quadrant_NotImportantUrgent"),
I18n.T("Quadrant_NotImportantNotUrgent")
};
ListSelectorComboBox.SelectedIndex = 0; // Default to "重要且紧急"
// Pre-select based on defaultQuadrantIndex if provided
if (defaultQuadrantIndex.HasValue)
{
if (defaultQuadrantIndex.Value >= 0 && defaultQuadrantIndex.Value < ListSelectorComboBox.Items.Count)
{
ListSelectorComboBox.SelectedIndex = defaultQuadrantIndex.Value;
}
}
// Populate Reminder Time ComboBoxes
for (int i = 0; i < 24; i++) ReminderHourComboBox.Items.Add(i.ToString("D2"));
for (int i = 0; i < 60; i++) ReminderMinuteComboBox.Items.Add(i.ToString("D2"));
// Set default selections
EnableReminderCheckBox.IsChecked = false;
ReminderDatePicker.SelectedDate = DateTime.Today;
ReminderHourComboBox.SelectedIndex = 0; // Default to "00"
ReminderMinuteComboBox.SelectedIndex = 0; // Default to "00"
RefreshSmartAssistant();
}
/// <summary>
/// 预填充任务描述(用于从草稿添加)
/// </summary>
public void SetPreFilledTask(string description, string quadrant)
{
if (!string.IsNullOrWhiteSpace(description))
{
_preFilledDescription = description;
TaskDescriptionTextBox.Text = description;
}
if (!string.IsNullOrWhiteSpace(quadrant))
{
_preFilledQuadrant = quadrant;
// 映射象限名称到索引
var quadrantMap = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
{
{ "重要且紧急", 0 },
{ "重要不紧急", 1 },
{ "不重要但紧急", 2 },
{ "不重要紧急", 2 }, // 兼容不同表述
{ "不重要不紧急", 3 },
{ "Important & Urgent", 0 },
{ "Important & Not Urgent", 1 },
{ "Not Important but Urgent", 2 },
{ "Not Important & Urgent", 2 },
{ "Not Important & Not Urgent", 3 },
{ I18n.T("Quadrant_ImportantUrgent"), 0 },
{ I18n.T("Quadrant_ImportantNotUrgent"), 1 },
{ I18n.T("Quadrant_NotImportantUrgent"), 2 },
{ I18n.T("Quadrant_NotImportantNotUrgent"), 3 }
};
if (quadrantMap.TryGetValue(quadrant, out int index))
{
_quadrantEditedByUser = false;
ListSelectorComboBox.SelectedIndex = index;
}
}
RefreshSmartAssistant();
}
// Removed older synchronous AddTaskButton_Click method. The async version below is used.
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void ResetClarificationButton_Click(object sender, RoutedEventArgs e)
{
TaskDescriptionTextBox.Text = _originalTaskDescription; // Restore original text
ClarificationBorder.Visibility = Visibility.Collapsed; // Changed
// ClarificationPromptText.Visibility = Visibility.Collapsed; // Old
// ResetClarificationButton.Visibility = Visibility.Collapsed; // Old
AddTaskButton.Content = I18n.T("AddTask_ButtonAdd");
_isClarificationRound = false;
TaskDescriptionTextBox.Focus(); // Set focus back to the textbox
}
private async void AddTaskButton_Click(object sender, RoutedEventArgs e)
{
string currentTaskDescription = NormalizeTaskText(TaskDescriptionTextBox.Text);
SelectedListIndex = ListSelectorComboBox.SelectedIndex;
string configErrorSubstring = "LLM dummy response (Configuration Error: API key missing or placeholder)";
if (string.IsNullOrWhiteSpace(currentTaskDescription))
{
MessageBox.Show(I18n.T("AddTask_ErrorEmptyDescription"), I18n.T("AddTask_TitleValidationError"), MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
if (SelectedListIndex < 0)
{
MessageBox.Show(I18n.T("AddTask_ErrorSelectList"), I18n.T("AddTask_TitleValidationError"), MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
// Disable buttons during processing
AddTaskButton.IsEnabled = false;
CancelButton.IsEnabled = false;
try
{
if (!_isClarificationRound && !(_skipClarificationForPrefilled && !string.IsNullOrWhiteSpace(_preFilledDescription)))
{
// Initial Submission: Analyze Clarity
_originalTaskDescription = currentTaskDescription; // Save for potential reset
var (status, question) = await _llmService.AnalyzeTaskClarityAsync(currentTaskDescription);
// Check for LLM configuration error after clarity analysis
// string configErrorSubstring is now defined at the beginning of the method
if (!_isLlmConfigErrorNotified && question != null && question.Contains(configErrorSubstring))
{
MessageBox.Show(I18n.T("AddTask_LlmConfigIssueText"),
I18n.T("AddTask_LlmConfigIssueTitle"), MessageBoxButton.OK, MessageBoxImage.Warning);
_isLlmConfigErrorNotified = true;
}
if (status == ClarityStatus.NeedsClarification)
{
ClarificationPromptText.Text = question; // This still needs to be set
ClarificationBorder.Visibility = Visibility.Visible; // Changed
// ClarificationPromptText.Visibility = Visibility.Visible; // Old
// ResetClarificationButton.Visibility = Visibility.Visible; // Old
AddTaskButton.Content = I18n.T("AddTask_ButtonSubmitClarified");
_isClarificationRound = true;
TaskDescriptionTextBox.Focus(); // Focus on textbox for user to edit
return; // Wait for user to clarify
}
// If Clear or Unknown, proceed directly to prioritization
}
// Prioritization & Task Creation (either directly or after clarification)
TaskDescription = currentTaskDescription; // Final task description
var (llmImportance, llmUrgency) = await _llmService.GetTaskPriorityAsync(TaskDescription);
var (ruleImportance, ruleUrgency) = _intentRecognizer.EstimatePriority(TaskDescription);
// Check for LLM configuration error after priority analysis
// string configErrorSubstring has been defined above
if (!_isLlmConfigErrorNotified &&
((llmImportance != null && llmImportance.Contains(configErrorSubstring)) ||
(llmUrgency != null && llmUrgency.Contains(configErrorSubstring))))
{
MessageBox.Show(I18n.T("AddTask_LlmConfigIssueText"),
I18n.T("AddTask_LlmConfigIssueTitle"), MessageBoxButton.OK, MessageBoxImage.Warning);
_isLlmConfigErrorNotified = true;
}
// --- LLM Suggestion Logic ---
var (finalImportanceByAi, finalUrgencyByAi, sourceTag) = MergePriority(llmImportance, llmUrgency, ruleImportance, ruleUrgency);
int suggestedIndex = GetIndexFromPriority(finalImportanceByAi, finalUrgencyByAi);
if (suggestedIndex >= 0)
{
ListSelectorComboBox.SelectedIndex = suggestedIndex;
}
if (suggestedIndex != -1 && suggestedIndex < ListSelectorComboBox.Items.Count)
{
string label = ListSelectorComboBox.Items[suggestedIndex] as string;
LlmSuggestionText.Text = I18n.Tf("AddTask_SuggestionFormat", sourceTag, label);
LlmSuggestionText.Visibility = Visibility.Visible;
}
else
{
LlmSuggestionText.Text = I18n.T("AddTask_SuggestionUnavailable");
LlmSuggestionText.Visibility = Visibility.Collapsed;
}
// --- End LLM Suggestion Logic ---
// User confirms or changes selection, then clicks "Add Task" again (or it's the first time)
// The final selection is captured by:
SelectedListIndex = ListSelectorComboBox.SelectedIndex;
// This line was already here, but its role is now more significant
// Update NewTask's Importance and Urgency based on the final ComboBox selection
var (finalImportance, finalUrgency) = GetPriorityFromIndex(SelectedListIndex);
DateTime? reminderTime = null;
if (EnableReminderCheckBox.IsChecked == true && ReminderDatePicker.SelectedDate.HasValue)
{
DateTime date = ReminderDatePicker.SelectedDate.Value;
int hour = 0;
int minute = 0;
if (ReminderHourComboBox.SelectedItem != null && int.TryParse(ReminderHourComboBox.SelectedItem.ToString(), out int h))
{
hour = h;
}
if (ReminderMinuteComboBox.SelectedItem != null && int.TryParse(ReminderMinuteComboBox.SelectedItem.ToString(), out int m))
{
minute = m;
}
// Ensure hour and minute are parsed successfully, otherwise they remain 0 or previously parsed value.
// A more robust solution might involve explicit validation here if 00:00 is not always a desired default.
reminderTime = new DateTime(date.Year, date.Month, date.Day, hour, minute, 0);
}
NewTask = new ItemGrid
{
Task = TaskDescription,
Importance = finalImportance, // Updated based on final selection
Urgency = finalUrgency, // Updated based on final selection
Score = 0, // Default score
IsActive = true,
CreatedDate = DateTime.Now,
LastModifiedDate = DateTime.Now,
Result = string.Empty,
ReminderTime = reminderTime
};
TaskAdded = true;
this.DialogResult = true;
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(I18n.Tf("AddTask_ErrorOccurredFormat", ex.Message), I18n.T("Title_Error"), MessageBoxButton.OK, MessageBoxImage.Error);
// Consider how to handle state if error occurs mid-process
// For now, re-enable buttons and let user retry or cancel
}
finally
{
AddTaskButton.IsEnabled = true;
CancelButton.IsEnabled = true;
}
}
// Helper method to map priority to ComboBox index
public static int GetIndexFromPriority(string importance, string urgency)
{
string imp = NormalizeImportanceToken(importance);
string urg = NormalizeUrgencyToken(urgency);
if (imp == "high" && urg == "high") return 0; // Important & Urgent
if (imp == "high" && urg == "low") return 1; // Important & Not Urgent
if (imp == "low" && urg == "high") return 2; // Not Important & Urgent
if (imp == "low" && urg == "low") return 3; // Not Important & Not Urgent
return -1;
}
private static string NormalizeImportanceToken(string value)
{
if (string.IsNullOrWhiteSpace(value))
return "unknown";
string v = value.Trim().ToLowerInvariant();
if (v == "high" || v == "高" || v == "重要" || v == "high importance")
return "high";
if (v == "low" || v == "低" || v == "不重要" || v == "low importance")
return "low";
if (v.Contains("important") && !v.Contains("not important"))
return "high";
if (v.Contains("not important"))
return "low";
return "unknown";
}
private static string NormalizeUrgencyToken(string value)
{
if (string.IsNullOrWhiteSpace(value))
return "unknown";
string v = value.Trim().ToLowerInvariant();
if (v == "high" || v == "高" || v == "紧急" || v == "urgent" || v == "high urgency")
return "high";
if (v == "low" || v == "低" || v == "不紧急" || v == "not urgent" || v == "low urgency")
return "low";
if (v.Contains("not urgent") || v.Contains("不紧急"))
return "low";
if (v.Contains("urgent") || (v.Contains("紧急") && !v.Contains("不紧急")))
return "high";
return "unknown";
}
// Helper method to map ComboBox index back to Importance/Urgency strings
public static (string Importance, string Urgency) GetPriorityFromIndex(int index)
{
switch (index)
{
case 0: return ("High", "High"); // Important & Urgent
case 1: return ("High", "Low"); // Important & Not Urgent
case 2: return ("Low", "High"); // Not Important & Urgent
case 3: return ("Low", "Low"); // Not Important & Not Urgent
default: return ("Medium", "Medium"); // Default if index is unexpected
}
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private static bool IsKnownPriority(string value)
{
if (string.IsNullOrWhiteSpace(value))
return false;
string v = value.Trim().ToLowerInvariant();
return v == "high" || v == "medium" || v == "low";
}
private (string importance, string urgency, string sourceTag) MergePriority(
string llmImportance,
string llmUrgency,
string ruleImportance,
string ruleUrgency)
{
bool llmValid = IsKnownPriority(llmImportance) && IsKnownPriority(llmUrgency)
&& !ContainsDummy(llmImportance)
&& !ContainsDummy(llmUrgency);
if (llmValid)
{
return (llmImportance, llmUrgency, I18n.T("AddTask_SourceLlm"));
}
bool ruleValid = IsKnownPriority(ruleImportance) && IsKnownPriority(ruleUrgency);
if (ruleValid)
{
return (ruleImportance, ruleUrgency, I18n.T("AddTask_SourceRule"));
}
return ("Medium", "Low", I18n.T("AddTask_SourceDefault"));
}
private static bool ContainsDummy(string value)
{
return !string.IsNullOrWhiteSpace(value) &&
value.IndexOf("dummy response", StringComparison.OrdinalIgnoreCase) >= 0;
}
public static DraftSmartSuggestion AnalyzeDraftInput(string rawText, DateTime now)
{
var recognizer = new IntentRecognizer();
var parser = new VoiceReminderTimeParser();
string normalized = string.IsNullOrWhiteSpace(rawText) ? string.Empty : rawText.Trim();
string extracted = recognizer.ExtractTaskDescription(normalized);
if (!string.IsNullOrWhiteSpace(extracted))
{
normalized = extracted.Trim();
}
var suggestion = new DraftSmartSuggestion
{
NormalizedDescription = normalized,
TaskLikelihoodScore = recognizer.ScoreTaskLikelihood(rawText),
IsPotentialTask = recognizer.IsPotentialTask(rawText)
};
if (!string.IsNullOrWhiteSpace(normalized))
{
var (importance, urgency) = recognizer.EstimatePriority(normalized);
suggestion.Importance = importance;
suggestion.Urgency = urgency;
suggestion.SuggestedQuadrantIndex = GetIndexFromPriority(importance, urgency);
}
if (parser.TryParse(rawText, now, out DateTime reminderTime))
{
suggestion.SuggestedReminderTime = reminderTime;
}
return suggestion;
}
private string NormalizeTaskText(string raw)
{
if (string.IsNullOrWhiteSpace(raw))
return string.Empty;
string trimmed = raw.Trim();
string extracted = _intentRecognizer.ExtractTaskDescription(trimmed);
if (!string.IsNullOrWhiteSpace(extracted))
{
return extracted.Trim();
}
return trimmed;
}
private void TaskDescriptionTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
RefreshSmartAssistant();
}
private void ReminderInput_Changed(object sender, RoutedEventArgs e)
{
if (!_isUpdatingReminderControls)
{
_reminderEditedByUser = true;
}
UpdatePreviewSummary();
}
private void ListSelectorComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!_isUpdatingQuadrantSelection)
{
_quadrantEditedByUser = true;
}
UpdatePreviewSummary();
}
private void RefreshSmartAssistant()
{
var suggestion = AnalyzeDraftInput(TaskDescriptionTextBox.Text, DateTime.Now);
if (string.IsNullOrWhiteSpace(suggestion.NormalizedDescription))
{
SmartAssistantBorder.Visibility = Visibility.Collapsed;
if (_autoReminderApplied && !_reminderEditedByUser)
{
ApplyReminderTime(null);
_autoReminderApplied = false;
}
return;
}
SmartAssistantBorder.Visibility = Visibility.Visible;
SmartTaskSignalText.Text = suggestion.IsPotentialTask
? I18n.Tf("AddTask_SmartTaskSignalStrongFormat", Math.Round(suggestion.TaskLikelihoodScore * 100))
: I18n.Tf("AddTask_SmartTaskSignalWeakFormat", Math.Round(suggestion.TaskLikelihoodScore * 100));
string quadrantLabel = suggestion.SuggestedQuadrantIndex >= 0 && suggestion.SuggestedQuadrantIndex < ListSelectorComboBox.Items.Count
? ListSelectorComboBox.Items[suggestion.SuggestedQuadrantIndex] as string
: I18n.T("AddTask_SmartQuadrantUnavailable");
SmartQuadrantSuggestionText.Text = I18n.Tf("AddTask_SmartQuadrantFormat", quadrantLabel);
if (suggestion.SuggestedReminderTime.HasValue)
{
SmartReminderSuggestionText.Text = I18n.Tf(
"AddTask_SmartReminderDetectedFormat",
suggestion.SuggestedReminderTime.Value.ToString("yyyy-MM-dd HH:mm", I18n.CurrentCulture));
if (!_reminderEditedByUser)
{
ApplyReminderTime(suggestion.SuggestedReminderTime);
_autoReminderApplied = true;
}
}
else
{
SmartReminderSuggestionText.Text = I18n.T("AddTask_SmartReminderNone");
if (_autoReminderApplied && !_reminderEditedByUser)
{
ApplyReminderTime(null);
_autoReminderApplied = false;
}
}
if (suggestion.SuggestedQuadrantIndex >= 0 && !_quadrantEditedByUser)
{
_isUpdatingQuadrantSelection = true;
try
{
ListSelectorComboBox.SelectedIndex = suggestion.SuggestedQuadrantIndex;
}
finally
{
_isUpdatingQuadrantSelection = false;
}
}
UpdatePreviewSummary();
}
private void ApplyReminderTime(DateTime? reminderTime)
{
_isUpdatingReminderControls = true;
try
{
if (reminderTime.HasValue)
{
EnableReminderCheckBox.IsChecked = true;
ReminderDatePicker.SelectedDate = reminderTime.Value.Date;
ReminderHourComboBox.SelectedItem = reminderTime.Value.Hour.ToString("D2", CultureInfo.InvariantCulture);
ReminderMinuteComboBox.SelectedItem = reminderTime.Value.Minute.ToString("D2", CultureInfo.InvariantCulture);
}
else
{
EnableReminderCheckBox.IsChecked = false;
ReminderDatePicker.SelectedDate = DateTime.Today;
ReminderHourComboBox.SelectedIndex = 0;
ReminderMinuteComboBox.SelectedIndex = 0;
}
}
finally
{
_isUpdatingReminderControls = false;
}
}
private void UpdatePreviewSummary()
{
string quadrantText = ListSelectorComboBox.SelectedItem as string ?? I18n.T("AddTask_SmartQuadrantUnavailable");
DateTime? selectedReminder = GetReminderTimeFromControls();
SmartPreviewText.Text = selectedReminder.HasValue
? I18n.Tf("AddTask_SmartPreviewFormat", quadrantText, selectedReminder.Value.ToString("yyyy-MM-dd HH:mm", I18n.CurrentCulture))
: I18n.Tf("AddTask_SmartPreviewNoReminderFormat", quadrantText);
}
private DateTime? GetReminderTimeFromControls()
{
if (EnableReminderCheckBox.IsChecked != true || !ReminderDatePicker.SelectedDate.HasValue)
{
return null;
}
int hour = 0;
int minute = 0;
if (ReminderHourComboBox.SelectedItem != null)
{
int.TryParse(ReminderHourComboBox.SelectedItem.ToString(), out hour);
}
if (ReminderMinuteComboBox.SelectedItem != null)
{
int.TryParse(ReminderMinuteComboBox.SelectedItem.ToString(), out minute);
}
DateTime date = ReminderDatePicker.SelectedDate.Value;
return new DateTime(date.Year, date.Month, date.Day, hour, minute, 0);
}
}
} // Closing brace for namespace TimeTask