From 6ab9be708d1c2ffa7c40569415c7f4c825d8b86d Mon Sep 17 00:00:00 2001 From: tfarcraw <123211521@163.com> Date: Thu, 19 Nov 2026 13:46:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BB=E8=A7=86=E9=A2=91=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E6=9A=82=E5=81=9C=E6=8C=89=E9=92=AE=E5=B9=B6=E5=B0=86?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4=E9=A1=B5=E8=A7=86=E9=A2=91=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BA=E5=8D=8A=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Training/CameraViewModel.cs | 12 +++-- .../VVMs/RecipeEditor/RecipeEditor.axaml | 47 +++++++++++-------- tests/VideoFlowTest.Smoke/Program.cs | 10 +++- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/src/SopHelper.Avalonia/Training/CameraViewModel.cs b/src/SopHelper.Avalonia/Training/CameraViewModel.cs index d1fca5d..8d6cf30 100644 --- a/src/SopHelper.Avalonia/Training/CameraViewModel.cs +++ b/src/SopHelper.Avalonia/Training/CameraViewModel.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.IO; using System.Text.Json; using Avalonia; @@ -71,6 +71,7 @@ public sealed partial class CameraViewModel : BindableBase public DelegateCommand PauseCommand { get; } public DelegateCommand RestartCommand { get; } public DelegateCommand PlayVideoCommand { get; } + public DelegateCommand PauseVideoCommand { get; } public DelegateCommand StopVideoCommand { get; } public DelegateCommand ImportVideoCommand { get; } public event Action? RecordingLimitReached; @@ -96,7 +97,8 @@ public sealed partial class CameraViewModel : BindableBase StopRecordingCommand = Command(() => { StopRecording(); return Task.CompletedTask; }, () => !IsBusy && !_closing && IsRecording); PauseCommand = Command(() => { TogglePause(); return Task.CompletedTask; }, () => !IsBusy && !_closing && IsRecording); RestartCommand = Command(RestartRecordingAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && HasStandardVideo && IsPreviewing && Preview != null && HasRecentFrame); - PlayVideoCommand = Command(ToggleVideoPlaybackAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && !IsRecording && HasStandardVideo); + PlayVideoCommand = Command(PlayVideoAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && !IsRecording && HasStandardVideo && !Playback.IsPlaying); + PauseVideoCommand = Command(() => { Playback.Pause(); Status = "视频播放已暂停"; return Task.CompletedTask; }, () => !IsBusy && !_closing && !IsTestingFlow && Playback.IsPlaying); ImportVideoCommand = Command(ImportVideoAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && !IsRecording); TestFlowCommand = Command(StartFlowTestAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && !IsRecording && HasStandardVideo && FlowTestConfigProvider is not null); StopVideoCommand = Command(async () => { await Playback.StopAsync(); EndFlowTest("测试已停止"); Status = "视频播放已停止"; }, () => !IsBusy && !_closing && Playback.IsLoaded); @@ -110,7 +112,7 @@ public sealed partial class CameraViewModel : BindableBase if (e.PropertyName == nameof(Playback.IsAtEnd) && Playback.IsAtEnd) { if (IsTestingFlow) _ = CompleteFlowTestAsync(); - Status = "视频播放结束,可点击“重新播放”再次观看"; + Status = "视频播放结束,可点击“播放”再次观看"; } }; Playback.Failed += message => { EndFlowTest(message); Status = message; }; @@ -190,11 +192,11 @@ public sealed partial class CameraViewModel : BindableBase _previewCamera = selected; IsPreviewing = true; Status = "相机预览中,可开始录像"; } - private async Task ToggleVideoPlaybackAsync() + private async Task PlayVideoAsync() { FlowTestRegions = null; if (IsRecording) throw new InvalidOperationException("请先停止录像并保存,再播放视频"); - if (Playback.IsPlaying) { Playback.Pause(); Status = "视频播放已暂停"; return; } + if (Playback.IsPlaying) return; if (IsPreviewing) { await Task.Run(_camera.Disconnect); diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml index 68f3cd5..86ddf94 100644 --- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml +++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml @@ -107,10 +107,10 @@ - - + + @@ -122,23 +122,7 @@