From 6402bd62a09790377fa76868bed361ffa9b5c810 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 26 Mar 2017 11:57:57 +0100 Subject: [PATCH] WinGui: Fix a number of stylecop warnings. --- .../Controls/SplitButton/SplitMenuButton.cs | 8 +-- .../Converters/FullPathToFileNameConverter.cs | 2 +- .../Converters/Options/OptionsTabConverter.cs | 2 +- .../QueueStatusToVisibilityConverter.cs | 3 +- .../Helpers/QueueRecoveryHelper.cs | 4 +- .../Services/Encode/EncodeBase.cs | 46 +++++++-------- .../HandBrakeWPF/Services/Encode/LibEncode.cs | 18 +++--- .../Encode/Model/Models/Video/VideoLevel.cs | 28 ++++----- .../Encode/Model/Models/Video/VideoPreset.cs | 28 ++++----- .../Encode/Model/Models/Video/VideoProfile.cs | 28 ++++----- .../Encode/Model/Models/Video/VideoTune.cs | 56 +++++++++--------- .../Services/Presets/Model/Preset.cs | 28 ++++----- .../Presets/Model/PresetDisplayCategory.cs | 10 ++-- .../Services/Presets/PresetService.cs | 6 +- .../Services/Queue/Model/QueueTask.cs | 28 ++++----- .../Services/Queue/QueueProcessor.cs | 50 ++++++++-------- win/CS/HandBrakeWPF/Services/Scan/LibScan.cs | 25 ++++---- .../Services/UserSettingService.cs | 2 +- win/CS/HandBrakeWPF/Utilities/Execute.cs | 42 +++++++------- .../Utilities/PropertyChangedBase.cs | 26 ++++----- .../HandBrakeWPF/ViewModels/AudioViewModel.cs | 36 ++++++------ .../HandBrakeWPF/ViewModels/LogViewModel.cs | 30 +++++----- .../HandBrakeWPF/ViewModels/MainViewModel.cs | 54 +++++++++--------- .../ViewModels/OptionsViewModel.cs | 20 +++---- .../ViewModels/SubtitlesViewModel.cs | 12 ++-- win/CS/HandBrakeWPF/Views/ShellView.xaml.cs | 57 +++++++++---------- 26 files changed, 324 insertions(+), 325 deletions(-) diff --git a/win/CS/HandBrakeWPF/Controls/SplitButton/SplitMenuButton.cs b/win/CS/HandBrakeWPF/Controls/SplitButton/SplitMenuButton.cs index adf17eb46..fb05bc967 100644 --- a/win/CS/HandBrakeWPF/Controls/SplitButton/SplitMenuButton.cs +++ b/win/CS/HandBrakeWPF/Controls/SplitButton/SplitMenuButton.cs @@ -36,7 +36,7 @@ namespace HandBrakeWPF.Controls.SplitButton /// /// The is mouse over split element. /// - private bool IsMouseOverSplitElement; + private bool isMouseOverSplitElement; /// /// The context menu. @@ -156,7 +156,7 @@ namespace HandBrakeWPF.Controls.SplitButton /// protected override void OnClick() { - if (this.IsMouseOverSplitElement) + if (this.isMouseOverSplitElement) { this.OpenButtonMenu(); } @@ -259,7 +259,7 @@ namespace HandBrakeWPF.Controls.SplitButton /// private void SplitElement_MouseEnter(object sender, MouseEventArgs e) { - this.IsMouseOverSplitElement = true; + this.isMouseOverSplitElement = true; } /// @@ -273,7 +273,7 @@ namespace HandBrakeWPF.Controls.SplitButton /// private void SplitElement_MouseLeave(object sender, MouseEventArgs e) { - this.IsMouseOverSplitElement = false; + this.isMouseOverSplitElement = false; } /// diff --git a/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs b/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs index 7989d6b06..4fa4b209c 100644 --- a/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs @@ -9,10 +9,10 @@ namespace HandBrakeWPF.Converters { + using System; using System.Globalization; using System.IO; using System.Windows.Data; - using System; /// /// Converts a Full Path to Filename only. diff --git a/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs b/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs index 54897e19c..c7837efd4 100644 --- a/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/Options/OptionsTabConverter.cs @@ -19,7 +19,7 @@ namespace HandBrakeWPF.Converters.Options /// /// The Options Tab Converter. Controls which tab is dispalyed. /// - class OptionsTabConverter : IValueConverter + public class OptionsTabConverter : IValueConverter { /// /// Converts a value. diff --git a/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs b/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs index f882728e7..c5691b2c5 100644 --- a/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/QueueStatusToVisibilityConverter.cs @@ -9,11 +9,10 @@ namespace HandBrakeWPF.Converters { + using System; using System.Globalization; using System.Windows; using System.Windows.Data; - using System; - using HandBrakeWPF.Services.Queue.Model; /// diff --git a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs index 01dd64667..83494ee36 100644 --- a/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs +++ b/win/CS/HandBrakeWPF/Helpers/QueueRecoveryHelper.cs @@ -56,14 +56,14 @@ namespace HandBrakeWPF.Helpers } List removeFiles = new List(); - XmlSerializer Ser = new XmlSerializer(typeof(List)); + XmlSerializer ser = new XmlSerializer(typeof(List)); foreach (FileInfo file in logFiles) { try { using (FileStream strm = new FileStream(file.FullName, FileMode.Open, FileAccess.Read)) { - List list = Ser.Deserialize(strm) as List; + List list = ser.Deserialize(strm) as List; if (list != null && list.Count == 0) { removeFiles.Add(file.FullName); diff --git a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs index 0e84c3650..8f7dee945 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs @@ -170,53 +170,53 @@ namespace HandBrakeWPF.Services.Encode } /// - /// The write file. + /// Verify the Encode Destination path exists and if not, create it. /// - /// - /// The content. - /// - /// - /// The file name. + /// + /// The task. /// - private void WriteFile(string content, string fileName) + /// + /// If the creation fails, an exception is thrown. + /// + protected void VerifyEncodeDestinationPath(EncodeTask task) { + // Make sure the path exists, attempt to create it if it doesn't try { - using (StreamWriter fileWriter = new StreamWriter(fileName) { AutoFlush = true }) + string path = Directory.GetParent(task.Destination).ToString(); + if (!Directory.Exists(path)) { - fileWriter.Write(content); + Directory.CreateDirectory(path); } } catch (Exception exc) { - Debug.WriteLine(exc); + throw new GeneralApplicationException( + "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc); } } /// - /// Verify the Encode Destination path exists and if not, create it. + /// The write file. /// - /// - /// The task. + /// + /// The content. /// - /// - /// If the creation fails, an exception is thrown. - /// - protected void VerifyEncodeDestinationPath(EncodeTask task) + /// + /// The file name. + /// + private void WriteFile(string content, string fileName) { - // Make sure the path exists, attempt to create it if it doesn't try { - string path = Directory.GetParent(task.Destination).ToString(); - if (!Directory.Exists(path)) + using (StreamWriter fileWriter = new StreamWriter(fileName) { AutoFlush = true }) { - Directory.CreateDirectory(path); + fileWriter.Write(content); } } catch (Exception exc) { - throw new GeneralApplicationException( - "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc); + Debug.WriteLine(exc); } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs index d8f25373a..03763d448 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs @@ -151,6 +151,15 @@ namespace HandBrakeWPF.Services.Encode #region HandBrakeInstance Event Handlers. + /// + /// Service Log Message. + /// + /// Log message content + protected void ServiceLogMessage(string message) + { + this.log.LogMessage(string.Format("{0}# {1}{0}", Environment.NewLine, message), LogMessageType.ScanOrEncode, LogLevel.Info); + } + /// /// Encode Progress Event Handler /// @@ -200,15 +209,6 @@ namespace HandBrakeWPF.Services.Encode ? new EventArgs.EncodeCompletedEventArgs(false, null, string.Empty, this.currentTask.Destination) : new EventArgs.EncodeCompletedEventArgs(true, null, string.Empty, this.currentTask.Destination)); } - - /// - /// Service Log Message. - /// - /// Log message content - protected void ServiceLogMessage(string message) - { - this.log.LogMessage(string.Format("{0}# {1}{0}", Environment.NewLine, message), LogMessageType.ScanOrEncode, LogLevel.Info); - } #endregion } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoLevel.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoLevel.cs index e7ca53e06..4cf6724a3 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoLevel.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoLevel.cs @@ -64,20 +64,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video return new VideoLevel(this.DisplayName, this.ShortName); } - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(VideoLevel other) - { - return string.Equals(this.ShortName, other.ShortName); - } - /// /// The equals. /// @@ -114,5 +100,19 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video { return (this.ShortName != null ? this.ShortName.GetHashCode() : 0); } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(VideoLevel other) + { + return string.Equals(this.ShortName, other.ShortName); + } } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoPreset.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoPreset.cs index 8efdf5b58..887540c31 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoPreset.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoPreset.cs @@ -64,20 +64,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video return new VideoPreset(this.DisplayName, this.ShortName); } - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(VideoPreset other) - { - return string.Equals(this.ShortName, other.ShortName); - } - /// /// The equals. /// @@ -117,5 +103,19 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video { return (this.ShortName != null ? this.ShortName.GetHashCode() : 0); } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(VideoPreset other) + { + return string.Equals(this.ShortName, other.ShortName); + } } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoProfile.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoProfile.cs index 80d3fe26d..4091e4cfb 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoProfile.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoProfile.cs @@ -64,20 +64,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video return new VideoProfile(this.DisplayName, this.ShortName); } - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(VideoProfile other) - { - return string.Equals(this.DisplayName, other.DisplayName) && string.Equals(this.ShortName, other.ShortName); - } - /// /// The equals. /// @@ -117,5 +103,19 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video return ((this.DisplayName != null ? this.DisplayName.GetHashCode() : 0) * 397) ^ (this.ShortName != null ? this.ShortName.GetHashCode() : 0); } } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(VideoProfile other) + { + return string.Equals(this.DisplayName, other.DisplayName) && string.Equals(this.ShortName, other.ShortName); + } } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoTune.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoTune.cs index deba2a56f..d202cf51d 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoTune.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/Video/VideoTune.cs @@ -69,34 +69,6 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video return new VideoTune(this.DisplayName, this.ShortName); } - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(HandBrakeWPF.Services.Encode.Model.Models.Video.VideoProfile other) - { - return string.Equals(this.DisplayName, other.DisplayName) && string.Equals(this.ShortName, other.ShortName); - } - - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(VideoTune other) - { - return string.Equals(this.ShortName, other.ShortName); - } - /// /// The equals. /// @@ -133,5 +105,33 @@ namespace HandBrakeWPF.Services.Encode.Model.Models.Video { return (this.ShortName != null ? this.ShortName.GetHashCode() : 0); } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(VideoTune other) + { + return string.Equals(this.ShortName, other.ShortName); + } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(VideoProfile other) + { + return string.Equals(this.DisplayName, other.DisplayName) && string.Equals(this.ShortName, other.ShortName); + } } } diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs index 5f179f67e..8c0ff34c8 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Model/Preset.cs @@ -185,20 +185,6 @@ namespace HandBrakeWPF.Services.Presets.Model #endregion - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(Preset other) - { - return string.Equals(this.Name, other.Name); - } - /// /// The equals. /// @@ -235,5 +221,19 @@ namespace HandBrakeWPF.Services.Presets.Model { return (this.Name != null ? this.Name.GetHashCode() : 0); } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(Preset other) + { + return string.Equals(this.Name, other.Name); + } } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs index 95d2213fb..f70fd4680 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/Model/PresetDisplayCategory.cs @@ -57,11 +57,6 @@ namespace HandBrakeWPF.Services.Presets.Model } } - protected bool Equals(PresetDisplayCategory other) - { - return string.Equals(this.Category, other.Category); - } - public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; @@ -74,5 +69,10 @@ namespace HandBrakeWPF.Services.Presets.Model { return (this.Category != null ? this.Category.GetHashCode() : 0); } + + protected bool Equals(PresetDisplayCategory other) + { + return string.Equals(this.Category, other.Category); + } } } diff --git a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs index a90bf1543..61e051fcd 100644 --- a/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs +++ b/win/CS/HandBrakeWPF/Services/Presets/PresetService.cs @@ -816,8 +816,10 @@ namespace HandBrakeWPF.Services.Presets // Orgamise the Presets list into Json Equivilent objects. Dictionary presetCategories = new Dictionary(); - List uncategorisedPresets = new List(); - foreach (Preset item in this.flatPresetList.Values.OrderBy(o => o.IsBuildIn)) // Handle User Presets first. + List uncategorisedPresets = new List(); + + // Handle User Presets first. + foreach (Preset item in this.flatPresetList.Values.OrderBy(o => o.IsBuildIn)) { if (string.IsNullOrEmpty(item.Category)) { diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs index 572300dd6..ac1b28d94 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs @@ -93,20 +93,6 @@ namespace HandBrakeWPF.Services.Queue.Model #endregion - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(QueueTask other) - { - return Equals(this.ScannedSourcePath, other.ScannedSourcePath) && Equals(this.Task, other.Task) && this.status == other.status; - } - /// /// The equals. /// @@ -152,5 +138,19 @@ namespace HandBrakeWPF.Services.Queue.Model return hashCode; } } + + /// + /// The equals. + /// + /// + /// The other. + /// + /// + /// The . + /// + protected bool Equals(QueueTask other) + { + return Equals(this.ScannedSourcePath, other.ScannedSourcePath) && Equals(this.Task, other.Task) && this.status == other.status; + } } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs index 02a378da7..f7e38d5e0 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs @@ -519,6 +519,31 @@ namespace HandBrakeWPF.Services.Queue #region Methods + /// + /// The on queue completed. + /// + /// + /// The e. + /// + protected virtual void OnQueueCompleted(QueueCompletedEventArgs e) + { + QueueCompletedEventDelegate handler = this.QueueCompleted; + if (handler != null) + { + handler(this, e); + } + + this.IsProcessing = false; + } + + /// + /// The on low diskspace detected. + /// + protected virtual void OnLowDiskspaceDetected() + { + this.LowDiskspaceDetected?.Invoke(this, EventArgs.Empty); + } + /// /// After an encode is complete, move onto the next job. /// @@ -611,31 +636,6 @@ namespace HandBrakeWPF.Services.Queue handler(this, e); } } - - /// - /// The on queue completed. - /// - /// - /// The e. - /// - protected virtual void OnQueueCompleted(QueueCompletedEventArgs e) - { - QueueCompletedEventDelegate handler = this.QueueCompleted; - if (handler != null) - { - handler(this, e); - } - - this.IsProcessing = false; - } - - /// - /// The on low diskspace detected. - /// - protected virtual void OnLowDiskspaceDetected() - { - this.LowDiskspaceDetected?.Invoke(this, EventArgs.Empty); - } /// /// Run through all the jobs on the queue. diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs index ea81a9c03..7be5db8f0 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs @@ -216,6 +216,17 @@ namespace HandBrakeWPF.Services.Scan #region Private Methods + /// + /// The service log message. + /// + /// + /// The message. + /// + protected void ServiceLogMessage(string message) + { + this.log.LogMessage(string.Format("{0} # {1}{0}", Environment.NewLine, message), LogMessageType.ScanOrEncode, LogLevel.Info); + } + /// /// Start a scan for a given source path and title /// @@ -263,6 +274,7 @@ namespace HandBrakeWPF.Services.Scan #endregion #region HandBrakeInstance Event Handlers + /// /// Scan Completed Event Handler /// @@ -347,7 +359,7 @@ namespace HandBrakeWPF.Services.Scan /// /// The convert titles. /// - internal static List ConvertTitles(JsonScanObject titles) + private static List<Title> ConvertTitles(JsonScanObject titles) { List<Title> titleList = new List<Title>(); foreach (SourceTitle title in titles.TitleList) @@ -434,17 +446,6 @@ namespace HandBrakeWPF.Services.Scan return titleList; } - - /// <summary> - /// The service log message. - /// </summary> - /// <param name="message"> - /// The message. - /// </param> - protected void ServiceLogMessage(string message) - { - this.log.LogMessage(string.Format("{0} # {1}{0}", Environment.NewLine, message), LogMessageType.ScanOrEncode, LogLevel.Info); - } #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/UserSettingService.cs b/win/CS/HandBrakeWPF/Services/UserSettingService.cs index acff3209a..6d8994ac5 100644 --- a/win/CS/HandBrakeWPF/Services/UserSettingService.cs +++ b/win/CS/HandBrakeWPF/Services/UserSettingService.cs @@ -37,7 +37,7 @@ namespace HandBrakeWPF.Services /// <summary> /// The XML Serializer /// </summary> - readonly XmlSerializer serializer = new XmlSerializer(typeof(Collections.SerializableDictionary<string, object>)); + private readonly XmlSerializer serializer = new XmlSerializer(typeof(Collections.SerializableDictionary<string, object>)); /// <summary> /// The User Settings diff --git a/win/CS/HandBrakeWPF/Utilities/Execute.cs b/win/CS/HandBrakeWPF/Utilities/Execute.cs index 34fdf3a44..0282744f3 100644 --- a/win/CS/HandBrakeWPF/Utilities/Execute.cs +++ b/win/CS/HandBrakeWPF/Utilities/Execute.cs @@ -72,18 +72,6 @@ namespace HandBrakeWPF.Utilities Execute.dispatcher = (Dispatcher)null; } - /// <summary> - /// The validate dispatcher. - /// </summary> - /// <exception cref="InvalidOperationException"> - /// Not initialized with dispatcher. - /// </exception> - private static void ValidateDispatcher() - { - if (Execute.dispatcher == null) - throw new InvalidOperationException("Not initialized with dispatcher."); - } - /// <summary> /// Executes the action on the UI thread asynchronously. /// </summary> @@ -123,6 +111,20 @@ namespace HandBrakeWPF.Utilities return (Task)taskSource.Task; } + /// <summary> + /// Executes the action on the UI thread. + /// </summary> + /// <param name="action">The action to execute.</param> + public static void OnUIThread(this System.Action action) + { + if (Execute.executor != null) + Execute.executor(action); + else if (Execute.CheckAccess()) + action(); + else + Execute.OnUIThreadAsync(action).Wait(); + } + /// <summary> /// The check access. /// </summary> @@ -137,17 +139,15 @@ namespace HandBrakeWPF.Utilities } /// <summary> - /// Executes the action on the UI thread. + /// The validate dispatcher. /// </summary> - /// <param name="action">The action to execute.</param> - public static void OnUIThread(this System.Action action) + /// <exception cref="InvalidOperationException"> + /// Not initialized with dispatcher. + /// </exception> + private static void ValidateDispatcher() { - if (Execute.executor != null) - Execute.executor(action); - else if (Execute.CheckAccess()) - action(); - else - Execute.OnUIThreadAsync(action).Wait(); + if (Execute.dispatcher == null) + throw new InvalidOperationException("Not initialized with dispatcher."); } } } diff --git a/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs b/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs index ae3a401b2..08f206891 100644 --- a/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs +++ b/win/CS/HandBrakeWPF/Utilities/PropertyChangedBase.cs @@ -84,19 +84,6 @@ namespace HandBrakeWPF.Utilities this.NotifyOfPropertyChange(ExtensionMethods.GetMemberInfo((Expression)property).Name); } - /// <summary> - /// Raises the <see cref="E:PropertyChanged"/> event directly. - /// </summary> - /// <param name="e">The <see cref="T:System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> - [EditorBrowsable(EditorBrowsableState.Never)] - protected void OnPropertyChanged(PropertyChangedEventArgs e) - { - PropertyChangedEventHandler changedEventHandler = this.PropertyChanged; - if (changedEventHandler == null) - return; - changedEventHandler((object)this, e); - } - /// <summary> /// Called when the object is deserialized. /// </summary> @@ -117,5 +104,18 @@ namespace HandBrakeWPF.Utilities { return false; } + + /// <summary> + /// Raises the <see cref="E:PropertyChanged"/> event directly. + /// </summary> + /// <param name="e">The <see cref="T:System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> + [EditorBrowsable(EditorBrowsableState.Never)] + protected void OnPropertyChanged(PropertyChangedEventArgs e) + { + PropertyChangedEventHandler changedEventHandler = this.PropertyChanged; + if (changedEventHandler == null) + return; + changedEventHandler((object)this, e); + } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs index c90c9add3..ffea2554e 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs @@ -305,6 +305,24 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.Task); } + /// <summary> + /// Add all remaining for selected languages. + /// </summary> + public void AddAllRemainingForSelectedLanguages() + { + // Add them if they are not already added. + foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks()) + { + // Step 2: Check if the track list already contrains this track + bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack)); + if (!found) + { + // If it doesn't, add it. + this.Add(sourceTrack, true); + } + } + } + #endregion #region Methods @@ -442,24 +460,6 @@ namespace HandBrakeWPF.ViewModels } } - /// <summary> - /// Add all remaining for selected languages. - /// </summary> - public void AddAllRemainingForSelectedLanguages() - { - // Add them if they are not already added. - foreach (Audio sourceTrack in this.GetSelectedLanguagesTracks()) - { - // Step 2: Check if the track list already contrains this track - bool found = this.Task.AudioTracks.Any(audioTrack => Equals(audioTrack.ScannedTrack, sourceTrack)); - if (!found) - { - // If it doesn't, add it. - this.Add(sourceTrack, true); - } - } - } - /// <summary> /// The get preferred audio track, or the first if none available. /// </summary> diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs index ce82439f1..85ac495ff 100644 --- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs @@ -107,6 +107,21 @@ namespace HandBrakeWPF.ViewModels base.OnActivate(); } + /// <summary> + /// Trigger a faster / smoother way of updating the log window. + /// </summary> + /// <param name="e"> + /// The e. + /// </param> + protected virtual void OnLogMessageReceived(LogEventArgs e) + { + var onLogMessageReceived = this.LogMessageReceived; + if (onLogMessageReceived != null) + { + onLogMessageReceived.Invoke(this, e); + } + } + /// <summary> /// Handle the OnDeactivate Caliburn Event /// </summary> @@ -172,20 +187,5 @@ namespace HandBrakeWPF.ViewModels }); } } - - /// <summary> - /// Trigger a faster / smoother way of updating the log window. - /// </summary> - /// <param name="e"> - /// The e. - /// </param> - protected virtual void OnLogMessageReceived(LogEventArgs e) - { - var onLogMessageReceived = this.LogMessageReceived; - if (onLogMessageReceived != null) - { - onLogMessageReceived.Invoke(this, e); - } - } } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index fbe0f6ad0..f29e6fac0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -2091,6 +2091,33 @@ namespace HandBrakeWPF.ViewModels } } + /// <summary> + /// The process drive. + /// </summary> + /// <param name="item"> + /// The item. + /// </param> + public void ProcessDrive(object item) + { + if (item != null) + { + if (item.GetType() == typeof(DriveInformation)) + { + this.StartScan(((DriveInformation)item).RootDirectory, 0); + } + else if (item.GetType() == typeof(SourceMenuItem)) + { + DriveInformation driveInfo = ((SourceMenuItem)item).Tag as DriveInformation; + if (driveInfo != null) + { + this.StartScan(driveInfo.RootDirectory, this.TitleSpecificScan); + } + + this.ShowSourceSelection = false; + } + } + } + #endregion #region Private Methods @@ -2516,33 +2543,6 @@ namespace HandBrakeWPF.ViewModels }); } - /// <summary> - /// The process drive. - /// </summary> - /// <param name="item"> - /// The item. - /// </param> - public void ProcessDrive(object item) - { - if (item != null) - { - if (item.GetType() == typeof(DriveInformation)) - { - this.StartScan(((DriveInformation)item).RootDirectory, 0); - } - else if (item.GetType() == typeof(SourceMenuItem)) - { - DriveInformation driveInfo = ((SourceMenuItem)item).Tag as DriveInformation; - if (driveInfo != null) - { - this.StartScan(driveInfo.RootDirectory, this.TitleSpecificScan); - } - - this.ShowSourceSelection = false; - } - } - } - /// <summary> /// Allows the main window to respond to setting changes. /// </summary> diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index d98fb2d25..69338721b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -1123,15 +1123,6 @@ namespace HandBrakeWPF.ViewModels #region Public Methods - /// <summary> - /// Load / Update the user settings. - /// </summary> - protected override void OnActivate() - { - this.OnLoad(); - base.OnActivate(); - } - /// <summary> /// Close this window. /// </summary> @@ -1244,7 +1235,7 @@ namespace HandBrakeWPF.ViewModels /// </summary> public void BrowseWhenDoneAudioFile() { - OpenFileDialog dialog = new OpenFileDialog() { Filter = "All Files|*.wav;*.mp3", FileName = this.WhenDoneAudioFileFullPath }; + OpenFileDialog dialog = new OpenFileDialog() { Filter = "All Files|*.wav;*.mp3", FileName = this.WhenDoneAudioFileFullPath }; bool? dialogResult = dialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value) { @@ -1437,6 +1428,15 @@ namespace HandBrakeWPF.ViewModels this.SelectedTab = tab; } + /// <summary> + /// Load / Update the user settings. + /// </summary> + protected override void OnActivate() + { + this.OnLoad(); + base.OnActivate(); + } + /// <summary> /// Save the settings selected /// </summary> diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index 9e002ae36..f1191edae 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -41,7 +41,7 @@ namespace HandBrakeWPF.ViewModels #region Constants and Fields - private readonly Subtitle ForeignAudioSearchTrack; + private readonly Subtitle foreignAudioSearchTrack; private IList<Subtitle> sourceTracks; #endregion @@ -63,8 +63,8 @@ namespace HandBrakeWPF.ViewModels this.Langauges = LanguageUtilities.MapLanguages().Keys; this.CharacterCodes = CharCodesUtilities.GetCharacterCodes(); - this.ForeignAudioSearchTrack = new Subtitle { SubtitleType = SubtitleType.ForeignAudioSearch, Language = "Foreign Audio Search" }; - this.SourceTracks = new List<Subtitle> { this.ForeignAudioSearchTrack }; + this.foreignAudioSearchTrack = new Subtitle { SubtitleType = SubtitleType.ForeignAudioSearch, Language = "Foreign Audio Search" }; + this.SourceTracks = new List<Subtitle> { this.foreignAudioSearchTrack }; } #endregion @@ -326,7 +326,7 @@ namespace HandBrakeWPF.ViewModels // Add Foreign Audio Scan if (this.SubtitleBehaviours.AddForeignAudioScanTrack) { - this.Add(ForeignAudioSearchTrack); + this.Add(foreignAudioSearchTrack); } // Add Track Behaviours @@ -496,7 +496,7 @@ namespace HandBrakeWPF.ViewModels public void SetSource(Source source, Title title, Preset preset, EncodeTask task) { this.SourceTracks.Clear(); - this.SourceTracks.Add(ForeignAudioSearchTrack); + this.SourceTracks.Add(foreignAudioSearchTrack); foreach (Subtitle subtitle in title.Subtitles) { this.SourceTracks.Add(subtitle); @@ -534,7 +534,7 @@ namespace HandBrakeWPF.ViewModels if (source == null) { - source = ForeignAudioSearchTrack; + source = foreignAudioSearchTrack; } SubtitleTrack track = new SubtitleTrack diff --git a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs index c1a45a58f..6fe0187bc 100644 --- a/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs +++ b/win/CS/HandBrakeWPF/Views/ShellView.xaml.cs @@ -45,14 +45,11 @@ namespace HandBrakeWPF.Views { this.InitializeComponent(); - - IUserSettingService userSettingService = IoC.Get<IUserSettingService>(); bool minimiseToTray = userSettingService.GetUserSetting<bool>(UserSettingConstants.MainWindowMinimize); if (minimiseToTray) { - INotifyIconService notifyIconService = IoC.Get<INotifyIconService>(); this.notifyIcon = new NotifyIcon(); this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick), new MenuItem("Mini Status Display", ShowMiniStatusDisplay) }); @@ -86,6 +83,33 @@ namespace HandBrakeWPF.Views } } + /// <summary> + /// Check with the user before closing. + /// </summary> + /// <param name="e"> + /// The CancelEventArgs. + /// </param> + protected override void OnClosing(CancelEventArgs e) + { + IShellViewModel shellViewModel = this.DataContext as IShellViewModel; + + if (shellViewModel != null) + { + bool canClose = shellViewModel.CanClose(); + if (!canClose) + { + e.Cancel = true; + } + } + + if (this.notifyIcon != null) + { + this.notifyIcon.Visible = false; + } + + base.OnClosing(e); + } + /// <summary> /// The show mini status display. /// </summary> @@ -146,32 +170,5 @@ namespace HandBrakeWPF.Views } } } - - /// <summary> - /// Check with the user before closing. - /// </summary> - /// <param name="e"> - /// The CancelEventArgs. - /// </param> - protected override void OnClosing(CancelEventArgs e) - { - IShellViewModel shellViewModel = this.DataContext as IShellViewModel; - - if (shellViewModel != null) - { - bool canClose = shellViewModel.CanClose(); - if (!canClose) - { - e.Cancel = true; - } - } - - if (this.notifyIcon != null) - { - this.notifyIcon.Visible = false; - } - - base.OnClosing(e); - } } } -- 2.40.0