From 9191ed6800d8347d9dbad781b4a86c2fbff462cd Mon Sep 17 00:00:00 2001 From: DavidWang19 Date: Fri, 24 Mar 2023 18:25:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=88=98=E6=96=97=E6=9C=AA=E5=8A=A0=E8=BD=BD=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=90=8Ejson=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Main/CopilotViewModel.cs | 35 +++++++++++++++++++++++--- src/MaaWpfGui/Views/CopilotView.xaml | 1 + 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/MaaWpfGui/Main/CopilotViewModel.cs b/src/MaaWpfGui/Main/CopilotViewModel.cs index 92848b5efb..5206af8f01 100644 --- a/src/MaaWpfGui/Main/CopilotViewModel.cs +++ b/src/MaaWpfGui/Main/CopilotViewModel.cs @@ -115,6 +115,21 @@ namespace MaaWpfGui } } + private bool _startEnabled = true; + + /// + /// Gets or sets a value indicating whether the start button is enabled. + /// + public bool StartEnabled + { + get => _startEnabled; + set + { + _startEnabled = value; + NotifyOfPropertyChange(() => StartEnabled); + } + } + /// /// Clears log. /// @@ -133,15 +148,28 @@ namespace MaaWpfGui get => _filename; set { - SetAndNotify(ref _filename, value); + if (value == _filename) + { + return; + } + + _filename = value; + NotifyOfPropertyChange(() => Filename); ClearLog(); - UpdateFileDoc(_filename); + UpdateFilename(); } } + private async void UpdateFilename() + { + StartEnabled = false; + await UpdateFileDoc(_filename); + StartEnabled = true; + } + private const string CopilotIdPrefix = "maa://"; - private async void UpdateFileDoc(string filename) + private async Task UpdateFileDoc(string filename) { ClearLog(); Url = CopilotUiUrl; @@ -196,6 +224,7 @@ namespace MaaWpfGui { ParseJsonAndShowInfo(jsonStr); } + } private async Task RequestCopilotServer(int copilotID) diff --git a/src/MaaWpfGui/Views/CopilotView.xaml b/src/MaaWpfGui/Views/CopilotView.xaml index f9b07f27d6..320f597dff 100644 --- a/src/MaaWpfGui/Views/CopilotView.xaml +++ b/src/MaaWpfGui/Views/CopilotView.xaml @@ -80,6 +80,7 @@ Height="50" Command="{s:Action Start}" Content="{DynamicResource Start}" + IsEnabled="{c:Binding StartEnabled}" Visibility="{c:Binding Idle}" />