From ec522a70a2f4e584e486b9412a86a7440c2e6b50 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 18 May 2014 19:56:12 +0000 Subject: [PATCH] WinGui: Minor tidy up of options. Cleanup of some code warnings and some initial DPIAwareness code. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6198 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Isolation/IsolatedEncodeService.cs | 2 +- .../Services/Encode.cs | 2 +- .../Services/Interfaces/IEncode.cs | 2 +- .../Services/LibEncode.cs | 2 +- .../Utilities/QueryParserUtility.cs | 6 -- win/CS/HandBrakeWPF/Constants.cs | 2 - win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 1 + win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs | 3 +- win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs | 3 - win/CS/HandBrakeWPF/Helpers/FileHelper.cs | 1 - .../Properties/Resources.Designer.cs | 23 +++++++ win/CS/HandBrakeWPF/Properties/Resources.resx | 11 ++++ .../Services/EncodeServiceWrapper.cs | 2 +- win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs | 66 +++++++++++++++++++ .../HandBrakeWPF/ViewModels/MainViewModel.cs | 1 - .../ViewModels/SubtitlesViewModel.cs | 9 +-- .../HandBrakeWPF/ViewModels/VideoViewModel.cs | 8 +-- win/CS/HandBrakeWPF/Views/OptionsView.xaml | 40 ++++++----- .../Views/PictureSettingsView.xaml | 2 +- win/CS/HandBrakeWPF/Views/Styles/Styles.xaml | 14 ++++ win/CS/HandBrakeWPF/Views/VideoView.xaml | 14 ---- 21 files changed, 152 insertions(+), 62 deletions(-) create mode 100644 win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs diff --git a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs index f5aba636c..aeb99783c 100644 --- a/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs +++ b/win/CS/HandBrake.ApplicationServices/Isolation/IsolatedEncodeService.cs @@ -104,7 +104,7 @@ namespace HandBrake.ApplicationServices.Isolation } /// - /// Gets or sets IsPaused + /// Gets a value indicating whether is pasued. /// public bool IsPasued { get; private set; } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 18d69c06f..318902c91 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -69,7 +69,7 @@ namespace HandBrake.ApplicationServices.Services } /// - /// Gets or sets IsPaused + /// Gets a value indicating whether is pasued. /// public bool IsPasued { get; private set; } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs index 7378eee1d..dec7d25b3 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IEncode.cs @@ -77,7 +77,7 @@ namespace HandBrake.ApplicationServices.Services.Interfaces bool CanPause { get; } /// - /// Is Paused + /// Gets a value indicating whether is pasued. /// bool IsPasued { get; } diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index 608fd1476..e62c1cc2c 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -79,7 +79,7 @@ namespace HandBrake.ApplicationServices.Services } /// - /// Gets or sets IsPaused + /// Gets a value indicating whether is pasued. /// public bool IsPasued { get; private set; } diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs index a3cfae6fe..2b39c74a5 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryParserUtility.cs @@ -54,7 +54,6 @@ namespace HandBrake.ApplicationServices.Utilities // Output Settings Match format = Regex.Match(input, @"-f ([a-zA-Z0-9]+)"); Match grayscale = Regex.Match(input, @" -g"); - Match largerMp4 = Regex.Match(input, @" -4"); Match ipodAtom = Regex.Match(input, @" -I"); // Picture Settings Tab @@ -480,11 +479,6 @@ namespace HandBrake.ApplicationServices.Utilities parsed.X264Tune = Converters.Getx264TuneFromCli(tuneOptions); } - - - - - if (x265Preset.Success) parsed.X265Preset = Converters.Getx265PresetFromCli(x265Preset.ToString().Replace("--x265-preset", string.Empty).Replace("=", string.Empty).Trim()); diff --git a/win/CS/HandBrakeWPF/Constants.cs b/win/CS/HandBrakeWPF/Constants.cs index 174db62ad..27e70828d 100644 --- a/win/CS/HandBrakeWPF/Constants.cs +++ b/win/CS/HandBrakeWPF/Constants.cs @@ -29,13 +29,11 @@ namespace HandBrakeWPF /// public const string AppcastUnstable32 = "http://handbrake.fr/appcast_unstable.i386.xml"; - /// /// The appcast 32. /// public const string AppcastUnstable64 = "http://handbrake.fr/appcast_unstable.x86_64.xml"; - /// /// The any. /// diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 2250b4fc5..64752b39d 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -157,6 +157,7 @@ + diff --git a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs index e9e4d0278..0c521661b 100644 --- a/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/AutoNameHelper.cs @@ -18,7 +18,6 @@ namespace HandBrakeWPF.Helpers using HandBrake.ApplicationServices.Extensions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Model.Encoding; - using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.Interop.Model.Encoding; using HandBrakeWPF.Services.Interfaces; @@ -97,10 +96,12 @@ namespace HandBrakeWPF.Helpers if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality) { destinationFilename = destinationFilename.Replace(Constants.Quality, task.Quality.ToString()); + destinationFilename = destinationFilename.Replace(Constants.Bitrate, string.Empty); } else { destinationFilename = destinationFilename.Replace(Constants.Bitrate, task.VideoBitrate.ToString()); + destinationFilename = destinationFilename.Replace(Constants.Quality, string.Empty); } } else diff --git a/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs b/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs index ede46fa8b..302611e1e 100644 --- a/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/CliCheckHelper.cs @@ -18,9 +18,6 @@ namespace HandBrakeWPF.Helpers using Caliburn.Micro; - using HandBrake.ApplicationServices; - using HandBrake.ApplicationServices.Services.Interfaces; - using HandBrakeWPF.Services.Interfaces; /// diff --git a/win/CS/HandBrakeWPF/Helpers/FileHelper.cs b/win/CS/HandBrakeWPF/Helpers/FileHelper.cs index 7a882de0b..e9017f8b5 100644 --- a/win/CS/HandBrakeWPF/Helpers/FileHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/FileHelper.cs @@ -42,7 +42,6 @@ namespace HandBrakeWPF.Helpers { return true; } - } catch (ArgumentException) { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index adb1478dd..327ff8ecc 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -680,6 +680,29 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to The format of the output file. In addition to any supported file system character, you can use the following placeholders that will be replaced when you change title or scan a source. + /// + ///Live Update Options: {source} {title} {chapters} + ///Non-Live Options: {date} {time} {quality} {bitrate} (These only change if you scan a new source, change title or chapters). + /// + public static string Options_AdditionalFormatOptions { + get { + return ResourceManager.GetString("Options_AdditionalFormatOptions", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Available additional Options: {source_path} or {source_folder_name} + /// + ///Not both at the same time!. + /// + public static string Options_DefaultPathAdditionalParams { + get { + return ResourceManager.GetString("Options_DefaultPathAdditionalParams", resourceCulture); + } + } + /// /// Looks up a localized string similar to Overwrite?. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 2d7dbc438..921d898e2 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -516,4 +516,15 @@ Do you wish to proceed? Output: {0} + + The format of the output file. In addition to any supported file system character, you can use the following placeholders that will be replaced when you change title or scan a source. + +Live Update Options: {source} {title} {chapters} +Non-Live Options: {date} {time} {quality} {bitrate} (These only change if you scan a new source, change title or chapters) + + + Available additional Options: {source_path} or {source_folder_name} + +Not both at the same time! + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs b/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs index ca71c7a30..796689781 100644 --- a/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs +++ b/win/CS/HandBrakeWPF/Services/EncodeServiceWrapper.cs @@ -146,7 +146,7 @@ namespace HandBrakeWPF.Services } /// - /// Gets or sets IsPaused + /// Gets a value indicating whether is pasued. /// public bool IsPasued { diff --git a/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs b/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs new file mode 100644 index 000000000..91751474c --- /dev/null +++ b/win/CS/HandBrakeWPF/Utilities/DPIAwareness.cs @@ -0,0 +1,66 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the DPIAwareness type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System.Windows; + using System.Windows.Media; + + /// + /// The dpi awareness. + /// + public class DPIAwareness + { + /// + /// The dx. + /// + private static double dx; + + /// + /// The dy. + /// + private static double dy; + + /// + /// Initializes a new instance of the class. + /// + public DPIAwareness() + { + var presentationSource = PresentationSource.FromVisual(Application.Current.MainWindow); + if (presentationSource != null && presentationSource.CompositionTarget != null) + { + Matrix m = presentationSource.CompositionTarget.TransformToDevice; + dx = m.M11; + dy = m.M22; + } + } + + /// + /// Gets the dpix. + /// + public double Dpix + { + get + { + return dx; + } + } + + /// + /// Gets the dpi y. + /// + public double DpiY + { + get + { + return dy; + } + } + } +} diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index bcdb9ff27..6e6b21a1f 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -2102,7 +2102,6 @@ namespace HandBrakeWPF.ViewModels { this.IsEncoding = false; - Execute.OnUIThread( () => { diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index 859763d3f..b279f95c5 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -160,7 +160,6 @@ namespace HandBrakeWPF.ViewModels } } - /// /// Gets or sets the subtitle behaviours. /// @@ -264,7 +263,6 @@ namespace HandBrakeWPF.ViewModels : LanguageUtilities.GetLanguageCodes( this.SubtitleBehaviours.SelectedLangauges.ToArray()); - List availableTracks = this.SourceTracks.Where(subtitle => iso6392Codes.Contains(subtitle.LanguageCodeClean)).ToList(); @@ -289,7 +287,6 @@ namespace HandBrakeWPF.ViewModels bool foundLanguage = false; Subtitle track = sourceTrack; - foreach (var item in this.Task.SubtitleTracks) { if (item.SourceTrack != null && item.SourceTrack.LanguageCode != null && track.LanguageCode.Contains(item.SourceTrack.LanguageCode)) @@ -606,7 +603,11 @@ namespace HandBrakeWPF.ViewModels } } - this.Task.SubtitleTracks.Add(track); + var encodeTask = this.Task; + if (encodeTask != null) + { + encodeTask.SubtitleTracks.Add(track); + } } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs index 0f5a0e167..46fa83487 100644 --- a/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/VideoViewModel.cs @@ -108,11 +108,6 @@ namespace HandBrakeWPF.ViewModels /// private int qsvPresetValue; - /// - /// The extra arguments. - /// - private string extraArguments; - /// /// The can clear tracker. /// @@ -483,7 +478,7 @@ namespace HandBrakeWPF.ViewModels { get { - return this.SelectedVideoEncoder == VideoEncoder.X264 || this.SelectedVideoEncoder == VideoEncoder.X265 ? "RF" : "QP"; + return this.SelectedVideoEncoder == VideoEncoder.X264 || this.SelectedVideoEncoder == VideoEncoder.X265 ? "RF" : "QP"; } } @@ -965,7 +960,6 @@ namespace HandBrakeWPF.ViewModels } } - /// /// Gets or sets H265Profile. /// diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index 4f28678c9..69f57ab74 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -1,11 +1,8 @@  @@ -175,28 +172,37 @@ - - - -