]> granicus.if.org Git - handbrake/commitdiff
WinGui: Finished re-writing the user settings service to use xml file storage rather...
authorsr55 <sr55.hb@outlook.com>
Mon, 15 Aug 2011 16:54:19 +0000 (16:54 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 15 Aug 2011 16:54:19 +0000 (16:54 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4175 b64f7644-9d1e-0410-96f1-a4d463321fa5

23 files changed:
win/CS/Functions/PresetLoader.cs
win/CS/Functions/QueryGenerator.cs
win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs [new file with mode: 0644]
win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs
win/CS/HandBrake.ApplicationServices/Properties/Settings.settings
win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs
win/CS/HandBrake.ApplicationServices/Services/Encode.cs
win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs
win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs
win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs
win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
win/CS/HandBrake.ApplicationServices/app.config
win/CS/Program.cs
win/CS/frmAbout.cs
win/CS/frmMain.cs
win/CS/frmOptions.cs
win/CS/frmQueue.cs

index 98ac0a0c5e38afc54abd5b5a9e2d2777ff83fe32..195459201e75f79d1338e4548982b0f1836517d1 100644 (file)
@@ -307,7 +307,7 @@ namespace Handbrake.Functions
                     sliderValue = 32 - (int)value;\r
                     break;\r
                 case VideoEncoder.X264:\r
-                    double cqStep = UserSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+                    double cqStep = UserSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
                     sliderValue = (int)((51.0 / cqStep) - (value / cqStep));\r
                     break;\r
                 case VideoEncoder.Theora:\r
index 7215be30e905ccfe2751704b14d37ddc04e9a442..782c4dcf908ba811b54b837b92c359eeda9e2aa7 100644 (file)
@@ -131,7 +131,7 @@ namespace Handbrake.Functions
                 query += " -t " + titleInfo[0];\r
             }\r
 \r
-            if (!UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav) && mainWindow.drop_angle.Items.Count != 0)\r
+            if (!UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav) && mainWindow.drop_angle.Items.Count != 0)\r
                 query += " --angle " + mainWindow.drop_angle.SelectedItem;\r
 \r
             // Decide what part of the video we want to encode.\r
@@ -337,7 +337,7 @@ namespace Handbrake.Functions
             // Video Quality Setting\r
             if (mainWindow.radio_cq.Checked)\r
             {\r
-                double cqStep = UserSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+                double cqStep = UserSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
                 double value;\r
                 switch (mainWindow.drp_videoEncoder.Text)\r
                 {\r
@@ -514,10 +514,10 @@ namespace Handbrake.Functions
             string query = string.Empty;\r
 \r
             // Verbosity Level\r
-            query += " --verbose=" + UserSettingService.GetUserSettingInt(UserSettingConstants.Verbosity);\r
+            query += " --verbose=" + UserSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity);\r
 \r
             // LibDVDNav\r
-            if (UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav))\r
+            if (UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))\r
                 query += " --no-dvdnav";\r
 \r
             return query;\r
diff --git a/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs b/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs
new file mode 100644 (file)
index 0000000..b492bc2
--- /dev/null
@@ -0,0 +1,103 @@
+/*  SerializableDictionary.cs $\r
+    This file is part of the HandBrake source code.\r
+    Homepage: <http://handbrake.fr>.\r
+    It may be used under the terms of the GNU General Public License. */\r
+\r
+namespace HandBrake.ApplicationServices.Collections\r
+{\r
+    using System.Collections.Generic;\r
+    using System.Runtime.Serialization;\r
+    using System.Xml.Serialization;\r
+\r
+    /// <summary>\r
+    /// A Serializable Dictionary\r
+    /// </summary>\r
+    /// <typeparam name="TKey">\r
+    /// The Key Type\r
+    /// </typeparam>\r
+    /// <typeparam name="TValue">\r
+    /// The Value Type\r
+    /// </typeparam>\r
+    [XmlRoot("dictionary")]\r
+    public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable\r
+    {\r
+        #region IXmlSerializable Members\r
+\r
+        /// <summary>\r
+        /// Get the Schema\r
+        /// </summary>\r
+        /// <returns>\r
+        /// Nothing. We don't use this.\r
+        /// </returns>\r
+        public System.Xml.Schema.XmlSchema GetSchema()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        /// <summary>\r
+        /// Deserialize some XML into a dictionary\r
+        /// </summary>\r
+        /// <param name="reader">\r
+        /// The reader.\r
+        /// </param>\r
+        public void ReadXml(System.Xml.XmlReader reader)\r
+        {\r
+            XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));\r
+            XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));\r
+\r
+            bool wasEmpty = reader.IsEmptyElement;\r
+            reader.Read();\r
+\r
+            if (wasEmpty)\r
+                return;\r
+\r
+            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)\r
+            {\r
+                reader.ReadStartElement("item");\r
+\r
+                reader.ReadStartElement("key");\r
+                TKey key = (TKey)keySerializer.Deserialize(reader);\r
+                reader.ReadEndElement();\r
+\r
+                reader.ReadStartElement("value");\r
+                TValue value = (TValue)valueSerializer.Deserialize(reader);\r
+                reader.ReadEndElement();\r
+\r
+                this.Add(key, value);\r
+\r
+                reader.ReadEndElement();\r
+                reader.MoveToContent();\r
+            }\r
+            reader.ReadEndElement();\r
+        }\r
+\r
+        /// <summary>\r
+        /// Write the Dictionary out to XML\r
+        /// </summary>\r
+        /// <param name="writer">\r
+        /// The writer.\r
+        /// </param>\r
+        public void WriteXml(System.Xml.XmlWriter writer)\r
+        {\r
+            XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));\r
+            XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));\r
+\r
+            foreach (TKey key in this.Keys)\r
+            {\r
+                writer.WriteStartElement("item");\r
+\r
+                writer.WriteStartElement("key");\r
+                keySerializer.Serialize(writer, key);\r
+                writer.WriteEndElement();\r
+\r
+                writer.WriteStartElement("value");\r
+                TValue value = this[key];\r
+                valueSerializer.Serialize(writer, value);\r
+                writer.WriteEndElement();\r
+\r
+                writer.WriteEndElement();\r
+            }\r
+        }\r
+        #endregion\r
+    }\r
+}\r
index 4a6b13b34f396cabc98e97268c22a7d80ebcf238..78480847c1b9a129e34a8d6c83707b30ba5cbae2 100644 (file)
@@ -77,6 +77,7 @@
     <Reference Include="WindowsBase" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="Collections\SerializableDictionary.cs" />\r
     <Compile Include="Converters\EnumToDescConverter.cs" />\r
     <Compile Include="Exceptions\GeneralApplicationException.cs" />\r
     <Compile Include="EventArgs\EncodeCompletedEventArgs.cs" />\r
