From 830dfaaafb34f2b7a86b85b8808c541fecf9fd8e Mon Sep 17 00:00:00 2001
From: uye <99072975+ABA2396@users.noreply.github.com>
Date: Sun, 6 Apr 2025 22:56:30 +0800
Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E4=B8=B4=E6=97=B6=E5=AE=9A=E6=97=B6=20(#12243)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* chore: 添加一个临时定时
* chore: 定时器全部改成可单次执行
---
.../ViewModels/UI/TaskQueueViewModel.cs | 4 +-
.../Settings/TimerSettingsUserControlModel.cs | 23 +++++------
.../Settings/TimerSettingsUserControl.xaml | 40 +++++++++++++++----
3 files changed, 45 insertions(+), 22 deletions(-)
diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
index 2266b6d855..8341c3af9e 100644
--- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs
@@ -488,7 +488,7 @@ namespace MaaWpfGui.ViewModels.UI
for (int i = 0; i < 8; ++i)
{
- if (!SettingsViewModel.TimerSettings.TimerModels.Timers[i].IsOn)
+ if (SettingsViewModel.TimerSettings.TimerModels.Timers[i].IsOn == false)
{
continue;
}
@@ -547,6 +547,8 @@ namespace MaaWpfGui.ViewModels.UI
{
_logger.Information($"Scheduled start: Timer Index: {configIndex}");
await HandleScheduledStart(configIndex);
+
+ SettingsViewModel.TimerSettings.TimerModels.Timers[configIndex].IsOn ??= false;
}
}
diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/TimerSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/TimerSettingsUserControlModel.cs
index e2e2108ee9..9b4ab82868 100644
--- a/src/MaaWpfGui/ViewModels/UserControl/Settings/TimerSettingsUserControlModel.cs
+++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/TimerSettingsUserControlModel.cs
@@ -82,7 +82,7 @@ public class TimerSettingsUserControlModel : PropertyChangedBase
{
public class TimerProperties : PropertyChangedBase
{
- public TimerProperties(int timeId, bool isOn, int hour, int min, string? timerConfig)
+ public TimerProperties(int timeId, bool? isOn, int hour, int min, string? timerConfig)
{
TimerId = timeId;
_isOn = isOn;
@@ -102,17 +102,14 @@ public class TimerSettingsUserControlModel : PropertyChangedBase
private readonly string _timerName = LocalizationHelper.GetString("Timer");
- public string TimerName
- {
- get => $"{_timerName} {TimerId + 1}";
- }
+ public string TimerName => $"{_timerName} {TimerId + 1}";
- private bool _isOn;
+ private bool? _isOn;
///
/// Gets or sets a value indicating whether the timer is set.
///
- public bool IsOn
+ public bool? IsOn
{
get => _isOn;
set
@@ -174,12 +171,12 @@ public class TimerSettingsUserControlModel : PropertyChangedBase
{
for (int i = 0; i < 8; i++)
{
- Timers[i] = new TimerProperties(
- i,
- ConfigurationHelper.GetTimer(i, bool.FalseString) == bool.TrueString,
- int.Parse(ConfigurationHelper.GetTimerHour(i, $"{i * 3}")),
- int.Parse(ConfigurationHelper.GetTimerMin(i, "0")),
- ConfigurationHelper.GetTimerConfig(i, ConfigurationHelper.GetCurrentConfiguration()));
+ var timerState = ConfigurationHelper.GetTimer(i, bool.FalseString);
+ bool? isOn = bool.TryParse(timerState, out bool parsedBool) ? parsedBool : null;
+ var hour = int.Parse(ConfigurationHelper.GetTimerHour(i, $"{i * 3}"));
+ var minute = int.Parse(ConfigurationHelper.GetTimerMin(i, "0"));
+ var config = ConfigurationHelper.GetTimerConfig(i, ConfigurationHelper.GetCurrentConfiguration());
+ Timers[i] = new(i, isOn, hour, minute, config);
}
}
}
diff --git a/src/MaaWpfGui/Views/UserControl/Settings/TimerSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/Settings/TimerSettingsUserControl.xaml
index 85ddf7fa66..2e6768b1ee 100644
--- a/src/MaaWpfGui/Views/UserControl/Settings/TimerSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/Settings/TimerSettingsUserControl.xaml
@@ -87,7 +87,10 @@
+ IsChecked="{Binding TimerModels.Timers[0].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[1].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[2].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[3].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[4].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[5].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[6].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />
+ IsChecked="{Binding TimerModels.Timers[7].IsOn}"
+ MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
+ Target={x:Type helper:CheckBoxHelper}}"
+ ToolTip="{DynamicResource CheckBoxesNotSaved}" />