diff --git a/BilibiliLiveRecordDownLoader/ViewModels/FFmpegCommandViewModel.cs b/BilibiliLiveRecordDownLoader/ViewModels/FFmpegCommandViewModel.cs index c92d611..2673bb4 100644 --- a/BilibiliLiveRecordDownLoader/ViewModels/FFmpegCommandViewModel.cs +++ b/BilibiliLiveRecordDownLoader/ViewModels/FFmpegCommandViewModel.cs @@ -84,6 +84,19 @@ public FFmpegCommandViewModel( ConvertOpenFileCommand = ReactiveCommand.Create(ConvertOpenFile); ConvertSaveFileCommand = ReactiveCommand.Create(ConvertSaveFile); ConvertCommand = ReactiveCommand.Create(CreateConvertVideoTask); + + this.WhenAnyValue(x => x.CutInput).Subscribe(_ => + { + NewOutputFile(); + }); + + this.WhenAnyValue(x => x.ConvertInput).Subscribe(file => + { + if (Path.GetExtension(file) == @".flv") + { + ConvertOutput = Path.ChangeExtension(file, @"mp4"); + } + }); } private async Task CheckFFmpegStatusAsync(CancellationToken token) @@ -113,6 +126,10 @@ private async Task CheckFFmpegStatusAsync(CancellationToken token) private void NewOutputFile() { var filename = CutInput; + if (!File.Exists(filename)) + { + return; + } var oldName = Path.ChangeExtension(filename, null); var extension = Path.GetExtension(filename); @@ -146,8 +163,6 @@ private void CutOpenFile() } CutInput = filename; - - NewOutputFile(); } private void CutSaveFile() @@ -170,11 +185,6 @@ private void ConvertOpenFile() } ConvertInput = filename; - - if (Path.GetExtension(filename) == @".flv") - { - ConvertOutput = Path.ChangeExtension(filename, @"mp4"); - } } private void ConvertSaveFile() diff --git a/BilibiliLiveRecordDownLoader/Views/FFmpegCommandView.xaml.cs b/BilibiliLiveRecordDownLoader/Views/FFmpegCommandView.xaml.cs index e0df256..56c9303 100644 --- a/BilibiliLiveRecordDownLoader/Views/FFmpegCommandView.xaml.cs +++ b/BilibiliLiveRecordDownLoader/Views/FFmpegCommandView.xaml.cs @@ -20,12 +20,12 @@ public FFmpegCommandView(FFmpegCommandViewModel viewModel) this.OneWayBind(ViewModel, vm => vm.FFmpegStatusForeground, vm => vm.FFmpegStatusTextBlock.Foreground).DisposeWith(d); this.BindCommand(ViewModel, vm => vm.CheckFFmpegStatusCommand, vm => vm.FFmpegStatusTextBlock, nameof(FFmpegStatusTextBlock.MouseLeftButtonUp)).DisposeWith(d); - this.OneWayBind(ViewModel, vm => vm.CutInput, vm => vm.CutInputTextBox.Text).DisposeWith(d); + this.Bind(ViewModel, vm => vm.CutInput, vm => vm.CutInputTextBox.Text).DisposeWith(d); this.Bind(ViewModel, vm => vm.CutOutput, vm => vm.CutOutputTextBox.Text).DisposeWith(d); this.Bind(ViewModel, vm => vm.CutStartTime, vm => vm.CutStartTimeTextBox.Text).DisposeWith(d); this.Bind(ViewModel, vm => vm.CutEndTime, vm => vm.CutEndTimeTextBox.Text).DisposeWith(d); - this.OneWayBind(ViewModel, vm => vm.ConvertInput, vm => vm.ConvertInputTextBox.Text).DisposeWith(d); + this.Bind(ViewModel, vm => vm.ConvertInput, vm => vm.ConvertInputTextBox.Text).DisposeWith(d); this.Bind(ViewModel, vm => vm.ConvertOutput, vm => vm.ConvertOutputTextBox.Text).DisposeWith(d); this.Bind(ViewModel, vm => vm.IsDelete, vm => vm.IsDeleteToggleSwitch.IsOn).DisposeWith(d);