From ab9c7eb8f3c9b328d2256c703c517df5fc3c6ea3 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Wed, 6 Jun 2018 08:54:29 +0200 Subject: [PATCH] Stylecop --- .../ConversionJobs/ConversionJob.cs | 48 +++++++++---------- .../ConversionJob_FFMPEG.Converters.cs | 4 +- .../ConversionJobs/ConversionJob_FFMPEG.cs | 13 ++--- .../ConversionPreset/ConversionPreset.cs | 2 +- Application/FileConverter/Helpers.cs | 1 + .../FileConverter/Windows/MainWindow.xaml.cs | 4 +- FileConverter.sln.DotSettings | 1 + 7 files changed, 38 insertions(+), 35 deletions(-) diff --git a/Application/FileConverter/ConversionJobs/ConversionJob.cs b/Application/FileConverter/ConversionJobs/ConversionJob.cs index 14a640c..fdcd755 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob.cs @@ -415,7 +415,7 @@ namespace FileConverter.ConversionJobs { Debug.Log("Conversion Succeed!"); - ChangeOutputFileTimestampToMatchOriginal(); + this.ChangeOutputFileTimestampToMatchOriginal(); // Apply the input post conversion action. switch (this.InputPostConversionAction) @@ -451,6 +451,29 @@ namespace FileConverter.ConversionJobs Debug.Log("Conversion Done!"); } + protected void ConversionFailed(string exitingMessage) + { + Debug.Log("Fail: {0}", exitingMessage); + + if (this.State == ConversionState.Failed) + { + // Already failed, don't override informations. + return; + } + + this.State = ConversionState.Failed; + this.UserState = Properties.Resources.ConversionStateFailed; + this.ErrorMessage = exitingMessage; + } + + protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") + { + if (this.PropertyChanged != null) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + private void ChangeOutputFileTimestampToMatchOriginal() { Debug.Log("Changing output files timestamp to match original timestamp ..."); @@ -480,29 +503,6 @@ namespace FileConverter.ConversionJobs Debug.Log("... timestamp matching finished."); } - protected void ConversionFailed(string exitingMessage) - { - Debug.Log("Fail: {0}", exitingMessage); - - if (this.State == ConversionState.Failed) - { - // Already failed, don't override informations. - return; - } - - this.State = ConversionState.Failed; - this.UserState = Properties.Resources.ConversionStateFailed; - this.ErrorMessage = exitingMessage; - } - - protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") - { - if (this.PropertyChanged != null) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - private bool AllOuputFilesExists() { for (int index = 0; index < this.OutputFilePaths.Length; index++) diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs index f0095b3..14012ab 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs @@ -100,8 +100,8 @@ namespace FileConverter.ConversionJobs { // http://trac.ffmpeg.org/wiki/Encode/H.264#Encodingfordumbplayers // YUV planar color space with 4:2:0 chroma subsampling - transformArgs += (transformArgs.Length > 0 ? "," : "") + "format=yuv420p"; - // maybe there should be an option for this on the settings? + transformArgs += (transformArgs.Length > 0 ? "," : string.Empty) + "format=yuv420p"; + //// TODO: maybe there should be an option for this on the settings? } return transformArgs; diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs index 3a4305a..7d446bb 100644 --- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs +++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs @@ -74,9 +74,10 @@ namespace FileConverter.ConversionJobs protected virtual void FillFFMpegArgumentsList() { // This option are necessary to be able to read metadata on Windows. src: http://jonhall.info/how_to/create_id3_tags_using_ffmpeg - const string mp3MetadataArgs = "-id3v2_version 3 -write_id3v1 1"; + const string MP3MetadataArgs = "-id3v2_version 3 -write_id3v1 1"; + // AAC have no standard tag system, use ApeV2 (that are compatible). src: http://eolindel.free.fr/foobar/tags.shtml - const string aacMetadataArgs = "-write_apetag 1"; + const string AACMetadataArgs = "-write_apetag 1"; switch (this.ConversionPreset.OutputType) { @@ -86,7 +87,7 @@ namespace FileConverter.ConversionJobs // https://trac.ffmpeg.org/wiki/Encode/AAC int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate); - string encoderArgs = $"-c:a aac -q:a {this.AACBitrateToQualityIndex(audioEncodingBitrate)} {channelArgs} {aacMetadataArgs}"; + string encoderArgs = $"-c:a aac -q:a {this.AACBitrateToQualityIndex(audioEncodingBitrate)} {channelArgs} {AACMetadataArgs}"; string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs); @@ -111,7 +112,7 @@ namespace FileConverter.ConversionJobs // Compute final arguments. string videoFilteringArgs = ConversionJob_FFMPEG.Encapsulate("-vf", transformArgs); - string encoderArgs = $"-c:v mpeg4 -vtag xvid -qscale:v {this.MPEG4QualityToQualityIndex(videoEncodingQuality)} {audioArgs} {videoFilteringArgs} {mp3MetadataArgs}"; + string encoderArgs = $"-c:v mpeg4 -vtag xvid -qscale:v {this.MPEG4QualityToQualityIndex(videoEncodingQuality)} {audioArgs} {videoFilteringArgs} {MP3MetadataArgs}"; string arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs); this.ffmpegArgumentStringByPass.Add(new FFMpegPass(arguments)); @@ -203,11 +204,11 @@ namespace FileConverter.ConversionJobs switch (encodingMode) { case EncodingMode.Mp3VBR: - encoderArgs = $"-codec:a libmp3lame -q:a {this.MP3VBRBitrateToQualityIndex(encodingQuality)} {channelArgs} {mp3MetadataArgs}"; + encoderArgs = $"-codec:a libmp3lame -q:a {this.MP3VBRBitrateToQualityIndex(encodingQuality)} {channelArgs} {MP3MetadataArgs}"; break; case EncodingMode.Mp3CBR: - encoderArgs = $"-codec:a libmp3lame -b:a {encodingQuality}k {channelArgs} {mp3MetadataArgs}"; + encoderArgs = $"-codec:a libmp3lame -b:a {encodingQuality}k {channelArgs} {MP3MetadataArgs}"; break; default: diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs index 2ec5a9f..37223a5 100644 --- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs +++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs @@ -106,7 +106,7 @@ namespace FileConverter { get; set; - } = false; + } [XmlElement] public List InputTypes diff --git a/Application/FileConverter/Helpers.cs b/Application/FileConverter/Helpers.cs index d313823..3646925 100644 --- a/Application/FileConverter/Helpers.cs +++ b/Application/FileConverter/Helpers.cs @@ -177,6 +177,7 @@ namespace FileConverter /// /// Check whether Microsoft office is available or not. /// + /// The office application name. /// Returns true if Office is installed on the computer. /// source: http://stackoverflow.com/questions/3266675/how-to-detect-installed-version-of-ms-office/3267832#3267832 /// source: http://www.codeproject.com/Articles/26520/Getting-Office-s-Version diff --git a/Application/FileConverter/Windows/MainWindow.xaml.cs b/Application/FileConverter/Windows/MainWindow.xaml.cs index 1e83147..fdaa024 100644 --- a/Application/FileConverter/Windows/MainWindow.xaml.cs +++ b/Application/FileConverter/Windows/MainWindow.xaml.cs @@ -2,13 +2,13 @@ namespace FileConverter { - using System.ComponentModel; using System.Collections.ObjectModel; + using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; - using FileConverter.ConversionJobs; using FileConverter.Annotations; + using FileConverter.ConversionJobs; using FileConverter.Windows; public partial class MainWindow : Window, INotifyPropertyChanged diff --git a/FileConverter.sln.DotSettings b/FileConverter.sln.DotSettings index 3e04390..e94e545 100644 --- a/FileConverter.sln.DotSettings +++ b/FileConverter.sln.DotSettings @@ -20,6 +20,7 @@ CBR OGGVBR VBR + <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" />