summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-05-24 20:59:08 +0100
committersr55 <[email protected]>2018-05-24 20:59:33 +0100
commitf6e6fc6c47298a0dd17dad6a6c387c18fe13c6b8 (patch)
tree6735481855a3367294ed053257052ff4c8d213a9 /win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
parent91bef558463a2635a934de99a61439696682c9c1 (diff)
WinGui: Add support for dropping .srt files onto the main window. When you do this, the Subtitles tab is activated and a subtitle track for each file dropped will be added.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index 082e662fc..3d19a81f5 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -1832,7 +1832,20 @@ namespace HandBrakeWPF.ViewModels
string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
if (fileNames != null && fileNames.Any() && (File.Exists(fileNames[0]) || Directory.Exists(fileNames[0])))
{
- this.StartScan(fileNames[0], 0);
+ string videoContent = fileNames.FirstOrDefault(f => Path.GetExtension(f)?.ToLower() != ".srt");
+ if (!string.IsNullOrEmpty(videoContent))
+ {
+ this.StartScan(videoContent, 0);
+ return;
+ }
+
+ // StartScan is not synchronous, so for now we don't support adding both srt and video file at the same time.
+ string[] subtitleFiles = fileNames.Where(f => Path.GetExtension(f)?.ToLower() == ".srt").ToArray();
+ if (this.SelectedTab != 5 && subtitleFiles.Any())
+ {
+ this.SwitchTab(5);
+ this.SubtitleViewModel.Import(subtitleFiles);
+ }
}
}