index 9b71465121370e22f6a73b04ab6704c12e05d4f7..1ddb4730d62630cc9d04cbb7b741e122a42da3f6 100644 (file)
@@ -13,6 +13,8 @@ namespace HandBrake.ApplicationServices.Parsing
 \r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Model.Encoding;\r
+    using HandBrake.ApplicationServices.Services;\r
+    using HandBrake.ApplicationServices.Services.Interfaces;\r
     using HandBrake.Interop.Model;\r
 \r
     using Size = System.Drawing.Size;\r
@@ -27,6 +29,11 @@ namespace HandBrake.ApplicationServices.Parsing
         /// </summary>\r
         private static readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
 \r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private static IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// Initializes a new instance of the <see cref="Title"/> class. \r
         /// </summary>\r
@@ -151,7 +158,7 @@ namespace HandBrake.ApplicationServices.Parsing
             }\r
        \r
             // Multi-Angle Support if LibDvdNav is enabled\r
-            if (!Properties.Settings.Default.DisableLibDvdNav)\r
+            if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))\r
             {\r
                 m = Regex.Match(nextLine, @"  \+ angle\(s\) ([0-9])");\r
                 if (m.Success)\r
index 7489ba72a1800b79fd87c52c8fbf9e89517ad732..fd41570e6f1c1287b36566f4ed370fcf672cb5e3 100644 (file)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------\r
 // <auto-generated>\r
 //     This code was generated by a tool.\r
-//     Runtime Version:4.0.30319.431\r
+//     Runtime Version:4.0.30319.468\r
 //\r
 //     Changes to this file may cause incorrect behavior and will be lost if\r
 //     the code is regenerated.\r
@@ -22,269 +22,5 @@ namespace HandBrake.ApplicationServices.Properties {
                 return defaultInstance;\r
             }\r
         }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("1")]\r
