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}" />