From 75e14c8379261b9dace0f6859832abbd52dfaffb Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:58:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1/?= =?UTF-8?q?=E5=9F=BA=E5=BB=BA=E5=88=97=E8=A1=A8=E9=A1=BA=E5=BA=8F=E5=90=8E?= =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=A7=8B=E4=BB=BB=E5=8A=A1=E4=BC=9A=E5=9C=A8?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E9=87=8D=E5=90=AF=E5=90=8E=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #10094 --- .../Services/RemoteControl/RemoteControlService.cs | 2 +- src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs | 9 +++++++-- src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs | 9 ++++++--- src/MaaWpfGui/Views/UI/TaskQueueView.xaml | 1 - .../Views/UserControl/InfrastSettingsUserControl.xaml | 1 - 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs index 6ac35626ce..8feafce878 100644 --- a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs +++ b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs @@ -604,7 +604,7 @@ namespace MaaWpfGui.Services.RemoteControl await Execute.OnUIThreadAsync(async () => { - // 虽然更改时已经保存过了,不过保险起见还是在点击开始之后再保存一次任务及基建列表 + // 虽然更改时已经保存过了,不过保险起见还是在点击开始之后再保存一次(任务及基建列表) Instances.TaskQueueViewModel.TaskItemSelectionChanged(); Instances.SettingsViewModel.InfrastOrderSelectionChanged(); diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index d8817ac2ef..9eea8bbe41 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -16,6 +16,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.ComponentModel; using System.Diagnostics; using System.Globalization; @@ -204,7 +205,8 @@ namespace MaaWpfGui.ViewModels.UI ConfigurationHelper.SetFacilityOrder(newVm.OriginalName, i.ToString()); } - InfrastItemViewModels = new ObservableCollection(tempOrderList); + InfrastItemViewModels = new ObservableCollection(tempOrderList!); + InfrastItemViewModels.CollectionChanged += InfrastOrderSelectionChanged; _dormThresholdLabel = LocalizationHelper.GetString("DormThreshold") + ": " + _dormThreshold + "%"; } @@ -1626,8 +1628,11 @@ namespace MaaWpfGui.ViewModels.UI /// /// 实时更新基建换班顺序 /// - public void InfrastOrderSelectionChanged() + /// ignored object + /// ignored NotifyCollectionChangedEventArgs + public void InfrastOrderSelectionChanged(object? sender = null, NotifyCollectionChangedEventArgs? e = null) { + _ = (sender, e); int index = 0; foreach (var item in InfrastItemViewModels) { diff --git a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs index d5b9ed9fc9..aa7fa85bdc 100644 --- a/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/TaskQueueViewModel.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Specialized; using System.Diagnostics; using System.IO; using System.Linq; @@ -71,10 +72,11 @@ namespace MaaWpfGui.ViewModels.UI /// /// 实时更新任务顺序 /// - // UI 绑定的方法 - // ReSharper disable once MemberCanBePrivate.Global - public void TaskItemSelectionChanged() + /// ignored object + /// ignored NotifyCollectionChangedEventArgs + public void TaskItemSelectionChanged(object sender = null, NotifyCollectionChangedEventArgs e = null) { + _ = (sender, e); Execute.OnUIThread(() => { int index = 0; @@ -641,6 +643,7 @@ namespace MaaWpfGui.ViewModels.UI } TaskItemViewModels = new ObservableCollection(tempOrderList); + TaskItemViewModels.CollectionChanged += TaskItemSelectionChanged; InitDrops(); NeedToUpdateDatePrompt(); diff --git a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml index 6f5447a63f..0179189c03 100644 --- a/src/MaaWpfGui/Views/UI/TaskQueueView.xaml +++ b/src/MaaWpfGui/Views/UI/TaskQueueView.xaml @@ -52,7 +52,6 @@ dd:DragDrop.IsDragSource="{Binding Idle}" dd:DragDrop.IsDropTarget="{Binding Idle}" BorderThickness="0" - DragDrop.Drop="{s:Action TaskItemSelectionChanged}" ItemContainerStyle="{StaticResource CustomListBoxItemStyle}" ItemsSource="{Binding TaskItemViewModels}" ToolTip="{DynamicResource LabelSequenceTip}"> diff --git a/src/MaaWpfGui/Views/UserControl/InfrastSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/InfrastSettingsUserControl.xaml index bb32ce92c6..d1a3703dfc 100644 --- a/src/MaaWpfGui/Views/UserControl/InfrastSettingsUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/InfrastSettingsUserControl.xaml @@ -115,7 +115,6 @@ dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True" ItemsSource="{Binding Path=InfrastItemViewModels}" - SelectionChanged="{s:Action InfrastOrderSelectionChanged}" ToolTip="{DynamicResource LabelSequenceTip}">