From 7418d3f8c1dd8fbb95e8ce2cc9f0f8dd533edd3c Mon Sep 17 00:00:00 2001
From: uye <99072975+ABA2396@users.noreply.github.com>
Date: Wed, 13 Dec 2023 11:14:14 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8F=AF=E4=BB=A5=E9=80=9A=E8=BF=87?=
=?UTF-8?q?=E5=8F=B3=E9=94=AE=E9=80=89=E6=8B=A9=E4=BB=85=E8=BF=90=E8=A1=8C?=
=?UTF-8?q?=E4=B8=80=E6=AC=A1=E4=BB=BB=E5=8A=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fix #7528
---
src/MaaWpfGui/Main/AsstProxy.cs | 1 +
src/MaaWpfGui/ViewModels/DragItemViewModel.cs | 26 +++++++++++++------
.../ViewModels/UI/TaskQueueViewModel.cs | 15 +++++++++++
src/MaaWpfGui/Views/UI/TaskQueueView.xaml | 8 ++++--
4 files changed, 40 insertions(+), 10 deletions(-)
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}" />