diff --git a/src/SopHelper.Avalonia/Training/CameraViewModel.cs b/src/SopHelper.Avalonia/Training/CameraViewModel.cs index f4389b4..87e3b49 100644 --- a/src/SopHelper.Avalonia/Training/CameraViewModel.cs +++ b/src/SopHelper.Avalonia/Training/CameraViewModel.cs @@ -72,6 +72,7 @@ public sealed partial class CameraViewModel : BindableBase public DelegateCommand RestartCommand { get; } public DelegateCommand PlayVideoCommand { get; } public DelegateCommand PauseVideoCommand { get; } + public DelegateCommand ToggleVideoPlaybackCommand { get; } public DelegateCommand StopVideoCommand { get; } public DelegateCommand ImportVideoCommand { get; } public event Action? RecordingLimitReached; @@ -99,6 +100,11 @@ public sealed partial class CameraViewModel : BindableBase RestartCommand = Command(RestartRecordingAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && HasStandardVideo && IsPreviewing && Preview != null && HasRecentFrame); PlayVideoCommand = Command(PlayVideoAsync, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && !IsRecording && HasStandardVideo && !Playback.IsPlaying); PauseVideoCommand = Command(() => { Playback.Pause(); Status = "视频播放已暂停"; return Task.CompletedTask; }, () => !IsBusy && !_closing && !IsTestingFlow && Playback.IsPlaying); + ToggleVideoPlaybackCommand = Command(async () => + { + if (Playback.IsPlaying) { Playback.Pause(); Status = "视频播放已暂停"; } + else await PlayVideoAsync(); + }, () => _sopStandard && !IsBusy && !_closing && !IsTestingFlow && !IsRecording && HasStandardVideo); 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); diff --git a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml index 25a3791..303ef66 100644 --- a/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml +++ b/src/SopHelper.Avalonia/VVMs/RecipeEditor/RecipeEditor.axaml @@ -301,48 +301,27 @@ - - - - + + + + - - -