fix: 勾选手动输入关卡名时无法拖动候选关卡

This commit is contained in:
uye
2026-03-17 03:26:38 +08:00
parent 95f000fc9c
commit 5ce8df552e
3 changed files with 37 additions and 1 deletions

View File

@@ -68,6 +68,11 @@ public class FightSettingsUserControlModel : TaskSettingsViewModel, FightSetting
public static FightSettingsUserControlModel Instance { get; }
/// <summary>
/// Gets or sets a value indicating whether a stage plan item is being dragged.
/// </summary>
public bool IsDragging { get => field; set => SetAndNotify(ref field, value); }
/// <summary>
/// Gets or private sets the list of stages.
/// </summary>

View File

@@ -310,6 +310,8 @@
<TextBox
Height="30"
hc:InfoElement.Placeholder="{DynamicResource DefaultStage}"
IsEnabled="{c:Binding !IsDragging,
Source={x:Static ui_vms:TaskQueueViewModel.FightTask}}"
Opacity="{c:Binding 'IsOpen ? 1 : 0.5'}"
Text="{Binding Stage, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{DynamicResource CustomStageCodeTip}"
@@ -348,7 +350,9 @@
hc:VisualElement.HighlightBackground="Transparent"
Background="Transparent"
BorderThickness="0"
Cursor="Hand" />
Cursor="Hand"
PreviewMouseLeftButtonDown="DragHandle_PreviewMouseLeftButtonDown"
PreviewMouseLeftButtonUp="DragHandle_PreviewMouseLeftButtonUp" />
<!-- 删除按钮 -->
<Button
Grid.Column="1"

View File

@@ -11,6 +11,10 @@
// but WITHOUT ANY WARRANTY
// </copyright>
using System.Windows;
using System.Windows.Input;
using MaaWpfGui.ViewModels.UI;
namespace MaaWpfGui.Views.UserControl.TaskQueue;
/// <summary>
@@ -25,4 +29,27 @@ public partial class FightSettingsUserControl : System.Windows.Controls.UserCont
{
InitializeComponent();
}
private void DragHandle_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
TaskQueueViewModel.FightTask.IsDragging = true;
// 拖拽松开时可能不经过 Button在 Window 层兜底恢复
var window = Window.GetWindow(this);
window?.PreviewMouseLeftButtonUp += Window_PreviewMouseLeftButtonUp;
}
private void DragHandle_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TaskQueueViewModel.FightTask.IsDragging = false;
}
private void Window_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
TaskQueueViewModel.FightTask.IsDragging = false;
if (sender is Window window)
{
window.PreviewMouseLeftButtonUp -= Window_PreviewMouseLeftButtonUp;
}
}
}