From 1b4d3a46f3643b73997973dca05f8558c0acafce Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 24 May 2018 21:07:20 +0100 Subject: [PATCH] WinGui: Don't allow subtitle import before a source has been scanned. --- win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs | 9 +++++++++ win/CS/HandBrakeWPF/Properties/ResourcesUI.resx | 3 +++ win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 9 +++++++++ win/CS/HandBrakeWPF/Views/MainView.xaml | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 05cce7649..cc359053b 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -1068,6 +1068,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Please choose a source to encode before trying to import a subtitle file.. + /// + public static string MainView_SubtitleBeforeScanError { + get { + return ResourceManager.GetString("MainView_SubtitleBeforeScanError", resourceCulture); + } + } + /// /// Looks up a localized string similar to Subtitles. /// diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index cd19adc04..4e188b0ce 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -1025,4 +1025,7 @@ This will not affect your current settings in the Subtitle tab. Show previews on summary tab. + + Please choose a source to encode before trying to import a subtitle file. + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 3d19a81f5..a081d28d5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1839,6 +1839,15 @@ namespace HandBrakeWPF.ViewModels return; } + if (this.SelectedTitle == null) + { + MessageBox.Show( + ResourcesUI.MainView_SubtitleBeforeScanError, + Resources.Error, + MessageBoxButton.OK, + MessageBoxImage.Error); + } + // 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()) diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index 049e31a28..f3bf10401 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -120,7 +120,7 @@ - + -- 2.40.0