string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];\r
if (fileNames != null && fileNames.Any() && (File.Exists(fileNames[0]) || Directory.Exists(fileNames[0])))\r
{\r
- this.StartScan(fileNames[0], 0);\r
+ string videoContent = fileNames.FirstOrDefault(f => Path.GetExtension(f)?.ToLower() != ".srt");\r
+ if (!string.IsNullOrEmpty(videoContent))\r
+ {\r
+ this.StartScan(videoContent, 0);\r
+ return;\r
+ }\r
+\r
+ // StartScan is not synchronous, so for now we don't support adding both srt and video file at the same time. \r
+ string[] subtitleFiles = fileNames.Where(f => Path.GetExtension(f)?.ToLower() == ".srt").ToArray();\r
+ if (this.SelectedTab != 5 && subtitleFiles.Any())\r
+ {\r
+ this.SwitchTab(5);\r
+ this.SubtitleViewModel.Import(subtitleFiles);\r
+ }\r
}\r
}\r
\r
using System.Collections.Generic;\r
using System.IO;\r
using System.Linq;\r
+ using System.Runtime.CompilerServices;\r
\r
using Caliburn.Micro;\r
\r
\r
dialog.ShowDialog();\r
\r
- foreach (var srtFile in dialog.FileNames)\r
+ this.AddInputSubtitles(dialog.FileNames);\r
+ }\r
+\r
+ public void Import(string[] subtitleFiles)\r
+ {\r
+ if (subtitleFiles != null && subtitleFiles.Any())\r
{\r
- SubtitleTrack track = new SubtitleTrack\r
- {\r
- SrtFileName = Path.GetFileNameWithoutExtension(srtFile),\r
- SrtOffset = 0,\r
- SrtCharCode = "UTF-8",\r
- SrtLang = "English",\r
- SubtitleType = SubtitleType.SRT,\r
- SrtPath = srtFile\r
- };\r
- this.Task.SubtitleTracks.Add(track);\r
- }\r
+ this.AddInputSubtitles(subtitleFiles);\r
+ } \r
}\r
\r
/// <summary>\r
{\r
continue; // Skip the track the user selected.\r
}\r
+\r
track.Default = false;\r
}\r
\r
{\r
continue; // Skip the track the user selected.\r
}\r
+\r
track.Burned = false;\r
}\r
+\r
this.NotifyOfPropertyChange(() => this.Task);\r
}\r
\r
break;\r
}\r
}\r
+\r
break;\r
case SubtitleBurnInBehaviourModes.ForeignAudio:\r
foreach (var track in this.Task.SubtitleTracks)\r
break;\r
}\r
}\r
+\r
break;\r
case SubtitleBurnInBehaviourModes.FirstTrack: \r
foreach (var track in this.Task.SubtitleTracks)\r
track.Burned = true;\r
this.SetBurnedToFalseForAllExcept(track);\r
}\r
- } \r
+ } \r
+ \r
break;\r
case SubtitleBurnInBehaviourModes.ForeignAudioPreferred:\r
foreach (var track in this.Task.SubtitleTracks)\r
this.SetBurnedToFalseForAllExcept(track);\r
break;\r
}\r
- } \r
+ } \r
+ \r
break;\r
}\r
}\r
: this.SourceTracks.Where(subtitle => !this.Task.SubtitleTracks.Any(track => Equals(track.SourceTrack, subtitle))).ToList();\r
}\r
\r
+ private void AddInputSubtitles(string[] filenames)\r
+ {\r
+ foreach (var srtFile in filenames)\r
+ {\r
+ if (!File.Exists(srtFile))\r
+ {\r
+ continue;\r
+ }\r
+\r
+ SubtitleTrack track = new SubtitleTrack\r
+ {\r
+ SrtFileName = Path.GetFileNameWithoutExtension(srtFile),\r
+ SrtOffset = 0,\r
+ SrtCharCode = "UTF-8",\r
+ SrtLang = "English",\r
+ SubtitleType = SubtitleType.SRT,\r
+ SrtPath = srtFile\r
+ };\r
+ this.Task.SubtitleTracks.Add(track);\r
+ }\r
+ }\r
+\r
#endregion\r
}\r
}\r