-        public int Verbosity {\r
-            get {\r
-                return ((int)(this["Verbosity"]));\r
-            }\r
-            set {\r
-                this["Verbosity"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("0.5")]\r
-        public double X264Step {\r
-            get {\r
-                return ((double)(this["X264Step"]));\r
-            }\r
-            set {\r
-                this["X264Step"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("Do Nothing")]\r
-        public string WhenCompleteAction {\r
-            get {\r
-                return ((string)(this["WhenCompleteAction"]));\r
-            }\r
-            set {\r
-                this["WhenCompleteAction"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool GrowlEncode {\r
-            get {\r
-                return ((bool)(this["GrowlEncode"]));\r
-            }\r
-            set {\r
-                this["GrowlEncode"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool GrowlQueue {\r
-            get {\r
-                return ((bool)(this["GrowlQueue"]));\r
-            }\r
-            set {\r
-                this["GrowlQueue"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("Below Normal")]\r
-        public string ProcessPriority {\r
-            get {\r
-                return ((string)(this["ProcessPriority"]));\r
-            }\r
-            set {\r
-                this["ProcessPriority"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("True")]\r
-        public bool PreventSleep {\r
-            get {\r
-                return ((bool)(this["PreventSleep"]));\r
-            }\r
-            set {\r
-                this["PreventSleep"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool ShowCLI {\r
-            get {\r
-                return ((bool)(this["ShowCLI"]));\r
-            }\r
-            set {\r
-                this["ShowCLI"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool SaveLogToCopyDirectory {\r
-            get {\r
-                return ((bool)(this["SaveLogToCopyDirectory"]));\r
-            }\r
-            set {\r
-                this["SaveLogToCopyDirectory"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool SaveLogWithVideo {\r
-            get {\r
-                return ((bool)(this["SaveLogWithVideo"]));\r
-            }\r
-            set {\r
-                this["SaveLogWithVideo"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string SaveLogCopyDirectory {\r
-            get {\r
-                return ((string)(this["SaveLogCopyDirectory"]));\r
-            }\r
-            set {\r
-                this["SaveLogCopyDirectory"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string HandBrakeVersion {\r
-            get {\r
-                return ((string)(this["HandBrakeVersion"]));\r
-            }\r
-            set {\r
-                this["HandBrakeVersion"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("0")]\r
-        public int HandBrakeBuild {\r
-            get {\r
-                return ((int)(this["HandBrakeBuild"]));\r
-            }\r
-            set {\r
-                this["HandBrakeBuild"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string InstanceId {\r
-            get {\r
-                return ((string)(this["InstanceId"]));\r
-            }\r
-            set {\r
-                this["InstanceId"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool DisableLibDvdNav {\r
-            get {\r
-                return ((bool)(this["DisableLibDvdNav"]));\r
-            }\r
-            set {\r
-                this["DisableLibDvdNav"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string HandBrakePlatform {\r
-            get {\r
-                return ((string)(this["HandBrakePlatform"]));\r
-            }\r
-            set {\r
-                this["HandBrakePlatform"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string HandBrakeExeHash {\r
-            get {\r
-                return ((string)(this["HandBrakeExeHash"]));\r
-            }\r
-            set {\r
-                this["HandBrakeExeHash"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string Setting {\r
-            get {\r
-                return ((string)(this["Setting"]));\r
-            }\r
-            set {\r
-                this["Setting"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string SendFileTo {\r
-            get {\r
-                return ((string)(this["SendFileTo"]));\r
-            }\r
-            set {\r
-                this["SendFileTo"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("")]\r
-        public string SendFileToArgs {\r
-            get {\r
-                return ((string)(this["SendFileToArgs"]));\r
-            }\r
-            set {\r
-                this["SendFileToArgs"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("False")]\r
-        public bool SendFile {\r
-            get {\r
-                return ((bool)(this["SendFile"]));\r
-            }\r
-            set {\r
-                this["SendFile"] = value;\r
-            }\r
-        }\r
-        \r
-        [global::System.Configuration.UserScopedSettingAttribute()]\r
-        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("10")]\r
-        public int MinTitleScanDuration {\r
-            get {\r
-                return ((int)(this["MinTitleScanDuration"]));\r
-            }\r
-            set {\r
-                this["MinTitleScanDuration"] = value;\r
-            }\r
-        }\r
     }\r
 }\r
index 9ef6aaa0f4d153305edb7f458cb7b226228041e5..2bd17f050c79279d80de789ed2c6a00bffabae92 100644 (file)
@@ -1,72 +1,5 @@
 <?xml version='1.0' encoding='utf-8'?>\r
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HandBrake.ApplicationServices.Properties" GeneratedClassName="Settings">\r
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">\r
   <Profiles />\r
-  <Settings>\r
-    <Setting Name="Verbosity" Type="System.Int32" Scope="User">\r
-      <Value Profile="(Default)">1</Value>\r
-    </Setting>\r
-    <Setting Name="X264Step" Type="System.Double" Scope="User">\r
-      <Value Profile="(Default)">0.5</Value>\r
-    </Setting>\r
-    <Setting Name="WhenCompleteAction" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">Do Nothing</Value>\r
-    </Setting>\r
-    <Setting Name="GrowlEncode" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="GrowlQueue" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="ProcessPriority" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">Below Normal</Value>\r
-    </Setting>\r
-    <Setting Name="PreventSleep" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">True</Value>\r
-    </Setting>\r
-    <Setting Name="ShowCLI" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="SaveLogToCopyDirectory" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="SaveLogWithVideo" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="SaveLogCopyDirectory" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="HandBrakeVersion" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="HandBrakeBuild" Type="System.Int32" Scope="User">\r
-      <Value Profile="(Default)">0</Value>\r
-    </Setting>\r
-    <Setting Name="InstanceId" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="DisableLibDvdNav" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="HandBrakePlatform" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="HandBrakeExeHash" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="Setting" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="SendFileTo" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="SendFileToArgs" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)" />\r
-    </Setting>\r
-    <Setting Name="SendFile" Type="System.Boolean" Scope="User">\r
-      <Value Profile="(Default)">False</Value>\r
-    </Setting>\r
-    <Setting Name="MinTitleScanDuration" Type="System.Int32" Scope="User">\r
-      <Value Profile="(Default)">10</Value>\r
-    </Setting>\r
-  </Settings>\r
+  <Settings />\r
 </SettingsFile>
\ No newline at end of file
index 978d4c9afe11ba4479f360319e8f4fbabb6d5e39..48505fc6fd2a36db74a26e111a56cb78346fdab5 100644 (file)
@@ -8,7 +8,6 @@ namespace HandBrake.ApplicationServices.Services.Base
     using System;\r
     using System.IO;\r
     using System.Text;\r
-    using System.Threading;\r
 \r
     using HandBrake.ApplicationServices.EventArgs;\r
     using HandBrake.ApplicationServices.Functions;\r
@@ -28,6 +27,11 @@ namespace HandBrake.ApplicationServices.Services.Base
         /// </summary>\r
         private static readonly object fileWriterLock = new object();\r
 \r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// Windows 7 API Pack wrapper\r
         /// </summary>\r
@@ -210,17 +214,17 @@ namespace HandBrake.ApplicationServices.Services.Base
                 File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));\r
 \r
                 // Save a copy of the log file in the same location as the enocde.\r
-                if (Properties.Settings.Default.SaveLogWithVideo)\r
+                if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo))\r
                 {\r
                     File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));\r
                 }\r
 \r
                 // Save a copy of the log file to a user specified location\r
-                if (Directory.Exists(Properties.Settings.Default.SaveLogCopyDirectory) &&\r
-                    Properties.Settings.Default.SaveLogToCopyDirectory)\r
+                if (Directory.Exists(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory)) &&\r
+                    this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory))\r
                 {\r
                     File.Copy(\r
-                        tempLogFile, Path.Combine(Properties.Settings.Default.SaveLogCopyDirectory, encodeLogFile));\r
+                        tempLogFile, Path.Combine(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory), encodeLogFile));\r
                 }\r
             }\r
             catch (Exception)\r
index 6acfe58074c2154525dd51eb545a2601747b15b4..04290eceda08d244f6508c1013d45024318b3d9c 100644 (file)
@@ -25,6 +25,11 @@ namespace HandBrake.ApplicationServices.Services
     {\r
         #region Private Variables\r
 \r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// Gets The Process Handle\r
         /// </summary>\r
@@ -102,7 +107,7 @@ namespace HandBrake.ApplicationServices.Services
                     }\r
                 }\r
 \r
-                if (Properties.Settings.Default.PreventSleep)\r
+                if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))\r
                 {\r
                     Win32.PreventSleep();\r
                 }\r
@@ -116,7 +121,7 @@ namespace HandBrake.ApplicationServices.Services
                     RedirectStandardOutput = true,\r
                     RedirectStandardError = enableLogging ? true : false,\r
                     UseShellExecute = false,\r
-                    CreateNoWindow = !Properties.Settings.Default.ShowCLI ? true : false\r
+                    CreateNoWindow = !this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowCLI) ? true : false\r
                 };\r
 \r
                 this.HbProcess = new Process { StartInfo = cliStart };\r
@@ -142,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services
                 }\r
 \r
                 // Set the Process Priority\r
-                switch (Properties.Settings.Default.ProcessPriority)\r
+                switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority))\r
                 {\r
                     case "Realtime":\r
                         this.HbProcess.PriorityClass = ProcessPriorityClass.RealTime;\r
@@ -253,7 +258,7 @@ namespace HandBrake.ApplicationServices.Services
                 this.WindowsSeven.SetTaskBarProgressToNoProgress();\r
             }\r
 \r
-            if (Properties.Settings.Default.PreventSleep)\r
+            if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))\r
             {\r
                 Win32.AllowSleep();\r
             }\r
index 9a96edab23855b199954ec34e0e36313ee9c94f2..c3290f64f236a93d69e6d4e5e88821954b28d83c 100644 (file)
@@ -23,48 +23,18 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
         void SetUserSetting(string name, object value);\r
 \r
         /// <summary>\r
-        /// Get an Integer type user setting\r
+        /// Get user setting for a given key.\r
         /// </summary>\r
         /// <param name="name">\r
-        /// The setting name\r
-        /// </param>\r
-        /// <returns>\r
-        /// The settings value\r
-        /// </returns>\r
-        int GetUserSettingInt(string name);\r
-\r
-        /// <summary>\r
-        /// Get an String type user setting\r
-        /// </summary>\r
-        /// <param name="name">\r
-        /// The setting name\r
-        /// </param>\r
-        /// <returns>\r
-        /// The settings value\r
-        /// </returns>\r
-        string GetUserSettingString(string name);\r
-\r
-        /// <summary>\r
-        /// Get an Boolean type user setting\r
-        /// </summary>\r
-        /// <param name="name">\r
-        /// The setting name\r
+        /// The name.\r
         /// </param>\r
+        /// <typeparam name="T">\r
+        /// The Type of the setting\r
+        /// </typeparam>\r
         /// <returns>\r
-        /// The settings value\r
+        /// The user setting\r
         /// </returns>\r
-        bool GetUserSettingBoolean(string name);\r
-\r
-        /// <summary>\r
-        /// Get an Double type user setting\r
-        /// </summary>\r
-        /// <param name="name">\r
-        /// The setting name\r
-        /// </param>\r
-        /// <returns>\r
-        /// The settings value\r
-        /// </returns>\r
-        double GetUserSettingDouble(string name);\r
+        T GetUserSetting<T>(string name);\r
 \r
         /// <summary>\r
         /// Get an StringCollection type user setting\r
@@ -76,6 +46,5 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
         /// The settings value\r
         /// </returns>\r
         System.Collections.Specialized.StringCollection GetUserSettingStringCollection(string name);\r
-\r
     }\r
 }
\ No newline at end of file
index d7af9b22477b122535e1fccbb5afa01a20079623..e677d47848575de9f65a5f794a643cb07114ecc1 100644 (file)
@@ -32,6 +32,11 @@ namespace HandBrake.ApplicationServices.Services
         /// </summary>\r
         private static readonly object logLock = new object();\r
 \r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// The Start time of the current Encode;\r
         /// </summary>\r
@@ -109,7 +114,7 @@ namespace HandBrake.ApplicationServices.Services
                 }\r
 \r
                 // Prvent the system from sleeping if the user asks\r
-                if (Properties.Settings.Default.PreventSleep)\r
+                if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep) )\r
                 {\r
                     Win32.PreventSleep();\r
                 }\r
@@ -121,7 +126,7 @@ namespace HandBrake.ApplicationServices.Services
                 this.instance.StartEncode(encodeJob);\r
 \r
                 // Set the Process Priority\r
-                switch (Properties.Settings.Default.ProcessPriority)\r
+                switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority))\r
                 {\r
                     case "Realtime":\r
                         Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;\r
@@ -280,7 +285,7 @@ namespace HandBrake.ApplicationServices.Services
                 this.WindowsSeven.SetTaskBarProgressToNoProgress();\r
             }\r
 \r
-            if (Properties.Settings.Default.PreventSleep)\r
+            if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))\r
             {\r
                 Win32.AllowSleep();\r
             }\r
index 09788e6b4312eddb4b0c5c4fe91425ffe9f8c39a..9cad60e4ee4540b9e39ffdc3f6059790d2503b2d 100644 (file)
@@ -39,6 +39,11 @@ namespace HandBrake.ApplicationServices.Services
         /// </summary>\r
         private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));\r
 \r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// The User Preset file\r
         /// </summary>\r
@@ -257,7 +262,7 @@ namespace HandBrake.ApplicationServices.Services
                                     Category = category,\r
                                     Name = presetName[0].Replace("+", string.Empty).Trim(),\r
                                     Query = presetName[2],\r
-                                    Version = Properties.Settings.Default.HandBrakeVersion,\r
+                                    Version = this.userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion),\r
                                     CropSettings = pic,\r
                                     Description = string.Empty, // Maybe one day we will populate this.\r
                                     IsBuildIn = true\r
@@ -297,7 +302,7 @@ namespace HandBrake.ApplicationServices.Services
                 List<Preset> preset = this.presets.Where(p => p.IsBuildIn).ToList();\r
                 if (preset.Count > 0)\r
                 {\r
-                    if (preset[0].Version != Properties.Settings.Default.HandBrakeVersion)\r
+                    if (preset[0].Version != this.userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion))\r
                     {\r
                         this.UpdateBuiltInPresets();\r
                         return true;\r
index be9c46359038719ee57c377dd76687a7d1cf1260..30ba395f4a83aea62ec86c905e0c4f20469b27c2 100644 (file)
@@ -20,6 +20,11 @@ namespace HandBrake.ApplicationServices.Services
     /// </summary>\r
     public class QueueProcessor : IQueueProcessor\r
     {\r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private static IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// Initializes a new instance of the <see cref="QueueProcessor"/> class.\r
         /// </summary>\r
@@ -196,7 +201,7 @@ namespace HandBrake.ApplicationServices.Services
             this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Completed;\r
 \r
             // Growl\r
-            if (Properties.Settings.Default.GrowlEncode)\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode))\r
                 GrowlCommunicator.Notify("Encode Completed",\r
                                          "Put down that cocktail...\nyour Handbrake encode is done.");\r
 \r
@@ -266,10 +271,10 @@ namespace HandBrake.ApplicationServices.Services
         /// <param name="file"> The file path</param>\r
         private static void SendToApplication(string file)\r
         {\r
-            if (Properties.Settings.Default.SendFile && !string.IsNullOrEmpty(Properties.Settings.Default.SendFileTo))\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile) && !string.IsNullOrEmpty(userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo)))\r
             {\r
-                string args = string.Format("{0} \"{1}\"", Properties.Settings.Default.SendFileToArgs, file);\r
-                ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.SendFileTo, args);\r
+                string args = string.Format("{0} \"{1}\"", userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs), file);\r
+                ProcessStartInfo vlc = new ProcessStartInfo(userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo), args);\r
                 Process.Start(vlc);\r
             }\r
         }\r
@@ -280,13 +285,13 @@ namespace HandBrake.ApplicationServices.Services
         private static void Finish()\r
         {\r
             // Growl\r
-            if (Properties.Settings.Default.GrowlQueue)\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlQueue))\r
             {\r
                 GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done.");\r
             }\r
 \r
             // Do something whent he encode ends.\r
-            switch (Properties.Settings.Default.WhenCompleteAction)\r
+            switch (userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))\r
             {\r
                 case "Shutdown":\r
                     Process.Start("Shutdown", "-s -t 60");\r
index 3c2a736e851e71bf25956246b303414f0d2eb4f5..652115c0684c250cf032fc0ba5362f0b72fb4d69 100644 (file)
@@ -44,6 +44,11 @@ namespace HandBrake.ApplicationServices.Services
         /// </summary>\r
         StringBuilder header = GeneralUtilities.CreateCliLogHeader();\r
 \r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private IUserSettingService userSettingService = new UserSettingService();\r
+\r
         #endregion\r
 \r
         /// <summary>\r
@@ -190,13 +195,12 @@ namespace HandBrake.ApplicationServices.Services
                     extraArguments += " --previews " + previewCount;\r
                 }\r
 \r
-\r
-                if (Properties.Settings.Default.DisableLibDvdNav)\r
+                if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))\r
                 {\r
                     extraArguments += " --no-dvdnav";\r
                 }\r
 \r
-                extraArguments += string.Format(" --min-duration={0}", Properties.Settings.Default.MinTitleScanDuration);\r
+                extraArguments += string.Format(" --min-duration={0}", this.userSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration));\r
 \r
                 if (title > 0)\r
                 {\r
index f6d6c55e2229dde6f9c3296f9965208ebdfa0474..6ef071d4be0ee17a330ef857c95aff56bbb56238 100644 (file)
@@ -5,6 +5,14 @@
 \r
 namespace HandBrake.ApplicationServices.Services\r
 {\r
+    using System;\r
+    using System.Collections.Generic;\r
+    using System.Collections.Specialized;\r
+    using System.IO;\r
+    using System.Xml.Serialization;\r
+\r
+    using HandBrake.ApplicationServices.Collections;\r
+    using HandBrake.ApplicationServices.Exceptions;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
 \r
     /// <summary>\r
@@ -12,6 +20,33 @@ namespace HandBrake.ApplicationServices.Services
     /// </summary>\r
     public class UserSettingService : IUserSettingService\r
     {\r
+        /// <summary>\r
+        /// The Settings File\r
+        /// </summary>\r
+        private readonly string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml";\r
+\r
+        /// <summary>\r
+        /// The XML Serializer \r
+        /// </summary>\r
+        readonly XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary<string, object>));\r
+\r
+        /// <summary>\r
+        /// The User Settings\r
+        /// </summary>\r
+        private SerializableDictionary<string, object> userSettings;\r
+\r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="UserSettingService"/> class.\r
+        /// </summary>\r
+        public UserSettingService()\r
+        {\r
+            this.Load();\r
+            if (userSettings == null || userSettings.Count == 0)\r
+            {\r
+                this.LoadDefaults();\r
+            }\r
+        }\r
+\r
         /// <summary>\r
         /// Set the specified user setting.\r
         /// </summary>\r
@@ -23,29 +58,34 @@ namespace HandBrake.ApplicationServices.Services
         /// </param>\r
         public void SetUserSetting(string name, object value)\r
         {\r
-            Properties.Settings.Default[name] = value;\r
-            Properties.Settings.Default.Save();\r
+            this.userSettings[name] = value;\r
+            this.Save();\r
         }\r
 \r
         /// <summary>\r
-        /// Get an Integer type user setting\r
+        /// Get user setting for a given key.\r
         /// </summary>\r
         /// <param name="name">\r
-        /// The setting name\r
+        /// The name.\r
         /// </param>\r
+        /// <typeparam name="T">\r
+        /// The Type of the setting\r
+        /// </typeparam>\r
         /// <returns>\r
-        /// The settings value\r
+        /// The user setting\r
         /// </returns>\r
-        public int GetUserSettingInt(string name)\r
+        public T GetUserSetting<T>(string name)\r
         {\r
-            int value;\r
-            int.TryParse(Properties.Settings.Default[name].ToString(), out value);\r
+            if (this.userSettings.ContainsKey(name))\r
+            {\r
+                return (T)this.userSettings[name];\r
+            }\r
 \r
-            return value;\r
+            return default(T);\r
         }\r
 \r
         /// <summary>\r
-        /// Get an String type user setting\r
+        /// Get an StringCollection type user setting\r
         /// </summary>\r
         /// <param name="name">\r
         /// The setting name\r
@@ -53,62 +93,68 @@ namespace HandBrake.ApplicationServices.Services
         /// <returns>\r
         /// The settings value\r
         /// </returns>\r
-        public string GetUserSettingString(string name)\r
+        public StringCollection GetUserSettingStringCollection(string name)\r
         {\r
-            return Properties.Settings.Default[name].ToString();\r
+            return (StringCollection)this.userSettings[name];\r
         }\r
 \r
         /// <summary>\r
-        /// Get an Boolean type user setting\r
+        /// Save the User Settings\r
         /// </summary>\r
-        /// <param name="name">\r
-        /// The setting name\r
-        /// </param>\r
-        /// <returns>\r
-        /// The settings value\r
-        /// </returns>\r
-        public bool GetUserSettingBoolean(string name)\r
+        private void Save()\r
         {\r
-            bool value;\r
-            bool.TryParse(Properties.Settings.Default[name].ToString(), out value);\r
-\r
-            return value;\r
+            using (FileStream strm = new FileStream(this.settingsFile, FileMode.Create, FileAccess.Write))\r
+            {\r
+                serializer.Serialize(strm, this.userSettings);\r
+            }\r
         }\r
 \r
         /// <summary>\r
-        /// Get an Double type user setting\r
+        /// Load the User Settings\r
         /// </summary>\r
-        /// <param name="name">\r
-        /// The setting name\r
-        /// </param>\r
-        /// <returns>\r
-        /// The settings value\r
-        /// </returns>\r
-        public double GetUserSettingDouble(string name)\r
+        private void Load()\r
         {\r
-            double value;\r
-            double.TryParse(Properties.Settings.Default[name].ToString(), out value);\r
-\r
-            return value;\r
+            try\r
+            {\r
+                if (File.Exists(this.settingsFile))\r
+                {\r
+                    using (StreamReader reader = new StreamReader(this.settingsFile))\r
+                    {\r
+                        SerializableDictionary<string, object> data = (SerializableDictionary<string, object>)serializer.Deserialize(reader);\r
+                        this.userSettings = data;\r
+                    }\r
+                }\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                throw new GeneralApplicationException(\r
+                    "HandBrake has detected corruption in the settings file. User settings will now be reset to defaults.",\r
+                    "Please restart HandBrake before continuing.",\r
+                    exc);\r
+            }\r
         }\r
 \r
         /// <summary>\r
-        /// Get an StringCollection type user setting\r
+        /// Load Default Settings\r
         /// </summary>\r
-        /// <param name="name">\r
-        /// The setting name\r
-        /// </param>\r
-        /// <returns>\r
-        /// The settings value\r
-        /// </returns>\r
-        public System.Collections.Specialized.StringCollection GetUserSettingStringCollection(string name)\r
+        private void LoadDefaults()\r
         {\r
-            System.Collections.Specialized.StringCollection value;\r
-\r
-            value = (System.Collections.Specialized.StringCollection) Properties.Settings.Default[name];\r
-\r
-            return value;\r
+            // TODO, maybe extract this out to a file.\r
+            userSettings = new SerializableDictionary<string, object>();\r
+            userSettings[UserSettingConstants.X264Step] = 0.25;\r
+            userSettings[UserSettingConstants.Verbosity] = 1;\r
+            userSettings[UserSettingConstants.WhenCompleteAction] = "Do Nothing";\r
+            userSettings[UserSettingConstants.GrowlEncode] = false;\r
+            userSettings[UserSettingConstants.GrowlQueue] = false;\r
+            userSettings[UserSettingConstants.ProcessPriority] = "Below Normal";\r
+            userSettings[UserSettingConstants.PreventSleep] = true;\r
+            userSettings[UserSettingConstants.ShowCLI] = false;\r
+            userSettings[UserSettingConstants.SaveLogToCopyDirectory] = false;\r
+            userSettings[UserSettingConstants.SaveLogWithVideo] = false;\r
+            userSettings[UserSettingConstants.DisableLibDvdNav] = false;\r
+            userSettings[UserSettingConstants.SendFile] = false;\r
+            userSettings[UserSettingConstants.MinScanDuration] = 10;\r
+            userSettings[UserSettingConstants.HandBrakeBuild] = 0;\r
         }\r
-\r
     }\r
 }\r
index 40317d8b7ec1d456286bd39b1766b5d22bbdf7ef..746f3693708498bbbd15eb969bdf4914d3614450 100644 (file)
@@ -14,12 +14,19 @@ namespace HandBrake.ApplicationServices.Utilities
 \r
     using HandBrake.ApplicationServices.Functions;\r
     using HandBrake.ApplicationServices.Model;\r
+    using HandBrake.ApplicationServices.Services;\r
+    using HandBrake.ApplicationServices.Services.Interfaces;\r
 \r
     /// <summary>\r
     /// A Set of Static Utilites\r
     /// </summary>\r
     public class GeneralUtilities\r
     {\r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private static IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /// <summary>\r
         /// The Default Log Directory\r
         /// </summary>\r
@@ -106,7 +113,7 @@ namespace HandBrake.ApplicationServices.Utilities
         {\r
             StringBuilder logHeader = new StringBuilder();\r
 \r
-            logHeader.AppendLine(String.Format("HandBrake {0} {1}", Properties.Settings.Default.HandBrakeVersion, Properties.Settings.Default.HandBrakeBuild));\r
+            logHeader.AppendLine(String.Format("HandBrake {0} {1}", userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild)));\r
             logHeader.AppendLine(String.Format("OS: {0}", Environment.OSVersion));\r
             logHeader.AppendLine(String.Format("CPU: {0}", SystemInfo.GetCpuCount));\r
             logHeader.Append(String.Format("Ram: {0} MB, ", SystemInfo.TotalPhysicalMemory));\r
index 3b514b1987bd7900b1105f335e63a560a1e15d1f..a7574127792ca7808fec55a687812aa204966714 100644 (file)
@@ -15,6 +15,8 @@ namespace HandBrake.ApplicationServices.Utilities
     using HandBrake.ApplicationServices.Functions;\r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Model.Encoding;\r
+    using HandBrake.ApplicationServices.Services;\r
+    using HandBrake.ApplicationServices.Services.Interfaces;\r
     using HandBrake.Interop.Model.Encoding;\r
 \r
     /// <summary>\r
@@ -22,6 +24,11 @@ namespace HandBrake.ApplicationServices.Utilities
     /// </summary>\r
     public class PlistPresetHandler\r
     {\r
+        /// <summary>\r
+        /// The User Setting Service\r
+        /// </summary>\r
+        private static IUserSettingService userSettingService = new UserSettingService();\r
+\r
         /**\r
          * TODO:\r
          * - Update with the new vfr,pfr,cfr keys\r
@@ -540,7 +547,7 @@ namespace HandBrake.ApplicationServices.Utilities
             AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString());\r
 \r
             // Preset Information\r
-            AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", Properties.Settings.Default.HandBrakeBuild.ToString());\r
+            AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeBuild));\r
             AddEncodeElement(xmlWriter, "PresetDescription", "string", "No Description");\r
             AddEncodeElement(xmlWriter, "PresetName", "string", preset.Name);\r
             AddEncodeElement(xmlWriter, "Type", "integer", "1"); // 1 is user preset, 0 is built in\r
index c2bffe7e37aa890ce62cc7df81ba9bf5376600f5..1747ee2d8e56fa628f88722aa244926896410167 100644 (file)
@@ -1,83 +1,9 @@
 <?xml version="1.0"?>\r
 <configuration>\r
   <configSections>\r
-    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
-      <section name="HandBrake.ApplicationServices.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>\r
-    </sectionGroup>\r
   </configSections>\r
   <startup>\r
 \r
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>\r
     </startup>\r
-  <userSettings>\r
-\r
-    <HandBrake.ApplicationServices.Properties.Settings>\r
-      <setting name="Verbosity" serializeAs="String">\r
-        <value>1</value>\r
-      </setting>\r
-      <setting name="X264Step" serializeAs="String">\r
-        <value>0.5</value>\r
-      </setting>\r
-      <setting name="WhenCompleteAction" serializeAs="String">\r
-        <value>Do Nothing</value>\r
-      </setting>\r
-      <setting name="GrowlEncode" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="GrowlQueue" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="ProcessPriority" serializeAs="String">\r
-        <value>Below Normal</value>\r
-      </setting>\r
-      <setting name="PreventSleep" serializeAs="String">\r
-        <value>True</value>\r
-      </setting>\r
-      <setting name="ShowCLI" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="SaveLogToCopyDirectory" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="SaveLogWithVideo" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="SaveLogCopyDirectory" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="HandBrakeVersion" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="HandBrakeBuild" serializeAs="String">\r
-        <value>0</value>\r
-      </setting>\r
-      <setting name="InstanceId" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="DisableLibDvdNav" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="HandBrakePlatform" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="HandBrakeExeHash" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="Setting" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="SendFileTo" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="SendFileToArgs" serializeAs="String">\r
-        <value />\r
-      </setting>\r
-      <setting name="SendFile" serializeAs="String">\r
-        <value>False</value>\r
-      </setting>\r
-      <setting name="MinTitleScanDuration" serializeAs="String">\r
-        <value>10</value>\r
-      </setting>\r
-    </HandBrake.ApplicationServices.Properties.Settings>\r
-  </userSettings>\r
 </configuration>\r
index 4e7dfcbc06c7a95fa481a582efa52f9f1112e891..406d8d0bbeee395e1c6ee120243746faffd3415b 100644 (file)
@@ -67,7 +67,7 @@ namespace Handbrake
                     // Going from major to major will require the user to reset.\r
                     // Going from svn to svn will attempt the upgrade.\r
                     UserSettingService service = new UserSettingService();\r
-                    string version = service.GetUserSettingString(UserSettingConstants.HandBrakeVersion);\r
+                    string version = service.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion);\r
                     if (version.Contains("svn"))\r
                     {\r
                         Settings.Default.Upgrade();\r
index 05a2765c202f84253f5503e9d208182ffb5eed63..7bceabdb6e5f2670a83c8582dbbd8fdd114cf93f 100644 (file)
@@ -26,8 +26,8 @@ namespace Handbrake
         {\r
             InitializeComponent();\r
 \r
-            string nightly = userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty;\r
-            lbl_GUIBuild.Text = userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion) + " (" + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild) + ") " + nightly;\r
+            string nightly = userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty;\r
+            lbl_GUIBuild.Text = userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion) + " (" + userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild) + ") " + nightly;\r
         }\r
 \r
         /// <summary>\r
index 0a01b6571a39787009b4ff83fcec2d8afce496ec..64c92ce0adf3ed3af0c0744acb72abc77af42ae6 100644 (file)
@@ -134,9 +134,9 @@ namespace Handbrake
             // Update the users config file with the CLI version data.\r
             Main.SetCliVersionData();\r
 \r
-            if (userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion).Contains("svn"))\r
+            if (userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion).Contains("svn"))\r
             {\r
-                this.Text += " " + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion);\r
+                this.Text += " " + userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion);\r
             }\r
 \r
             // Check for new versions, if update checking is enabled\r
@@ -147,10 +147,11 @@ namespace Handbrake
                     // Set when the last update was\r
                     Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
                     Settings.Default.Save();\r
-                    string url = this.userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild).EndsWith("1")\r
+                    string url = this.userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild).ToString().EndsWith("1")\r
                                                   ? Settings.Default.appcast_unstable\r
                                                   : Settings.Default.appcast;\r
-                    UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSettingInt(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion));\r
+                    UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false, url, userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild),\r
+                        Settings.Default.skipversion, userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion));\r
                 }\r
             }\r
 \r
@@ -212,7 +213,7 @@ namespace Handbrake
 \r
                 if (info.NewVersionAvailable)\r
                 {\r
-                    UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild));\r
+                    UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeBuild));\r
                     updateWindow.ShowDialog();\r
                 }\r
             }\r
@@ -453,10 +454,10 @@ namespace Handbrake
             lbl_updateCheck.Visible = true;\r
             Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
             Settings.Default.Save();\r
-            string url = userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild).EndsWith("1")\r
+            string url = userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeBuild).EndsWith("1")\r
                                                   ? Settings.Default.appcast_unstable\r
                                                   : Settings.Default.appcast;\r
-            UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDoneMenu), false, url, userSettingService.GetUserSettingInt(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion));\r
+            UpdateService.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDoneMenu), false, url, userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion));\r
         }\r
 \r
         /// <summary>\r
@@ -947,7 +948,7 @@ namespace Handbrake
         {\r
             if (btn_start.Text == "Stop")\r
             {\r
-                DialogResult result = !userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI)\r
+                DialogResult result = !userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowCLI)\r
                              ? MessageBox.Show(\r
                                  "Are you sure you wish to cancel the encode?\n\nPlease note: Stopping this encode will render the file unplayable. ",\r
                                  "Cancel Encode?",\r
@@ -964,7 +965,7 @@ namespace Handbrake
                     // Pause The Queue\r
                     this.queueProcessor.Pause();\r
 \r
-                    if (userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI))\r
+                    if (userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowCLI))\r
                         this.queueProcessor.EncodeService.SafelyStop();\r
                     else\r
                         this.queueProcessor.EncodeService.Stop();\r
@@ -1435,7 +1436,7 @@ namespace Handbrake
 \r
                 // Populate the Angles dropdown\r
                 drop_angle.Items.Clear();\r
-                if (!userSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav))\r
+                if (!userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))\r
                 {\r
                     drop_angle.Visible = true;\r
                     lbl_angle.Visible = true;\r
@@ -1790,11 +1791,11 @@ namespace Handbrake
                 case "H.264 (x264)":\r
                     slider_videoQuality.Minimum = 0;\r
                     slider_videoQuality.TickFrequency = 1;\r
-                    double cqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+                    double cqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
                     double multiplier = 1.0 / cqStep;\r
                     double value = slider_videoQuality.Value * multiplier;\r
 \r
-                    slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step));\r
+                    slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step));\r
 \r
                     if (value < slider_videoQuality.Maximum)\r
                         slider_videoQuality.Value = slider_videoQuality.Maximum - (int)value;\r
@@ -1861,7 +1862,7 @@ namespace Handbrake
         {\r
             if (cachedCqStep == 0)\r
             {\r
-                cachedCqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+                cachedCqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
             }\r
 \r
             // Work out the current RF value.\r
@@ -1869,13 +1870,13 @@ namespace Handbrake
             double rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
 \r
             // Change the maximum value for the slider\r
-            slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step));\r
+            slider_videoQuality.Maximum = (int)(51 / userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step));\r
 \r
             // Reset the CQ slider to RF0\r
             slider_videoQuality.Value = slider_videoQuality.Maximum;\r
 \r
             // Reset the CQ slider back to the previous value as close as possible\r
-            double cqStepNew = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+            double cqStepNew = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
             double rfValueCurrent = 51.0 - slider_videoQuality.Value * cqStepNew;\r
             while (rfValueCurrent < rfValue)\r
             {\r
@@ -1884,12 +1885,12 @@ namespace Handbrake
             }\r
 \r
             // Cache the CQ step for the next calculation\r
-            this.cachedCqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+            this.cachedCqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
         }\r
 \r
         private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
         {\r
-            double cqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);\r
+            double cqStep = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step);\r
             switch (drp_videoEncoder.Text)\r
             {\r
                 case "MPEG-4 (FFmpeg)":\r
@@ -2494,7 +2495,7 @@ namespace Handbrake
 \r
                 if (info.NewVersionAvailable)\r
                 {\r
-                    UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeBuild));\r
+                    UpdateInfo updateWindow = new UpdateInfo(info, userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeBuild));\r
                     updateWindow.ShowDialog();\r
                 }\r
                 else\r
index ecf973086cd2b89bc9523fb1c9c7c9c6fb28ce35..ac80923332f4a7d7bc9fc1cc400123f427ef5e24 100644 (file)
@@ -84,18 +84,18 @@ namespace Handbrake
             }\r
 \r
             // On Encode Completeion Action\r
-            drp_completeOption.Text = userSettingService.GetUserSettingString("WhenCompleteAction");\r
+            drp_completeOption.Text = userSettingService.GetUserSetting<string>("WhenCompleteAction");\r
 \r
             // Growl.\r
-            if (userSettingService.GetUserSettingBoolean(UserSettingConstants.GrowlEncode))\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode))\r
                 check_growlEncode.CheckState = CheckState.Checked;\r
 \r
-            if (userSettingService.GetUserSettingBoolean(UserSettingConstants.GrowlQueue))\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlQueue))\r
                 check_GrowlQueue.CheckState = CheckState.Checked;\r
 \r
-            check_sendFileTo.Checked = this.userSettingService.GetUserSettingBoolean(UserSettingConstants.SendFile);\r
-            lbl_sendFileTo.Text = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSettingString(UserSettingConstants.SendFileTo));\r
-            txt_SendFileArgs.Text = this.userSettingService.GetUserSettingString(UserSettingConstants.SendFileToArgs);\r
+            check_sendFileTo.Checked = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile);\r
+            lbl_sendFileTo.Text = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo));\r
+            txt_SendFileArgs.Text = this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs);\r
 \r
             // #############################\r
             // Output Settings\r
@@ -177,23 +177,23 @@ namespace Handbrake
             // #############################\r
 \r
             // Priority level for encodes\r
-            drp_Priority.Text = userSettingService.GetUserSettingString(UserSettingConstants.ProcessPriority);\r
+            drp_Priority.Text = userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority);\r
 \r
-            check_preventSleep.Checked = userSettingService.GetUserSettingBoolean(UserSettingConstants.PreventSleep);\r
+            check_preventSleep.Checked = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep);\r
 \r
             // Log Verbosity Level\r
-            cb_logVerboseLvl.SelectedIndex = userSettingService.GetUserSettingInt(UserSettingConstants.Verbosity);\r
+            cb_logVerboseLvl.SelectedIndex = userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity);\r
 \r
             // Save logs in the same directory as encoded files\r
-            if (userSettingService.GetUserSettingBoolean(UserSettingConstants.SaveLogWithVideo))\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo))\r
                 check_saveLogWithVideo.CheckState = CheckState.Checked;\r
 \r
             // Save Logs in a specified path\r
-            if (userSettingService.GetUserSettingBoolean(UserSettingConstants.SaveLogToCopyDirectory))\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory))\r
                 check_logsInSpecifiedLocation.CheckState = CheckState.Checked;\r
 \r
             // The saved log path\r
-            text_logPath.Text = userSettingService.GetUserSettingString(UserSettingConstants.SaveLogCopyDirectory);\r
+            text_logPath.Text = userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory);\r
 \r
             check_clearOldLogs.Checked = Properties.Settings.Default.clearOldLogs;\r
 \r
@@ -222,13 +222,13 @@ namespace Handbrake
                 check_disablePresetNotification.CheckState = CheckState.Checked;\r
 \r
             // Show CLI Window\r
-            check_showCliForInGUIEncode.Checked = userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI);\r
+            check_showCliForInGUIEncode.Checked = userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowCLI);\r
 \r
             // Set the preview count\r
             drop_previewScanCount.SelectedItem = Properties.Settings.Default.previewScanCount.ToString();\r
 \r
             // x264 step\r
-            string step = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step).ToString(new CultureInfo("en-US"));\r
+            string step = userSettingService.GetUserSetting<double>(UserSettingConstants.X264Step).ToString(new CultureInfo("en-US"));\r
             switch (step)\r
             {\r
                 case "1":\r
@@ -246,10 +246,10 @@ namespace Handbrake
             }\r
 \r
             // Min Title Length\r
-            ud_minTitleLength.Value = this.userSettingService.GetUserSettingInt(UserSettingConstants.MinScanDuration); \r
+            ud_minTitleLength.Value = this.userSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration); \r
 \r
             // Use Experimental dvdnav\r
-            if (userSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav))\r
+            if (userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))\r
                 check_dvdnav.CheckState = CheckState.Checked;\r
 \r
             optionsWindowLoading = false;\r
index 04cb91276fd6cf70419b4ccc30bb5704f5970368..fc433f1a5aa948d8f0fdb5f697d72dcf9b0afe96 100644 (file)
@@ -76,7 +76,7 @@ namespace Handbrake
             queue.EncodeService.EncodeStarted += this.queue_EncodeStarted;\r
             queue.EncodeService.EncodeCompleted += this.queue_EncodeEnded;\r
 \r
-            drp_completeOption.Text = userSettingService.GetUserSettingString(UserSettingConstants.WhenCompleteAction);\r
+            drp_completeOption.Text = userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction);\r
         }\r
 \r
         /// <summary>\r