feat: 可以通过右键选择仅运行一次任务

fix #7528
This commit is contained in:
uye
2023-12-13 11:14:14 +08:00
parent 30f654bb0c
commit 7418d3f8c1
4 changed files with 40 additions and 10 deletions

View File

@@ -638,6 +638,7 @@ namespace MaaWpfGui.Main
_latestTaskId.Clear();
Instances.TaskQueueViewModel.ResetFightVariables();
Instances.TaskQueueViewModel.ResetTaskSelection();
_runningState.SetIdle(true);
Instances.RecognizerViewModel.GachaDone = true;

View File

@@ -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;
/// <summary>
/// Gets or sets a value indicating whether gets or sets whether the key is checked with null.
/// </summary>
public bool? IsCheckedWithNull
{
get => _isCheckedWithNull;
set
{
SetAndNotify(ref _isCheckedWithNull, value);
value ??= false;
ConfigurationHelper.SetCheckedStorage(_storageKey, OriginalName, value.ToString());
}
}
/// <summary>
/// Gets or sets a value indicating whether gets or sets whether the key is checked.
/// </summary>
public bool IsChecked
{
get => _isChecked;
set
{
SetAndNotify(ref _isChecked, value);
ConfigurationHelper.SetCheckedStorage(_storageKey, OriginalName, value.ToString());
}
get => IsCheckedWithNull != false;
set => IsCheckedWithNull = value;
}
// 换成图标的话要这个,暂时没用

View File

@@ -342,6 +342,7 @@ namespace MaaWpfGui.ViewModels.UI
}
ResetFightVariables();
ResetTaskSelection();
RefreshCustomInfrastPlanIndexByPeriod();
}
@@ -751,6 +752,20 @@ namespace MaaWpfGui.ViewModels.UI
}
}
/// <summary>
/// Reset unsaved task selection.
/// </summary>
public void ResetTaskSelection()
{
foreach (var item in TaskItemViewModels)
{
if (item.IsCheckedWithNull == null)
{
item.IsChecked = false;
}
}
}
private async Task<bool> ConnectToEmulator()
{
string errMsg = string.Empty;

View File

@@ -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}" />
<hc:ButtonGroup Grid.Column="1" HorizontalAlignment="Left">
<!-- ReSharper disable once Xaml.StaticResourceNotResolved -->
<RadioButton