summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <sr55.hb@outlook.com>2011-08-15 16:54:19 +0000
committersr55 <sr55.hb@outlook.com>2011-08-15 16:54:19 +0000
commit44b2c7e69d5613631a4ab39a91e01b673046f030 (patch)
tree8fe8f170aea693a9993c44db3826a324a46cbd4b /win
parent3e3deb33d5c5ec4aca3d6c855db646b511bf788b (diff)
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
Diffstat (limited to 'win')
-rw-r--r--win/CS/Functions/PresetLoader.cs2
-rw-r--r--win/CS/Functions/QueryGenerator.cs8
-rw-r--r--win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs103
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj1
-rw-r--r--win/CS/HandBrake.ApplicationServices/Parsing/Title.cs9
-rw-r--r--win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs266
-rw-r--r--win/CS/HandBrake.ApplicationServices/Properties/Settings.settings71
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs14
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode.cs13
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs45
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs11
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/PresetService.cs9
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs17
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ScanService.cs10
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs146
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs9
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs9
-rw-r--r--win/CS/HandBrake.ApplicationServices/app.config74
-rw-r--r--win/CS/Program.cs2
-rw-r--r--win/CS/frmAbout.cs4
-rw-r--r--win/CS/frmMain.cs37
-rw-r--r--win/CS/frmOptions.cs32
-rw-r--r--win/CS/frmQueue.cs2
23 files changed, 329 insertions, 565 deletions
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<double>(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<bool>(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<double>(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<int>(UserSettingConstants.Verbosity);
// LibDVDNav
- if (UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav))
+ if (UserSettingService.GetUserSetting<bool>(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: <http://handbrake.fr>.
+ 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;
+
+ /// <summary>
+ /// A Serializable Dictionary
+ /// </summary>
+ /// <typeparam name="TKey">
+ /// The Key Type
+ /// </typeparam>
+ /// <typeparam name="TValue">
+ /// The Value Type
+ /// </typeparam>
+ [XmlRoot("dictionary")]
+ public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable
+ {
+ #region IXmlSerializable Members
+
+ /// <summary>
+ /// Get the Schema
+ /// </summary>
+ /// <returns>
+ /// Nothing. We don't use this.
+ /// </returns>
+ public System.Xml.Schema.XmlSchema GetSchema()
+ {
+ return null;
+ }
+
+ /// <summary>
+ /// Deserialize some XML into a dictionary
+ /// </summary>
+ /// <param name="reader">
+ /// The reader.
+ /// </param>
+ 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();
+ }
+
+ /// <summary>
+ /// Write the Dictionary out to XML
+ /// </summary>
+ /// <param name="writer">
+ /// The writer.
+ /// </param>
+ 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 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Collections\SerializableDictionary.cs" />
<Compile Include="Converters\EnumToDescConverter.cs" />
<Compile Include="Exceptions\GeneralApplicationException.cs" />
<Compile Include="EventArgs\EncodeCompletedEventArgs.cs" />
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;
@@ -28,6 +30,11 @@ namespace HandBrake.ApplicationServices.Parsing
private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private static IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// Initializes a new instance of the <see cref="Title"/> class.
/// </summary>
public Title()
@@ -151,7 +158,7 @@ namespace HandBrake.ApplicationServices.Parsing
}
// Multi-Angle Support if LibDvdNav is enabled
- if (!Properties.Settings.Default.DisableLibDvdNav)
+ if (!userSettingService.GetUserSetting<bool>(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 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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 @@
<?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HandBrake.ApplicationServices.Properties" GeneratedClassName="Settings">
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles />
- <Settings>
- <Setting Name="Verbosity" Type="System.Int32" Scope="User">
- <Value Profile="(Default)">1</Value>
- </Setting>
- <Setting Name="X264Step" Type="System.Double" Scope="User">
- <Value Profile="(Default)">0.5</Value>
- </Setting>
- <Setting Name="WhenCompleteAction" Type="System.String" Scope="User">
- <Value Profile="(Default)">Do Nothing</Value>
- </Setting>
- <Setting Name="GrowlEncode" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="GrowlQueue" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="ProcessPriority" Type="System.String" Scope="User">
- <Value Profile="(Default)">Below Normal</Value>
- </Setting>
- <Setting Name="PreventSleep" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">True</Value>
- </Setting>
- <Setting Name="ShowCLI" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="SaveLogToCopyDirectory" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="SaveLogWithVideo" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="SaveLogCopyDirectory" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="HandBrakeVersion" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="HandBrakeBuild" Type="System.Int32" Scope="User">
- <Value Profile="(Default)">0</Value>
- </Setting>
- <Setting Name="InstanceId" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="DisableLibDvdNav" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="HandBrakePlatform" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="HandBrakeExeHash" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="Setting" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="SendFileTo" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="SendFileToArgs" Type="System.String" Scope="User">
- <Value Profile="(Default)" />
- </Setting>
- <Setting Name="SendFile" Type="System.Boolean" Scope="User">
- <Value Profile="(Default)">False</Value>
- </Setting>
- <Setting Name="MinTitleScanDuration" Type="System.Int32" Scope="User">
- <Value Profile="(Default)">10</Value>
- </Setting>
- </Settings>
+ <Settings />
</SettingsFile> \ 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;
@@ -29,6 +28,11 @@ namespace HandBrake.ApplicationServices.Services.Base
private static readonly object fileWriterLock = new object();
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// Windows 7 API Pack wrapper
/// </summary>
private Win7 windowsSeven = new Win7();
@@ -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<bool>(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<string>(UserSettingConstants.SaveLogCopyDirectory)) &&
+ this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory))
{
File.Copy(
- tempLogFile, Path.Combine(Properties.Settings.Default.SaveLogCopyDirectory, encodeLogFile));
+ tempLogFile, Path.Combine(this.userSettingService.GetUserSetting<string>(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
@@ -26,6 +26,11 @@ namespace HandBrake.ApplicationServices.Services
#region Private Variables
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// Gets The Process Handle
/// </summary>
private IntPtr processHandle;
@@ -102,7 +107,7 @@ namespace HandBrake.ApplicationServices.Services
}
}
- if (Properties.Settings.Default.PreventSleep)
+ if (this.userSettingService.GetUserSetting<bool>(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<bool>(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<string>(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<bool>(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);
/// <summary>
- /// Get an Integer type user setting
+ /// Get user setting for a given key.
/// </summary>
/// <param name="name">
- /// The setting name
- /// </param>
- /// <returns>
- /// The settings value
- /// </returns>
- int GetUserSettingInt(string name);
-
- /// <summary>
- /// Get an String type user setting
- /// </summary>
- /// <param name="name">
- /// The setting name
- /// </param>
- /// <returns>
- /// The settings value
- /// </returns>
- string GetUserSettingString(string name);
-
- /// <summary>
- /// Get an Boolean type user setting
- /// </summary>
- /// <param name="name">
- /// The setting name
+ /// The name.
/// </param>
+ /// <typeparam name="T">
+ /// The Type of the setting
+ /// </typeparam>
/// <returns>
- /// The settings value
+ /// The user setting
/// </returns>
- bool GetUserSettingBoolean(string name);
-
- /// <summary>
- /// Get an Double type user setting
- /// </summary>
- /// <param name="name">
- /// The setting name
- /// </param>
- /// <returns>
- /// The settings value
- /// </returns>
- double GetUserSettingDouble(string name);
+ T GetUserSetting<T>(string name);
/// <summary>
/// Get an StringCollection type user setting
@@ -76,6 +46,5 @@ namespace HandBrake.ApplicationServices.Services.Interfaces
/// The settings value
/// </returns>
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
@@ -33,6 +33,11 @@ namespace HandBrake.ApplicationServices.Services
private static readonly object logLock = new object();
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// The Start time of the current Encode;
/// </summary>
private DateTime startTime;
@@ -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<bool>(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<string>(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<bool>(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
@@ -40,6 +40,11 @@ namespace HandBrake.ApplicationServices.Services
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Preset>));
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// The User Preset file
/// </summary>
private readonly string userPresetFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml";
@@ -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<string>(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> 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<string>(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
@@ -21,6 +21,11 @@ namespace HandBrake.ApplicationServices.Services
public class QueueProcessor : IQueueProcessor
{
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private static IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// Initializes a new instance of the <see cref="QueueProcessor"/> class.
/// </summary>
/// <param name="queueManager">
@@ -196,7 +201,7 @@ namespace HandBrake.ApplicationServices.Services
this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Completed;
// Growl
- if (Properties.Settings.Default.GrowlEncode)
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode))
GrowlCommunicator.Notify("Encode Completed",
"Put down that cocktail...\nyour Handbrake encode is done.");
@@ -266,10 +271,10 @@ namespace HandBrake.ApplicationServices.Services
/// <param name="file"> The file path</param>
private static void SendToApplication(string file)
{
- if (Properties.Settings.Default.SendFile && !string.IsNullOrEmpty(Properties.Settings.Default.SendFileTo))
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile) && !string.IsNullOrEmpty(userSettingService.GetUserSetting<string>(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<string>(UserSettingConstants.SendFileToArgs), file);
+ ProcessStartInfo vlc = new ProcessStartInfo(userSettingService.GetUserSetting<string>(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<bool>(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<string>(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
/// </summary>
StringBuilder header = GeneralUtilities.CreateCliLogHeader();
+ /// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = new UserSettingService();
+
#endregion
/// <summary>
@@ -190,13 +195,12 @@ namespace HandBrake.ApplicationServices.Services
extraArguments += " --previews " + previewCount;
}
-
- if (Properties.Settings.Default.DisableLibDvdNav)
+ if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))
{
extraArguments += " --no-dvdnav";
}
- extraArguments += string.Format(" --min-duration={0}", Properties.Settings.Default.MinTitleScanDuration);
+ extraArguments += string.Format(" --min-duration={0}", this.userSettingService.GetUserSetting<int>(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;
/// <summary>
@@ -13,6 +21,33 @@ namespace HandBrake.ApplicationServices.Services
public class UserSettingService : IUserSettingService
{
/// <summary>
+ /// The Settings File
+ /// </summary>
+ private readonly string settingsFile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml";
+
+ /// <summary>
+ /// The XML Serializer
+ /// </summary>
+ readonly XmlSerializer serializer = new XmlSerializer(typeof(SerializableDictionary<string, object>));
+
+ /// <summary>
+ /// The User Settings
+ /// </summary>
+ private SerializableDictionary<string, object> userSettings;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="UserSettingService"/> class.
+ /// </summary>
+ public UserSettingService()
+ {
+ this.Load();
+ if (userSettings == null || userSettings.Count == 0)
+ {
+ this.LoadDefaults();
+ }
+ }
+
+ /// <summary>
/// Set the specified user setting.
/// </summary>
/// <param name="name">
@@ -23,29 +58,34 @@ namespace HandBrake.ApplicationServices.Services
/// </param>
public void SetUserSetting(string name, object value)
{
- Properties.Settings.Default[name] = value;
- Properties.Settings.Default.Save();
+ this.userSettings[name] = value;
+ this.Save();
}
/// <summary>
- /// Get an Integer type user setting
+ /// Get user setting for a given key.
/// </summary>
/// <param name="name">
- /// The setting name
+ /// The name.
/// </param>
+ /// <typeparam name="T">
+ /// The Type of the setting
+ /// </typeparam>
/// <returns>
- /// The settings value
+ /// The user setting
/// </returns>
- public int GetUserSettingInt(string name)
+ public T GetUserSetting<T>(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);
}
/// <summary>
- /// Get an String type user setting
+ /// Get an StringCollection type user setting
/// </summary>
/// <param name="name">
/// The setting name
@@ -53,62 +93,68 @@ namespace HandBrake.ApplicationServices.Services
/// <returns>
/// The settings value
/// </returns>
- public string GetUserSettingString(string name)
+ public StringCollection GetUserSettingStringCollection(string name)
{
- return Properties.Settings.Default[name].ToString();
+ return (StringCollection)this.userSettings[name];
}
/// <summary>
- /// Get an Boolean type user setting
+ /// Save the User Settings
/// </summary>
- /// <param name="name">
- /// The setting name
- /// </param>
- /// <returns>
- /// The settings value
- /// </returns>
- 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);
+ }
}
/// <summary>
- /// Get an Double type user setting
+ /// Load the User Settings
/// </summary>
- /// <param name="name">
- /// The setting name
- /// </param>
- /// <returns>
- /// The settings value
- /// </returns>
- 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<string, object> data = (SerializableDictionary<string, object>)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);
+ }
}
/// <summary>
- /// Get an StringCollection type user setting
+ /// Load Default Settings
/// </summary>
- /// <param name="name">
- /// The setting name
- /// </param>
- /// <returns>
- /// The settings value
- /// </returns>
- 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<string, object>();
+ 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,6 +14,8 @@ namespace HandBrake.ApplicationServices.Utilities
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// A Set of Static Utilites
@@ -21,6 +23,11 @@ namespace HandBrake.ApplicationServices.Utilities
public class GeneralUtilities
{
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private static IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// The Default Log Directory
/// </summary>
private static readonly string LogDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
@@ -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<string>(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<int>(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;
/// <summary>
@@ -22,6 +24,11 @@ namespace HandBrake.ApplicationServices.Utilities
/// </summary>
public class PlistPresetHandler
{
+ /// <summary>
+ /// The User Setting Service
+ /// </summary>
+ 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<string>(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 @@
<?xml version="1.0"?>
<configuration>
<configSections>
- <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <section name="HandBrake.ApplicationServices.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
- </sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
- <userSettings>
-
- <HandBrake.ApplicationServices.Properties.Settings>
- <setting name="Verbosity" serializeAs="String">
- <value>1</value>
- </setting>
- <setting name="X264Step" serializeAs="String">
- <value>0.5</value>
- </setting>
- <setting name="WhenCompleteAction" serializeAs="String">
- <value>Do Nothing</value>
- </setting>
- <setting name="GrowlEncode" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="GrowlQueue" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="ProcessPriority" serializeAs="String">
- <value>Below Normal</value>
- </setting>
- <setting name="PreventSleep" serializeAs="String">
- <value>True</value>
- </setting>
- <setting name="ShowCLI" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="SaveLogToCopyDirectory" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="SaveLogWithVideo" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="SaveLogCopyDirectory" serializeAs="String">
- <value />
- </setting>
- <setting name="HandBrakeVersion" serializeAs="String">
- <value />
- </setting>
- <setting name="HandBrakeBuild" serializeAs="String">
- <value>0</value>
- </setting>
- <setting name="InstanceId" serializeAs="String">
- <value />
- </setting>
- <setting name="DisableLibDvdNav" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="HandBrakePlatform" serializeAs="String">
- <value />
- </setting>
- <setting name="HandBrakeExeHash" serializeAs="String">
- <value />
- </setting>
- <setting name="Setting" serializeAs="String">
- <value />
- </setting>
- <setting name="SendFileTo" serializeAs="String">
- <value />
- </setting>
- <setting name="SendFileToArgs" serializeAs="String">
- <value />
- </setting>
- <setting name="SendFile" serializeAs="String">
- <value>False</value>
- </setting>
- <setting name="MinTitleScanDuration" serializeAs="String">
- <value>10</value>
- </setting>
- </HandBrake.ApplicationServices.Properties.Settings>
- </userSettings>
</configuration>
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<string>(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<string>(UserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty;
+ lbl_GUIBuild.Text = userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion) + " (" + userSettingService.GetUserSetting<int>(UserSettingConstants.HandBrakeBuild) + ") " + nightly;
}
/// <summary>
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<string>(UserSettingConstants.HandBrakeVersion).Contains("svn"))
{
- this.Text += " " + userSettingService.GetUserSettingString(UserSettingConstants.HandBrakeVersion);
+ this.Text += " " + userSettingService.GetUserSetting<string>(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<int>(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<int>(UserSettingConstants.HandBrakeBuild),
+ Settings.Default.skipversion, userSettingService.GetUserSetting<string>(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<string>(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<string>(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<string>(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<int>(UserSettingConstants.HandBrakeBuild), Settings.Default.skipversion, userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion));
}
/// <summary>
@@ -947,7 +948,7 @@ namespace Handbrake
{
if (btn_start.Text == "Stop")
{
- DialogResult result = !userSettingService.GetUserSettingBoolean(UserSettingConstants.ShowCLI)
+ DialogResult result = !userSettingService.GetUserSetting<bool>(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<bool>(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<bool>(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<double>(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<double>(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<double>(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<double>(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<double>(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<double>(UserSettingConstants.X264Step);
}
private void slider_videoQuality_Scroll(object sender, EventArgs e)
{
- double cqStep = userSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);
+ double cqStep = userSettingService.GetUserSetting<double>(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<string>(UserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<string>(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<string>("WhenCompleteAction");
// Growl.
- if (userSettingService.GetUserSettingBoolean(UserSettingConstants.GrowlEncode))
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode))
check_growlEncode.CheckState = CheckState.Checked;
- if (userSettingService.GetUserSettingBoolean(UserSettingConstants.GrowlQueue))
+ if (userSettingService.GetUserSetting<bool>(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<bool>(UserSettingConstants.SendFile);
+ lbl_sendFileTo.Text = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo));
+ txt_SendFileArgs.Text = this.userSettingService.GetUserSetting<string>(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<string>(UserSettingConstants.ProcessPriority);
- check_preventSleep.Checked = userSettingService.GetUserSettingBoolean(UserSettingConstants.PreventSleep);
+ check_preventSleep.Checked = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep);
// Log Verbosity Level
- cb_logVerboseLvl.SelectedIndex = userSettingService.GetUserSettingInt(UserSettingConstants.Verbosity);
+ cb_logVerboseLvl.SelectedIndex = userSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity);
// Save logs in the same directory as encoded files
- if (userSettingService.GetUserSettingBoolean(UserSettingConstants.SaveLogWithVideo))
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo))
check_saveLogWithVideo.CheckState = CheckState.Checked;
// Save Logs in a specified path
- if (userSettingService.GetUserSettingBoolean(UserSettingConstants.SaveLogToCopyDirectory))
+ if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory))
check_logsInSpecifiedLocation.CheckState = CheckState.Checked;
// The saved log path
- text_logPath.Text = userSettingService.GetUserSettingString(UserSettingConstants.SaveLogCopyDirectory);
+ text_logPath.Text = userSettingService.GetUserSetting<string>(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<bool>(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<double>(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<int>(UserSettingConstants.MinScanDuration);
// Use Experimental dvdnav
- if (userSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav))
+ if (userSettingService.GetUserSetting<bool>(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<string>(UserSettingConstants.WhenCompleteAction);
}
/// <summary>