From 44b2c7e69d5613631a4ab39a91e01b673046f030 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 15 Aug 2011 16:54:19 +0000 Subject: [PATCH] WinGui: Finished re-writing the user settings service to use xml file storage rather than built-in settings. Moved all the Services Library settings over to use the service. Main application will be done later. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4175 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/Functions/PresetLoader.cs | 2 +- win/CS/Functions/QueryGenerator.cs | 8 +- .../Collections/SerializableDictionary.cs | 103 +++++++ .../HandBrake.ApplicationServices.csproj | 1 + .../Parsing/Title.cs | 9 +- .../Properties/Settings.Designer.cs | 266 +----------------- .../Properties/Settings.settings | 71 +---- .../Services/Base/EncodeBase.cs | 14 +- .../Services/Encode.cs | 13 +- .../Interfaces/IUserSettingService.cs | 45 +-- .../Services/LibEncode.cs | 11 +- .../Services/PresetService.cs | 9 +- .../Services/QueueProcessor.cs | 17 +- .../Services/ScanService.cs | 10 +- .../Services/UserSettingService.cs | 146 ++++++---- .../Utilities/GeneralUtilities.cs | 9 +- .../Utilities/PlistUtility.cs | 9 +- .../HandBrake.ApplicationServices/app.config | 74 ----- win/CS/Program.cs | 2 +- win/CS/frmAbout.cs | 4 +- win/CS/frmMain.cs | 37 +-- win/CS/frmOptions.cs | 32 +-- win/CS/frmQueue.cs | 2 +- 23 files changed, 329 insertions(+), 565 deletions(-) create mode 100644 win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs diff --git a/win/CS/Functions/PresetLoader.cs b/win/CS/Functions/PresetLoader.cs index 98ac0a0c5..195459201 100644 --- a/win/CS/Functions/PresetLoader.cs +++ b/win/CS/Functions/PresetLoader.cs @@ -307,7 +307,7 @@ namespace Handbrake.Functions sliderValue = 32 - (int)value; break; case VideoEncoder.X264: - double cqStep = UserSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + double cqStep = UserSettingService.GetUserSetting(UserSettingConstants.X264Step); sliderValue = (int)((51.0 / cqStep) - (value / cqStep)); break; case VideoEncoder.Theora: diff --git a/win/CS/Functions/QueryGenerator.cs b/win/CS/Functions/QueryGenerator.cs index 7215be30e..782c4dcf9 100644 --- a/win/CS/Functions/QueryGenerator.cs +++ b/win/CS/Functions/QueryGenerator.cs @@ -131,7 +131,7 @@ namespace Handbrake.Functions query += " -t " + titleInfo[0]; } - if (!UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav) && mainWindow.drop_angle.Items.Count != 0) + if (!UserSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav) && mainWindow.drop_angle.Items.Count != 0) query += " --angle " + mainWindow.drop_angle.SelectedItem; // Decide what part of the video we want to encode. @@ -337,7 +337,7 @@ namespace Handbrake.Functions // Video Quality Setting if (mainWindow.radio_cq.Checked) { - double cqStep = UserSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + double cqStep = UserSettingService.GetUserSetting(UserSettingConstants.X264Step); double value; switch (mainWindow.drp_videoEncoder.Text) { @@ -514,10 +514,10 @@ namespace Handbrake.Functions string query = string.Empty; // Verbosity Level - query += " --verbose=" + UserSettingService.GetUserSettingInt(UserSettingConstants.Verbosity); + query += " --verbose=" + UserSettingService.GetUserSetting(UserSettingConstants.Verbosity); // LibDVDNav - if (UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav)) + if (UserSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav)) query += " --no-dvdnav"; return query; diff --git a/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs b/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs new file mode 100644 index 000000000..b492bc2f0 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs @@ -0,0 +1,103 @@ +/* SerializableDictionary.cs $ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +namespace HandBrake.ApplicationServices.Collections +{ + using System.Collections.Generic; + using System.Runtime.Serialization; + using System.Xml.Serialization; + + /// + /// A Serializable Dictionary + /// + /// + /// The Key Type + /// + /// + /// The Value Type + /// + [XmlRoot("dictionary")] + public class SerializableDictionary : Dictionary, IXmlSerializable + { + #region IXmlSerializable Members + + /// + /// Get the Schema + /// + /// + /// Nothing. We don't use this. + /// + public System.Xml.Schema.XmlSchema GetSchema() + { + return null; + } + + /// + /// Deserialize some XML into a dictionary + /// + /// + /// The reader. + /// + public void ReadXml(System.Xml.XmlReader reader) + { + XmlSerializer keySerializer = new XmlSerializer(typeof(TKey)); + XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue)); + + bool wasEmpty = reader.IsEmptyElement; + reader.Read(); + + if (wasEmpty) + return; + + while (reader.NodeType != System.Xml.XmlNodeType.EndElement) + { + reader.ReadStartElement("item"); + + reader.ReadStartElement("key"); + TKey key = (TKey)keySerializer.Deserialize(reader); + reader.ReadEndElement(); + + reader.ReadStartElement("value"); + TValue value = (TValue)valueSerializer.Deserialize(reader); + reader.ReadEndElement(); + + this.Add(key, value); + + reader.ReadEndElement(); + reader.MoveToContent(); + } + reader.ReadEndElement(); + } + + /// + /// Write the Dictionary out to XML + /// + /// + /// The writer. + /// + public void WriteXml(System.Xml.XmlWriter writer) + { + XmlSerializer keySerializer = new XmlSerializer(typeof(TKey)); + XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue)); + + foreach (TKey key in this.Keys) + { + writer.WriteStartElement("item"); + + writer.WriteStartElement("key"); + keySerializer.Serialize(writer, key); + writer.WriteEndElement(); + + writer.WriteStartElement("value"); + TValue value = this[key]; + valueSerializer.Serialize(writer, value); + writer.WriteEndElement(); + + writer.WriteEndElement(); + } + } + #endregion + } +} diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 4a6b13b34..78480847c 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -77,6 +77,7 @@ + diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index 9b7146512..1ddb4730d 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -13,6 +13,8 @@ namespace HandBrake.ApplicationServices.Parsing using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Model.Encoding; + using HandBrake.ApplicationServices.Services; + using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.Interop.Model; using Size = System.Drawing.Size; @@ -27,6 +29,11 @@ namespace HandBrake.ApplicationServices.Parsing /// private static readonly CultureInfo Culture = new CultureInfo("en-US", false); + /// + /// The User Setting Service + /// + private static IUserSettingService userSettingService = new UserSettingService(); + /// /// Initializes a new instance of the class. /// @@ -151,7 +158,7 @@ namespace HandBrake.ApplicationServices.Parsing } // Multi-Angle Support if LibDvdNav is enabled - if (!Properties.Settings.Default.DisableLibDvdNav) + if (!userSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav)) { m = Regex.Match(nextLine, @" \+ angle\(s\) ([0-9])"); if (m.Success) diff --git a/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs b/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs index 7489ba72a..fd41570e6 100644 --- a/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs +++ b/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.431 +// Runtime Version:4.0.30319.468 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -22,269 +22,5 @@ namespace HandBrake.ApplicationServices.Properties { return defaultInstance; } } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("1")] - public int Verbosity { - get { - return ((int)(this["Verbosity"])); - } - set { - this["Verbosity"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("0.5")] - public double X264Step { - get { - return ((double)(this["X264Step"])); - } - set { - this["X264Step"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Do Nothing")] - public string WhenCompleteAction { - get { - return ((string)(this["WhenCompleteAction"])); - } - set { - this["WhenCompleteAction"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool GrowlEncode { - get { - return ((bool)(this["GrowlEncode"])); - } - set { - this["GrowlEncode"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool GrowlQueue { - get { - return ((bool)(this["GrowlQueue"])); - } - set { - this["GrowlQueue"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("Below Normal")] - public string ProcessPriority { - get { - return ((string)(this["ProcessPriority"])); - } - set { - this["ProcessPriority"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool PreventSleep { - get { - return ((bool)(this["PreventSleep"])); - } - set { - this["PreventSleep"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool ShowCLI { - get { - return ((bool)(this["ShowCLI"])); - } - set { - this["ShowCLI"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool SaveLogToCopyDirectory { - get { - return ((bool)(this["SaveLogToCopyDirectory"])); - } - set { - this["SaveLogToCopyDirectory"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool SaveLogWithVideo { - get { - return ((bool)(this["SaveLogWithVideo"])); - } - set { - this["SaveLogWithVideo"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string SaveLogCopyDirectory { - get { - return ((string)(this["SaveLogCopyDirectory"])); - } - set { - this["SaveLogCopyDirectory"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string HandBrakeVersion { - get { - return ((string)(this["HandBrakeVersion"])); - } - set { - this["HandBrakeVersion"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("0")] - public int HandBrakeBuild { - get { - return ((int)(this["HandBrakeBuild"])); - } - set { - this["HandBrakeBuild"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string InstanceId { - get { - return ((string)(this["InstanceId"])); - } - set { - this["InstanceId"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool DisableLibDvdNav { - get { - return ((bool)(this["DisableLibDvdNav"])); - } - set { - this["DisableLibDvdNav"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string HandBrakePlatform { - get { - return ((string)(this["HandBrakePlatform"])); - } - set { - this["HandBrakePlatform"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string HandBrakeExeHash { - get { - return ((string)(this["HandBrakeExeHash"])); - } - set { - this["HandBrakeExeHash"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string Setting { - get { - return ((string)(this["Setting"])); - } - set { - this["Setting"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string SendFileTo { - get { - return ((string)(this["SendFileTo"])); - } - set { - this["SendFileTo"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] - public string SendFileToArgs { - get { - return ((string)(this["SendFileToArgs"])); - } - set { - this["SendFileToArgs"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool SendFile { - get { - return ((bool)(this["SendFile"])); - } - set { - this["SendFile"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("10")] - public int MinTitleScanDuration { - get { - return ((int)(this["MinTitleScanDuration"])); - } - set { - this["MinTitleScanDuration"] = value; - } - } } } diff --git a/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings b/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings index 9ef6aaa0f..2bd17f050 100644 --- a/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings +++ b/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings @@ -1,72 +1,5 @@  - + - - - 1 - - - 0.5 - - - Do Nothing - - - False - - - False - - - Below Normal - - - True - - - False - - - False - - - False - - - - - - - - - 0 - - - - - - False - - - - - - - - - - - - - - - - - - False - - - 10 - - + \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 978d4c9af..48505fc6f 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -8,7 +8,6 @@ namespace HandBrake.ApplicationServices.Services.Base using System; using System.IO; using System.Text; - using System.Threading; using HandBrake.ApplicationServices.EventArgs; using HandBrake.ApplicationServices.Functions; @@ -28,6 +27,11 @@ namespace HandBrake.ApplicationServices.Services.Base /// private static readonly object fileWriterLock = new object(); + /// + /// The User Setting Service + /// + private IUserSettingService userSettingService = new UserSettingService(); + /// /// Windows 7 API Pack wrapper /// @@ -210,17 +214,17 @@ namespace HandBrake.ApplicationServices.Services.Base File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile)); // Save a copy of the log file in the same location as the enocde. - if (Properties.Settings.Default.SaveLogWithVideo) + if (this.userSettingService.GetUserSetting(UserSettingConstants.SaveLogWithVideo)) { File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile)); } // Save a copy of the log file to a user specified location - if (Directory.Exists(Properties.Settings.Default.SaveLogCopyDirectory) && - Properties.Settings.Default.SaveLogToCopyDirectory) + if (Directory.Exists(this.userSettingService.GetUserSetting(UserSettingConstants.SaveLogCopyDirectory)) && + this.userSettingService.GetUserSetting(UserSettingConstants.SaveLogToCopyDirectory)) { File.Copy( - tempLogFile, Path.Combine(Properties.Settings.Default.SaveLogCopyDirectory, encodeLogFile)); + tempLogFile, Path.Combine(this.userSettingService.GetUserSetting(UserSettingConstants.SaveLogCopyDirectory), encodeLogFile)); } } catch (Exception) diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 6acfe5807..04290eced 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -25,6 +25,11 @@ namespace HandBrake.ApplicationServices.Services { #region Private Variables + /// + /// The User Setting Service + /// + private IUserSettingService userSettingService = new UserSettingService(); + /// /// Gets The Process Handle /// @@ -102,7 +107,7 @@ namespace HandBrake.ApplicationServices.Services } } - if (Properties.Settings.Default.PreventSleep) + if (this.userSettingService.GetUserSetting(UserSettingConstants.PreventSleep)) { Win32.PreventSleep(); } @@ -116,7 +121,7 @@ namespace HandBrake.ApplicationServices.Services RedirectStandardOutput = true, RedirectStandardError = enableLogging ? true : false, UseShellExecute = false, - CreateNoWindow = !Properties.Settings.Default.ShowCLI ? true : false + CreateNoWindow = !this.userSettingService.GetUserSetting(UserSettingConstants.ShowCLI) ? true : false }; this.HbProcess = new Process { StartInfo = cliStart }; @@ -142,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services } // Set the Process Priority - switch (Properties.Settings.Default.ProcessPriority) + switch (this.userSettingService.GetUserSetting(UserSettingConstants.ProcessPriority)) { case "Realtime": this.HbProcess.PriorityClass = ProcessPriorityClass.RealTime; @@ -253,7 +258,7 @@ namespace HandBrake.ApplicationServices.Services this.WindowsSeven.SetTaskBarProgressToNoProgress(); } - if (Properties.Settings.Default.PreventSleep) + if (this.userSettingService.GetUserSetting(UserSettingConstants.PreventSleep)) { Win32.AllowSleep(); } diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs index 9a96edab2..c3290f64f 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs @@ -23,48 +23,18 @@ namespace HandBrake.ApplicationServices.Services.Interfaces void SetUserSetting(string name, object value); /// - /// Get an Integer type user setting + /// Get user setting for a given key. /// /// - /// The setting name - /// - /// - /// The settings value - /// - int GetUserSettingInt(string name); - - /// - /// Get an String type user setting - /// - /// - /// The setting name - /// - /// - /// The settings value - /// - string GetUserSettingString(string name); - - /// - /// Get an Boolean type user setting - /// - /// - /// The setting name + /// The name. /// + /// + /// The Type of the setting + /// /// - /// The settings value + /// The user setting /// - bool GetUserSettingBoolean(string name); - - /// - /// Get an Double type user setting - /// - /// - /// The setting name - /// - /// - /// The settings value - /// - double GetUserSettingDouble(string name); + T GetUserSetting(string name); /// /// Get an StringCollection type user setting @@ -76,6 +46,5 @@ namespace HandBrake.ApplicationServices.Services.Interfaces /// The settings value /// System.Collections.Specialized.StringCollection GetUserSettingStringCollection(string name); - } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index d7af9b224..e677d4784 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -32,6 +32,11 @@ namespace HandBrake.ApplicationServices.Services /// private static readonly object logLock = new object(); + /// + /// The User Setting Service + /// + private IUserSettingService userSettingService = new UserSettingService(); + /// /// The Start time of the current Encode; /// @@ -109,7 +114,7 @@ namespace HandBrake.ApplicationServices.Services } // Prvent the system from sleeping if the user asks - if (Properties.Settings.Default.PreventSleep) + if (this.userSettingService.GetUserSetting(UserSettingConstants.PreventSleep) ) { Win32.PreventSleep(); } @@ -121,7 +126,7 @@ namespace HandBrake.ApplicationServices.Services this.instance.StartEncode(encodeJob); // Set the Process Priority - switch (Properties.Settings.Default.ProcessPriority) + switch (this.userSettingService.GetUserSetting(UserSettingConstants.ProcessPriority)) { case "Realtime": Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; @@ -280,7 +285,7 @@ namespace HandBrake.ApplicationServices.Services this.WindowsSeven.SetTaskBarProgressToNoProgress(); } - if (Properties.Settings.Default.PreventSleep) + if (this.userSettingService.GetUserSetting(UserSettingConstants.PreventSleep)) { Win32.AllowSleep(); } diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index 09788e6b4..9cad60e4e 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -39,6 +39,11 @@ namespace HandBrake.ApplicationServices.Services /// private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List)); + /// + /// The User Setting Service + /// + private IUserSettingService userSettingService = new UserSettingService(); + /// /// The User Preset file /// @@ -257,7 +262,7 @@ namespace HandBrake.ApplicationServices.Services Category = category, Name = presetName[0].Replace("+", string.Empty).Trim(), Query = presetName[2], - Version = Properties.Settings.Default.HandBrakeVersion, + Version = this.userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion), CropSettings = pic, Description = string.Empty, // Maybe one day we will populate this. IsBuildIn = true @@ -297,7 +302,7 @@ namespace HandBrake.ApplicationServices.Services List preset = this.presets.Where(p => p.IsBuildIn).ToList(); if (preset.Count > 0) { - if (preset[0].Version != Properties.Settings.Default.HandBrakeVersion) + if (preset[0].Version != this.userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion)) { this.UpdateBuiltInPresets(); return true; diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index be9c46359..30ba395f4 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -20,6 +20,11 @@ namespace HandBrake.ApplicationServices.Services /// public class QueueProcessor : IQueueProcessor { + /// + /// The User Setting Service + /// + private static IUserSettingService userSettingService = new UserSettingService(); + /// /// Initializes a new instance of the class. /// @@ -196,7 +201,7 @@ namespace HandBrake.ApplicationServices.Services this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Completed; // Growl - if (Properties.Settings.Default.GrowlEncode) + if (userSettingService.GetUserSetting(UserSettingConstants.GrowlEncode)) GrowlCommunicator.Notify("Encode Completed", "Put down that cocktail...\nyour Handbrake encode is done."); @@ -266,10 +271,10 @@ namespace HandBrake.ApplicationServices.Services /// The file path private static void SendToApplication(string file) { - if (Properties.Settings.Default.SendFile && !string.IsNullOrEmpty(Properties.Settings.Default.SendFileTo)) + if (userSettingService.GetUserSetting(UserSettingConstants.SendFile) && !string.IsNullOrEmpty(userSettingService.GetUserSetting(UserSettingConstants.SendFileTo))) { - string args = string.Format("{0} \"{1}\"", Properties.Settings.Default.SendFileToArgs, file); - ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.SendFileTo, args); + string args = string.Format("{0} \"{1}\"", userSettingService.GetUserSetting(UserSettingConstants.SendFileToArgs), file); + ProcessStartInfo vlc = new ProcessStartInfo(userSettingService.GetUserSetting(UserSettingConstants.SendFileTo), args); Process.Start(vlc); } } @@ -280,13 +285,13 @@ namespace HandBrake.ApplicationServices.Services private static void Finish() { // Growl - if (Properties.Settings.Default.GrowlQueue) + if (userSettingService.GetUserSetting(UserSettingConstants.GrowlQueue)) { GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done."); } // Do something whent he encode ends. - switch (Properties.Settings.Default.WhenCompleteAction) + switch (userSettingService.GetUserSetting(UserSettingConstants.WhenCompleteAction)) { case "Shutdown": Process.Start("Shutdown", "-s -t 60"); diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index 3c2a736e8..652115c06 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -44,6 +44,11 @@ namespace HandBrake.ApplicationServices.Services /// StringBuilder header = GeneralUtilities.CreateCliLogHeader(); + /// + /// The User Setting Service + /// + private IUserSettingService userSettingService = new UserSettingService(); + #endregion /// @@ -190,13 +195,12 @@ namespace HandBrake.ApplicationServices.Services extraArguments += " --previews " + previewCount; } - - if (Properties.Settings.Default.DisableLibDvdNav) + if (this.userSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav)) { extraArguments += " --no-dvdnav"; } - extraArguments += string.Format(" --min-duration={0}", Properties.Settings.Default.MinTitleScanDuration); + extraArguments += string.Format(" --min-duration={0}", this.userSettingService.GetUserSetting(UserSettingConstants.MinScanDuration)); if (title > 0) { diff --git a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs index f6d6c55e2..6ef071d4b 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs @@ -5,6 +5,14 @@ namespace HandBrake.ApplicationServices.Services { + using System; + using System.Collections.Generic; + using System.Collections.Specialized; + using System.IO; + using System.Xml.Serialization; + + using HandBrake.ApplicationServices.Collections; + using HandBrake.ApplicationServices.Exceptions; using HandBrake.ApplicationServices.Services.Interfaces; /// @@ -12,6 +20,33 @@ namespace HandBrake.ApplicationServices.Services /// public class UserSettingService : IUserSettingService { + /// + /// The Settings File + /// + private readonly string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml"; + + /// + /// The XML Serializer + /// + readonly XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary)); + + /// + /// The User Settings + /// + private SerializableDictionary userSettings; + + /// + /// Initializes a new instance of the class. + /// + public UserSettingService() + { + this.Load(); + if (userSettings == null || userSettings.Count == 0) + { + this.LoadDefaults(); + } + } + /// /// Set the specified user setting. /// @@ -23,29 +58,34 @@ namespace HandBrake.ApplicationServices.Services /// public void SetUserSetting(string name, object value) { - Properties.Settings.Default[name] = value; - Properties.Settings.Default.Save(); + this.userSettings[name] = value; + this.Save(); } /// - /// Get an Integer type user setting + /// Get user setting for a given key. /// /// - /// The setting name + /// The name. /// + /// + /// The Type of the setting + /// /// - /// The settings value + /// The user setting /// - public int GetUserSettingInt(string name) + public T GetUserSetting(string name) { - int value; - int.TryParse(Properties.Settings.Default[name].ToString(), out value); + if (this.userSettings.ContainsKey(name)) + { + return (T)this.userSettings[name]; + } - return value; + return default(T); } /// - /// Get an String type user setting + /// Get an StringCollection type user setting /// /// /// The setting name @@ -53,62 +93,68 @@ namespace HandBrake.ApplicationServices.Services /// /// The settings value /// - public string GetUserSettingString(string name) + public StringCollection GetUserSettingStringCollection(string name) { - return Properties.Settings.Default[name].ToString(); + return (StringCollection)this.userSettings[name]; } /// - /// Get an Boolean type user setting + /// Save the User Settings /// - /// - /// The setting name - /// - /// - /// The settings value - /// - public bool GetUserSettingBoolean(string name) + private void Save() { - bool value; - bool.TryParse(Properties.Settings.Default[name].ToString(), out value); - - return value; + using (FileStream strm = new FileStream(this.settingsFile, FileMode.Create, FileAccess.Write)) + { + serializer.Serialize(strm, this.userSettings); + } } /// - /// Get an Double type user setting + /// Load the User Settings /// - /// - /// The setting name - /// - /// - /// The settings value - /// - public double GetUserSettingDouble(string name) + private void Load() { - double value; - double.TryParse(Properties.Settings.Default[name].ToString(), out value); - - return value; + try + { + if (File.Exists(this.settingsFile)) + { + using (StreamReader reader = new StreamReader(this.settingsFile)) + { + SerializableDictionary data = (SerializableDictionary)serializer.Deserialize(reader); + this.userSettings = data; + } + } + } + catch (Exception exc) + { + throw new GeneralApplicationException( + "HandBrake has detected corruption in the settings file. User settings will now be reset to defaults.", + "Please restart HandBrake before continuing.", + exc); + } } /// - /// Get an StringCollection type user setting + /// Load Default Settings /// - /// - /// The setting name - /// - /// - /// The settings value - /// - public System.Collections.Specialized.StringCollection GetUserSettingStringCollection(string name) + private void LoadDefaults() { - System.Collections.Specialized.StringCollection value; - - value = (System.Collections.Specialized.StringCollection) Properties.Settings.Default[name]; - - return value; + // TODO, maybe extract this out to a file. + userSettings = new SerializableDictionary(); + userSettings[UserSettingConstants.X264Step] = 0.25; + userSettings[UserSettingConstants.Verbosity] = 1; + userSettings[UserSettingConstants.WhenCompleteAction] = "Do Nothing"; + userSettings[UserSettingConstants.GrowlEncode] = false; + userSettings[UserSettingConstants.GrowlQueue] = false; + userSettings[UserSettingConstants.ProcessPriority] = "Below Normal"; + userSettings[UserSettingConstants.PreventSleep] = true; + userSettings[UserSettingConstants.ShowCLI] = false; + userSettings[UserSettingConstants.SaveLogToCopyDirectory] = false; + userSettings[UserSettingConstants.SaveLogWithVideo] = false; + userSettings[UserSettingConstants.DisableLibDvdNav] = false; + userSettings[UserSettingConstants.SendFile] = false; + userSettings[UserSettingConstants.MinScanDuration] = 10; + userSettings[UserSettingConstants.HandBrakeBuild] = 0; } - } } diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index 40317d8b7..746f36937 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -14,12 +14,19 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Functions; using HandBrake.ApplicationServices.Model; + using HandBrake.ApplicationServices.Services; + using HandBrake.ApplicationServices.Services.Interfaces; /// /// A Set of Static Utilites /// public class GeneralUtilities { + /// + /// The User Setting Service + /// + private static IUserSettingService userSettingService = new UserSettingService(); + /// /// The Default Log Directory /// @@ -106,7 +113,7 @@ namespace HandBrake.ApplicationServices.Utilities { StringBuilder logHeader = new StringBuilder(); - logHeader.AppendLine(String.Format("HandBrake {0} {1}", Properties.Settings.Default.HandBrakeVersion, Properties.Settings.Default.HandBrakeBuild)); + logHeader.AppendLine(String.Format("HandBrake {0} {1}", userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild))); logHeader.AppendLine(String.Format("OS: {0}", Environment.OSVersion)); logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount)); logHeader.Append(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory)); diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 3b514b198..a75741277 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -15,6 +15,8 @@ namespace HandBrake.ApplicationServices.Utilities using HandBrake.ApplicationServices.Functions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Model.Encoding; + using HandBrake.ApplicationServices.Services; + using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.Interop.Model.Encoding; /// @@ -22,6 +24,11 @@ namespace HandBrake.ApplicationServices.Utilities /// public class PlistPresetHandler { + /// + /// The User Setting Service + /// + private static IUserSettingService userSettingService = new UserSettingService(); + /** * TODO: * - Update with the new vfr,pfr,cfr keys @@ -540,7 +547,7 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString()); // Preset Information - AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", Properties.Settings.Default.HandBrakeBuild.ToString()); + AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild)); AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description"); AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name); AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in diff --git a/win/CS/HandBrake.ApplicationServices/app.config b/win/CS/HandBrake.ApplicationServices/app.config index c2bffe7e3..1747ee2d8 100644 --- a/win/CS/HandBrake.ApplicationServices/app.config +++ b/win/CS/HandBrake.ApplicationServices/app.config @@ -1,83 +1,9 @@ - -
- - - - - - 1 - - - 0.5 - - - Do Nothing - - - False - - - False - - - Below Normal - - - True - - - False - - - False - - - False - - - - - - - - - 0 - - - - - - False - - - - - - - - - - - - - - - - - - False - - - 10 - - - diff --git a/win/CS/Program.cs b/win/CS/Program.cs index 4e7dfcbc0..406d8d0bb 100644 --- a/win/CS/Program.cs +++ b/win/CS/Program.cs @@ -67,7 +67,7 @@ namespace Handbrake // Going from major to major will require the user to reset. // Going from svn to svn will attempt the upgrade. UserSettingService service = new UserSettingService(); - string version = service.GetUserSettingString(UserSettingConstants.HandBrakeVersion); + string version = service.GetUserSetting(UserSettingConstants.HandBrakeVersion); if (version.Contains("svn")) { Settings.Default.Upgrade(); diff --git a/win/CS/frmAbout.cs b/win/CS/frmAbout.cs index 05a2765c2..7bceabdb6 100644 --- a/win/CS/frmAbout.cs +++ b/win/CS/frmAbout.cs @@ -26,8 +26,8 @@ namespace Handbrake { InitializeComponent(); - string nightly = userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty; - lbl_GUIBuild.Text = userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion) + " (" + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild) + ") " + nightly; + string nightly = userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty; + lbl_GUIBuild.Text = userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion) + " (" + userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild) + ") " + nightly; } /// diff --git a/win/CS/frmMain.cs b/win/CS/frmMain.cs index 0a01b6571..64c92ce0a 100644 --- a/win/CS/frmMain.cs +++ b/win/CS/frmMain.cs @@ -134,9 +134,9 @@ namespace Handbrake // Update the users config file with the CLI version data. Main.SetCliVersionData(); - if (userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion).Contains("svn")) + if (userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion).Contains("svn")) { - this.Text += " " + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion); + this.Text += " " + userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion); } // Check for new versions, if update checking is enabled @@ -147,10 +147,11 @@ namespace Handbrake // Set when the last update was Settings.Default.lastUpdateCheckDate = DateTime.Now; Settings.Default.Save(); - string url = this.userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild).EndsWith("1") + string url = this.userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild).ToString().EndsWith("1") ? Settings.Default.appcast_unstable : Settings.Default.appcast; - UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSettingInt(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion)); + UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild), + Settings.Default.skipversion, userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion)); } } @@ -212,7 +213,7 @@ namespace Handbrake if (info.NewVersionAvailable) { - UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild)); + UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild)); updateWindow.ShowDialog(); } } @@ -453,10 +454,10 @@ namespace Handbrake lbl_updateCheck.Visible = true; Settings.Default.lastUpdateCheckDate = DateTime.Now; Settings.Default.Save(); - string url = userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild).EndsWith("1") + string url = userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild).EndsWith("1") ? Settings.Default.appcast_unstable : Settings.Default.appcast; - UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDoneMenu), false, url, userSettingService.GetUserSettingInt(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion)); + UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDoneMenu), false, url, userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion)); } /// @@ -947,7 +948,7 @@ namespace Handbrake { if (btn_start.Text == "Stop") { - DialogResult result = !userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI) + DialogResult result = !userSettingService.GetUserSetting(UserSettingConstants.ShowCLI) ? MessageBox.Show( "Are you sure you wish to cancel the encode?\n\nPlease note: Stopping this encode will render the file unplayable. ", "Cancel Encode?", @@ -964,7 +965,7 @@ namespace Handbrake // Pause The Queue this.queueProcessor.Pause(); - if (userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI)) + if (userSettingService.GetUserSetting(UserSettingConstants.ShowCLI)) this.queueProcessor.EncodeService.SafelyStop(); else this.queueProcessor.EncodeService.Stop(); @@ -1435,7 +1436,7 @@ namespace Handbrake // Populate the Angles dropdown drop_angle.Items.Clear(); - if (!userSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav)) + if (!userSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav)) { drop_angle.Visible = true; lbl_angle.Visible = true; @@ -1790,11 +1791,11 @@ namespace Handbrake case "H.264 (x264)": slider_videoQuality.Minimum = 0; slider_videoQuality.TickFrequency = 1; - double cqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + double cqStep = userSettingService.GetUserSetting(UserSettingConstants.X264Step); double multiplier = 1.0 / cqStep; double value = slider_videoQuality.Value * multiplier; - slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step)); + slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSetting(UserSettingConstants.X264Step)); if (value < slider_videoQuality.Maximum) slider_videoQuality.Value = slider_videoQuality.Maximum - (int)value; @@ -1861,7 +1862,7 @@ namespace Handbrake { if (cachedCqStep == 0) { - cachedCqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + cachedCqStep = userSettingService.GetUserSetting(UserSettingConstants.X264Step); } // Work out the current RF value. @@ -1869,13 +1870,13 @@ namespace Handbrake double rfValue = 51.0 - slider_videoQuality.Value * cqStep; // Change the maximum value for the slider - slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step)); + slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSetting(UserSettingConstants.X264Step)); // Reset the CQ slider to RF0 slider_videoQuality.Value = slider_videoQuality.Maximum; // Reset the CQ slider back to the previous value as close as possible - double cqStepNew = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + double cqStepNew = userSettingService.GetUserSetting(UserSettingConstants.X264Step); double rfValueCurrent = 51.0 - slider_videoQuality.Value * cqStepNew; while (rfValueCurrent < rfValue) { @@ -1884,12 +1885,12 @@ namespace Handbrake } // Cache the CQ step for the next calculation - this.cachedCqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + this.cachedCqStep = userSettingService.GetUserSetting(UserSettingConstants.X264Step); } private void slider_videoQuality_Scroll(object sender, EventArgs e) { - double cqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step); + double cqStep = userSettingService.GetUserSetting(UserSettingConstants.X264Step); switch (drp_videoEncoder.Text) { case "MPEG-4 (FFmpeg)": @@ -2494,7 +2495,7 @@ namespace Handbrake if (info.NewVersionAvailable) { - UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild)); + UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSetting(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting(UserSettingConstants.HandBrakeBuild)); updateWindow.ShowDialog(); } else diff --git a/win/CS/frmOptions.cs b/win/CS/frmOptions.cs index ecf973086..ac8092333 100644 --- a/win/CS/frmOptions.cs +++ b/win/CS/frmOptions.cs @@ -84,18 +84,18 @@ namespace Handbrake } // On Encode Completeion Action - drp_completeOption.Text = userSettingService.GetUserSettingString("WhenCompleteAction"); + drp_completeOption.Text = userSettingService.GetUserSetting("WhenCompleteAction"); // Growl. - if (userSettingService.GetUserSettingBoolean(UserSettingConstants.GrowlEncode)) + if (userSettingService.GetUserSetting(UserSettingConstants.GrowlEncode)) check_growlEncode.CheckState = CheckState.Checked; - if (userSettingService.GetUserSettingBoolean(UserSettingConstants.GrowlQueue)) + if (userSettingService.GetUserSetting(UserSettingConstants.GrowlQueue)) check_GrowlQueue.CheckState = CheckState.Checked; - check_sendFileTo.Checked = this.userSettingService.GetUserSettingBoolean(UserSettingConstants.SendFile); - lbl_sendFileTo.Text = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSettingString(UserSettingConstants.SendFileTo)); - txt_SendFileArgs.Text = this.userSettingService.GetUserSettingString(UserSettingConstants.SendFileToArgs); + check_sendFileTo.Checked = this.userSettingService.GetUserSetting(UserSettingConstants.SendFile); + lbl_sendFileTo.Text = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting(UserSettingConstants.SendFileTo)); + txt_SendFileArgs.Text = this.userSettingService.GetUserSetting(UserSettingConstants.SendFileToArgs); // ############################# // Output Settings @@ -177,23 +177,23 @@ namespace Handbrake // ############################# // Priority level for encodes - drp_Priority.Text = userSettingService.GetUserSettingString(UserSettingConstants.ProcessPriority); + drp_Priority.Text = userSettingService.GetUserSetting(UserSettingConstants.ProcessPriority); - check_preventSleep.Checked = userSettingService.GetUserSettingBoolean(UserSettingConstants.PreventSleep); + check_preventSleep.Checked = userSettingService.GetUserSetting(UserSettingConstants.PreventSleep); // Log Verbosity Level - cb_logVerboseLvl.SelectedIndex = userSettingService.GetUserSettingInt(UserSettingConstants.Verbosity); + cb_logVerboseLvl.SelectedIndex = userSettingService.GetUserSetting(UserSettingConstants.Verbosity); // Save logs in the same directory as encoded files - if (userSettingService.GetUserSettingBoolean(UserSettingConstants.SaveLogWithVideo)) + if (userSettingService.GetUserSetting(UserSettingConstants.SaveLogWithVideo)) check_saveLogWithVideo.CheckState = CheckState.Checked; // Save Logs in a specified path - if (userSettingService.GetUserSettingBoolean(UserSettingConstants.SaveLogToCopyDirectory)) + if (userSettingService.GetUserSetting(UserSettingConstants.SaveLogToCopyDirectory)) check_logsInSpecifiedLocation.CheckState = CheckState.Checked; // The saved log path - text_logPath.Text = userSettingService.GetUserSettingString(UserSettingConstants.SaveLogCopyDirectory); + text_logPath.Text = userSettingService.GetUserSetting(UserSettingConstants.SaveLogCopyDirectory); check_clearOldLogs.Checked = Properties.Settings.Default.clearOldLogs; @@ -222,13 +222,13 @@ namespace Handbrake check_disablePresetNotification.CheckState = CheckState.Checked; // Show CLI Window - check_showCliForInGUIEncode.Checked = userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI); + check_showCliForInGUIEncode.Checked = userSettingService.GetUserSetting(UserSettingConstants.ShowCLI); // Set the preview count drop_previewScanCount.SelectedItem = Properties.Settings.Default.previewScanCount.ToString(); // x264 step - string step = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step).ToString(new CultureInfo("en-US")); + string step = userSettingService.GetUserSetting(UserSettingConstants.X264Step).ToString(new CultureInfo("en-US")); switch (step) { case "1": @@ -246,10 +246,10 @@ namespace Handbrake } // Min Title Length - ud_minTitleLength.Value = this.userSettingService.GetUserSettingInt(UserSettingConstants.MinScanDuration); + ud_minTitleLength.Value = this.userSettingService.GetUserSetting(UserSettingConstants.MinScanDuration); // Use Experimental dvdnav - if (userSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav)) + if (userSettingService.GetUserSetting(UserSettingConstants.DisableLibDvdNav)) check_dvdnav.CheckState = CheckState.Checked; optionsWindowLoading = false; diff --git a/win/CS/frmQueue.cs b/win/CS/frmQueue.cs index 04cb91276..fc433f1a5 100644 --- a/win/CS/frmQueue.cs +++ b/win/CS/frmQueue.cs @@ -76,7 +76,7 @@ namespace Handbrake queue.EncodeService.EncodeStarted += this.queue_EncodeStarted; queue.EncodeService.EncodeCompleted += this.queue_EncodeEnded; - drp_completeOption.Text = userSettingService.GetUserSettingString(UserSettingConstants.WhenCompleteAction); + drp_completeOption.Text = userSettingService.GetUserSetting(UserSettingConstants.WhenCompleteAction); } /// -- 2.40.0