Skip to content

Commit

Permalink
Fix drag drop
Browse files Browse the repository at this point in the history
  • Loading branch information
HMBSbige committed Dec 27, 2020
1 parent b1b493a commit 548c646
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
24 changes: 17 additions & 7 deletions BilibiliLiveRecordDownLoader/ViewModels/FFmpegCommandViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> CheckFFmpegStatusAsync(CancellationToken token)
Expand Down Expand Up @@ -113,6 +126,10 @@ private async Task<bool> 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);
Expand Down Expand Up @@ -146,8 +163,6 @@ private void CutOpenFile()
}

CutInput = filename;

NewOutputFile();
}

private void CutSaveFile()
Expand All @@ -170,11 +185,6 @@ private void ConvertOpenFile()
}

ConvertInput = filename;

if (Path.GetExtension(filename) == @".flv")
{
ConvertOutput = Path.ChangeExtension(filename, @"mp4");
}
}

private void ConvertSaveFile()
Expand Down
4 changes: 2 additions & 2 deletions BilibiliLiveRecordDownLoader/Views/FFmpegCommandView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 548c646

Please sign in to comment.