diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 2790c9e42a..8155cd911c 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -638,6 +638,7 @@ namespace MaaWpfGui.Main _latestTaskId.Clear(); Instances.TaskQueueViewModel.ResetFightVariables(); + Instances.TaskQueueViewModel.ResetTaskSelection(); _runningState.SetIdle(true); Instances.RecognizerViewModel.GachaDone = true; diff --git a/src/MaaWpfGui/ViewModels/DragItemViewModel.cs b/src/MaaWpfGui/ViewModels/DragItemViewModel.cs index 25f7c5c955..4099dd3a7e 100644 --- a/src/MaaWpfGui/ViewModels/DragItemViewModel.cs +++ b/src/MaaWpfGui/ViewModels/DragItemViewModel.cs @@ -49,7 +49,7 @@ namespace MaaWpfGui.ViewModels Name = name; OriginalName = originalName; _storageKey = storageKey; - _isChecked = Convert.ToBoolean(ConfigurationHelper.GetCheckedStorage(storageKey, originalName, bool.TrueString)); + IsChecked = Convert.ToBoolean(ConfigurationHelper.GetCheckedStorage(storageKey, originalName, bool.TrueString)); } private string _originalName; @@ -74,19 +74,29 @@ namespace MaaWpfGui.ViewModels set => SetAndNotify(ref _name, value); } - private bool _isChecked; + private bool? _isCheckedWithNull; + + /// + /// Gets or sets a value indicating whether gets or sets whether the key is checked with null. + /// + public bool? IsCheckedWithNull + { + get => _isCheckedWithNull; + set + { + SetAndNotify(ref _isCheckedWithNull, value); + value ??= false; + ConfigurationHelper.SetCheckedStorage(_storageKey, OriginalName, value.ToString()); + } + } /// /// Gets or sets a value indicating whether gets or sets whether the key is checked. /// public bool IsChecked { - get => _isChecked; - set - { - SetAndNotify(ref _isChecked, value); - ConfigurationHelper.SetCheckedStorage(_storageKey, OriginalName, value.ToString()); - } + get => IsCheckedWithNull != false; + set => IsCheckedWithNull = value; } // 换成图标的话要这个,暂时没用 diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index f66d1e087d..8ec44e77fe 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -342,6 +342,7 @@ namespace MaaWpfGui.ViewModels.UI } ResetFightVariables(); + ResetTaskSelection(); RefreshCustomInfrastPlanIndexByPeriod(); } @@ -751,6 +752,20 @@ namespace MaaWpfGui.ViewModels.UI } } + /// + /// Reset unsaved task selection. + /// + public void ResetTaskSelection() + { + foreach (var item in TaskItemViewModels) + { + if (item.IsCheckedWithNull == null) + { + item.IsChecked = false; + } + } + } + private async Task ConnectToEmulator() { string errMsg = string.Empty; diff --git a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml index f933e52568..df82324784 100644 --- a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml +++ b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml @@ -7,6 +7,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:dd="urn:gong-wpf-dragdrop" xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:helper="clr-namespace:MaaWpfGui.Helper" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:properties="clr-namespace:MaaWpfGui.Styles.Properties" xmlns:s="https://github.com/canton7/Stylet" @@ -68,8 +69,11 @@ Grid.ColumnSpan="2" HorizontalAlignment="Left" Content="{Binding Name}" - IsChecked="{Binding IsChecked}" - IsHitTestVisible="{Binding ElementName=TaskList, Path=DataContext.Idle}" /> + IsChecked="{Binding IsCheckedWithNull}" + IsHitTestVisible="{Binding ElementName=TaskList, Path=DataContext.Idle}" + MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick, + Target={x:Type helper:CheckBoxHelper}}" + ToolTip="{DynamicResource CheckBoxesNotSavedAsNull}" />