summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Init.cs160
-rw-r--r--win/CS/HandBrake.ApplicationServices/Parsing/Title.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs204
-rw-r--r--win/CS/HandBrake.ApplicationServices/Properties/Settings.settings61
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode.cs26
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs69
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/PresetService.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ScanService.cs4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs7
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs95
-rw-r--r--win/CS/HandBrake.ApplicationServices/Settings.StyleCop15
-rw-r--r--win/CS/HandBrake.ApplicationServices/UserSettingConstants.cs99
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs24
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/app.config72
17 files changed, 646 insertions, 210 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 4edad2011..fcfb2fe03 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -96,7 +96,6 @@
<Compile Include="Functions\System.cs" />
<Compile Include="Functions\Win32.cs" />
<Compile Include="Functions\Win7.cs" />
- <Compile Include="Init.cs" />
<Compile Include="Model\DriveInformation.cs" />
<Compile Include="Model\Encoding\AudioTrack.cs" />
<Compile Include="Model\Encoding\Anamorphic.cs" />
@@ -142,12 +141,15 @@
<Compile Include="Services\Interfaces\IQueueProcessor.cs" />
<Compile Include="Services\Interfaces\IScan.cs" />
<Compile Include="Services\Interfaces\IPresetService.cs" />
+ <Compile Include="Services\Interfaces\IUserSettingService.cs" />
<Compile Include="Services\LibScan.cs" />
<Compile Include="Services\PresetService.cs" />
<Compile Include="Services\QueueManager.cs" />
<Compile Include="Services\QueueProcessor.cs" />
<Compile Include="Services\ScanService.cs" />
<Compile Include="Services\UpdateService.cs" />
+ <Compile Include="Services\UserSettingService.cs" />
+ <Compile Include="UserSettingConstants.cs" />
<Compile Include="Utilities\AppcastReader.cs" />
<Compile Include="Utilities\GeneralUtilities.cs" />
<Compile Include="Utilities\LanguageUtilities.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Init.cs b/win/CS/HandBrake.ApplicationServices/Init.cs
deleted file mode 100644
index e51683ab8..000000000
--- a/win/CS/HandBrake.ApplicationServices/Init.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Init.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
-{
- using System;
- using System.Reflection;
-
- /// <summary>
- /// Initialize ApplicationServices
- /// </summary>
- public class Init
- {
- /**
- * I really dislike this, Need to replace this sooner rather than later.
- **/
-
- /// <summary>
- /// Setup the Settings used by the applicaiton with this library
- /// </summary>
- /// <param name="versionString">
- /// The version / name of the application that's using this DLL.
- /// </param>
- /// <param name="instanceId">
- /// The Instance ID
- /// </param>
- /// <param name="completionOption">
- /// The completion option.
- /// </param>
- /// <param name="disableDvdNav">
- /// The disable dvd nav.
- /// </param>
- /// <param name="growlEncode">
- /// The growl encode.
- /// </param>
- /// <param name="growlQueue">
- /// The growl queue.
- /// </param>
- /// <param name="processPriority">
- /// The process priority.
- /// </param>
- /// <param name="saveLogPath">
- /// The save log path.
- /// </param>
- /// <param name="saveLogToSpecifiedPath">
- /// The save log to specified path.
- /// </param>
- /// <param name="saveLogWithVideo">
- /// The save log with video.
- /// </param>
- /// <param name="showCliForInGuiEncodeStatus">
- /// The show cli for in gui encode status.
- /// </param>
- /// <param name="preventSleep">
- /// Prevent the system from sleeping
- /// </param>
- public static void SetupSettings(string versionString, string version, int build, int instanceId, string completionOption, bool disableDvdNav,
- bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath,
- bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep)
- {
- InstanceId = instanceId;
- HandBrakeGuiVersionString = versionString;
- Version = version;
- Build = build;
- CompletionOption = completionOption;
- DisableDvdNav = disableDvdNav;
- GrowlEncode = growlEncode;
- GrowlQueue = growlQueue;
- ProcessPriority = processPriority;
- SaveLogPath = saveLogPath;
- SaveLogToSpecifiedPath = saveLogToSpecifiedPath;
- SaveLogWithVideo = saveLogWithVideo;
- ShowCliForInGuiEncodeStatus = showCliForInGuiEncodeStatus;
- PreventSleep = preventSleep;
- }
-
- /// <summary>
- /// Gets the Assembly version.
- /// </summary>
- /// <returns>
- /// Version data
- /// </returns>
- public static Version AssemblyVersion()
- {
- return Assembly.GetExecutingAssembly().GetName().Version;
- }
-
- /// <summary>
- /// The instance ID used by the Main Applicaiton
- /// </summary>
- public static int InstanceId;
-
- /// <summary>
- /// The Applicaiton that uses this DLL can pass in it's version string.
- /// </summary>
- public static string HandBrakeGuiVersionString;
-
- /// <summary>
- /// HandBrakes Version or Svn revision
- /// </summary>
- public static string Version;
-
- /// <summary>
- /// Handbrakes Build number
- /// </summary>
- public static int Build;
-
- /// <summary>
- /// What to do when the encode completes.
- /// </summary>
- public static string CompletionOption;
-
- /// <summary>
- /// Disable LibDvdNav
- /// </summary>
- public static bool DisableDvdNav;
-
- /// <summary>
- /// Growl when an encode has finished.
- /// </summary>
- public static bool GrowlEncode;
-
- /// <summary>
- /// Growl when a queue has finished.
- /// </summary>
- public static bool GrowlQueue;
-
- /// <summary>
- /// The Process Priority for HandBrakeCLI
- /// </summary>
- public static string ProcessPriority;
-
- /// <summary>
- /// Path to save log files to.
- /// </summary>
- public static string SaveLogPath;
-
- /// <summary>
- /// Copy log files to the SaveLogPath
- /// </summary>
- public static bool SaveLogToSpecifiedPath;
-
- /// <summary>
- /// Save a copy of the log files with the video
- /// </summary>
- public static bool SaveLogWithVideo;
-
- /// <summary>
- /// Show the CLI window when encoding.
- /// </summary>
- public static bool ShowCliForInGuiEncodeStatus;
-
- /// <summary>
- /// Prevent system sleep
- /// </summary>
- public static bool PreventSleep;
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
index 7f4bf9b78..2f08eb19e 100644
--- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
+++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
@@ -149,7 +149,7 @@ namespace HandBrake.ApplicationServices.Parsing
}
// Multi-Angle Support if LibDvdNav is enabled
- if (!Init.DisableDvdNav)
+ if (!Properties.Settings.Default.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 dab4d168f..228bdbe14 100644
--- a/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs
+++ b/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs
@@ -22,5 +22,209 @@ 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;
+ }
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings b/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings
index 15034e76c..66c42127e 100644
--- a/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings
+++ b/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings
@@ -1,6 +1,57 @@
<?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
- <Profiles>
- <Profile Name="(Default)" />
- </Profiles>
-</SettingsFile>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="HandBrake.ApplicationServices.Properties" GeneratedClassName="Settings">
+ <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>
+ </Settings>
+</SettingsFile> \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
index d64a4479e..0208eaf98 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
@@ -28,6 +28,11 @@ namespace HandBrake.ApplicationServices.Services
#region Private Variables
/// <summary>
+ /// The User Setting Service
+ /// </summary>
+ private IUserSettingService userSettingService = new UserSettingService();
+
+ /// <summary>
/// The Log Buffer
/// </summary>
private StringBuilder logBuffer;
@@ -159,7 +164,7 @@ namespace HandBrake.ApplicationServices.Services
}
}
- if (Init.PreventSleep)
+ if (Properties.Settings.Default.PreventSleep)
{
Win32.PreventSleep();
}
@@ -170,7 +175,7 @@ namespace HandBrake.ApplicationServices.Services
RedirectStandardOutput = true,
RedirectStandardError = enableLogging ? true : false,
UseShellExecute = false,
- CreateNoWindow = !Init.ShowCliForInGuiEncodeStatus ? true : false
+ CreateNoWindow = !Properties.Settings.Default.ShowCLI ? true : false
};
this.HbProcess = new Process { StartInfo = cliStart };
@@ -194,7 +199,7 @@ namespace HandBrake.ApplicationServices.Services
}
// Set the Process Priority
- switch (Init.ProcessPriority)
+ switch (Properties.Settings.Default.ProcessPriority)
{
case "Realtime":
this.HbProcess.PriorityClass = ProcessPriorityClass.RealTime;
@@ -304,7 +309,7 @@ namespace HandBrake.ApplicationServices.Services
{
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
"\\HandBrake\\logs";
- string tempLogFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", Init.InstanceId));
+ string tempLogFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.GetInstanceCount));
string encodeDestinationPath = Path.GetDirectoryName(destination);
string destinationFile = Path.GetFileName(destination);
@@ -319,13 +324,12 @@ namespace HandBrake.ApplicationServices.Services
File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));
// Save a copy of the log file in the same location as the enocde.
- if (Init.SaveLogWithVideo)
+ if (Properties.Settings.Default.SaveLogWithVideo)
File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));
// Save a copy of the log file to a user specified location
- if (Directory.Exists(Init.SaveLogPath))
- if (Init.SaveLogPath != String.Empty && Init.SaveLogToSpecifiedPath)
- File.Copy(tempLogFile, Path.Combine(Init.SaveLogPath, encodeLogFile));
+ if (Directory.Exists(Properties.Settings.Default.SaveLogCopyDirectory) && Properties.Settings.Default.SaveLogToCopyDirectory)
+ File.Copy(tempLogFile, Path.Combine(Properties.Settings.Default.SaveLogCopyDirectory, encodeLogFile));
}
catch (Exception exc)
{
@@ -354,7 +358,7 @@ namespace HandBrake.ApplicationServices.Services
windowsSeven.SetTaskBarProgressToNoProgress();
}
- if (Init.PreventSleep)
+ if (Properties.Settings.Default.PreventSleep)
{
Win32.AllowSleep();
}
@@ -398,8 +402,8 @@ namespace HandBrake.ApplicationServices.Services
private void SetupLogging(QueueTask encodeQueueTask)
{
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
- string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", Init.InstanceId));
- string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", Init.InstanceId));
+ string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.GetInstanceCount));
+ string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", GeneralUtilities.GetInstanceCount));
try
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs
new file mode 100644
index 000000000..46ca316f4
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/Interfaces/IUserSettingService.cs
@@ -0,0 +1,69 @@
+/* IUserSettingService.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.Services.Interfaces
+{
+ /// <summary>
+ /// The User Setting Service Interace.
+ /// </summary>
+ public interface IUserSettingService
+ {
+ /// <summary>
+ /// Set the specified user setting.
+ /// </summary>
+ /// <param name="name">
+ /// Name of the property
+ /// </param>
+ /// <param name="value">
+ /// The value to store.
+ /// </param>
+ void SetUserSetting(string name, object value);
+
+ /// <summary>
+ /// Get an Integer type user setting
+ /// </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
+ /// </param>
+ /// <returns>
+ /// The settings value
+ /// </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);
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
index f46a8bad1..6381bb177 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
@@ -8,12 +8,10 @@ namespace HandBrake.ApplicationServices.Services
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
- using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
- using System.Windows.Data;
using System.Xml.Serialization;
using HandBrake.ApplicationServices.Model;
@@ -250,7 +248,7 @@ namespace HandBrake.ApplicationServices.Services
Category = category,
Name = presetName[0].Replace("+", string.Empty).Trim(),
Query = presetName[2],
- Version = Init.Version,
+ Version = Properties.Settings.Default.HandBrakeVersion,
CropSettings = pic,
Description = string.Empty, // Maybe one day we will populate this.
IsBuildIn = true
@@ -276,7 +274,7 @@ namespace HandBrake.ApplicationServices.Services
// Update built-in Presets if the built-in Presets belong to an older version.
if (this.presets.Count != 0)
{
- if (this.presets[0].Version != Init.Version)
+ if (this.presets[0].Version != Properties.Settings.Default.HandBrakeVersion)
{
this.UpdateBuiltInPresets(string.Empty);
return true;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index 130e1fc46..6f3bf2c1a 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -193,7 +193,7 @@ namespace HandBrake.ApplicationServices.Services
private void EncodeServiceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
{
// Growl
- if (Init.GrowlEncode)
+ if (Properties.Settings.Default.GrowlEncode)
GrowlCommunicator.Notify("Encode Completed",
"Put down that cocktail...\nyour Handbrake encode is done.");
@@ -247,11 +247,11 @@ namespace HandBrake.ApplicationServices.Services
private static void Finish()
{
// Growl
- if (Init.GrowlQueue)
+ if (Properties.Settings.Default.GrowlQueue)
GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done.");
// Do something whent he encode ends.
- switch (Init.CompletionOption)
+ switch (Properties.Settings.Default.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 38dddd2d6..e5bc320e2 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
@@ -159,7 +159,7 @@ namespace HandBrake.ApplicationServices.Services
"\\HandBrake\\logs";
string dvdInfoPath = Path.Combine(
logDir,
- string.Format("last_scan_log{0}.txt", Init.InstanceId == 0 ? string.Empty : Init.InstanceId.ToString()));
+ string.Format("last_scan_log{0}.txt", GeneralUtilities.GetInstanceCount));
// Make we don't pick up a stale last_encode_log.txt (and that we have rights to the file)
if (File.Exists(dvdInfoPath))
@@ -168,7 +168,7 @@ namespace HandBrake.ApplicationServices.Services
}
string extraArguments = string.Empty;
- if (Init.DisableDvdNav)
+ if (Properties.Settings.Default.DisableLibDvdNav)
{
extraArguments = " --no-dvdnav";
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs b/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs
index 5e65021e5..a932feee5 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/UpdateService.cs
@@ -1,4 +1,9 @@
-namespace HandBrake.ApplicationServices.Services
+/* UpdateService.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.Services
{
using System;
using System.IO;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs
new file mode 100644
index 000000000..87d77324f
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs
@@ -0,0 +1,95 @@
+/* UserSettingService.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.Services
+{
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ /// <summary>
+ /// The User Setting Serivce
+ /// </summary>
+ public class UserSettingService : IUserSettingService
+ {
+ /// <summary>
+ /// Set the specified user setting.
+ /// </summary>
+ /// <param name="name">
+ /// Name of the property
+ /// </param>
+ /// <param name="value">
+ /// The value to store.
+ /// </param>
+ public void SetUserSetting(string name, object value)
+ {
+ Properties.Settings.Default[name] = value;
+ Properties.Settings.Default.Save();
+ }
+
+ /// <summary>
+ /// Get an Integer type user setting
+ /// </summary>
+ /// <param name="name">
+ /// The setting name
+ /// </param>
+ /// <returns>
+ /// The settings value
+ /// </returns>
+ public int GetUserSettingInt(string name)
+ {
+ int value;
+ int.TryParse(Properties.Settings.Default[name].ToString(), out value);
+
+ return value;
+ }
+
+ /// <summary>
+ /// Get an String type user setting
+ /// </summary>
+ /// <param name="name">
+ /// The setting name
+ /// </param>
+ /// <returns>
+ /// The settings value
+ /// </returns>
+ public string GetUserSettingString(string name)
+ {
+ return Properties.Settings.Default[name].ToString();
+ }
+
+ /// <summary>
+ /// Get an Boolean type user setting
+ /// </summary>
+ /// <param name="name">
+ /// The setting name
+ /// </param>
+ /// <returns>
+ /// The settings value
+ /// </returns>
+ public bool GetUserSettingBoolean(string name)
+ {
+ bool value;
+ bool.TryParse(Properties.Settings.Default[name].ToString(), out value);
+
+ return value;
+ }
+
+ /// <summary>
+ /// Get an Double type user setting
+ /// </summary>
+ /// <param name="name">
+ /// The setting name
+ /// </param>
+ /// <returns>
+ /// The settings value
+ /// </returns>
+ public double GetUserSettingDouble(string name)
+ {
+ double value;
+ double.TryParse(Properties.Settings.Default[name].ToString(), out value);
+
+ return value;
+ }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Settings.StyleCop b/win/CS/HandBrake.ApplicationServices/Settings.StyleCop
index e61afbf69..7f55ce6c6 100644
--- a/win/CS/HandBrake.ApplicationServices/Settings.StyleCop
+++ b/win/CS/HandBrake.ApplicationServices/Settings.StyleCop
@@ -1,14 +1 @@
-<StyleCopSettings Version="4.3">
- <Analyzers>
- <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
- <Rules>
- <Rule Name="ElementsMustBeDocumented">
- <RuleSettings>
- <BooleanProperty Name="Enabled">True</BooleanProperty>
- </RuleSettings>
- </Rule>
- </Rules>
- <AnalyzerSettings />
- </Analyzer>
- </Analyzers>
-</StyleCopSettings> \ No newline at end of file
+<StyleCopSettings Version="4.3" /> \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/UserSettingConstants.cs b/win/CS/HandBrake.ApplicationServices/UserSettingConstants.cs
new file mode 100644
index 000000000..ba61a8255
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/UserSettingConstants.cs
@@ -0,0 +1,99 @@
+/* UserSettingConstants.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
+{
+ /// <summary>
+ /// Constants for the User Settings Service
+ /// </summary>
+ public class UserSettingConstants
+ {
+ /// <summary>
+ /// The Verbosity
+ /// </summary>
+ public const string Verbosity = "Verbosity";
+
+ /// <summary>
+ /// The X264 Stepper
+ /// </summary>
+ public const string X264Step = "X264Step";
+
+ /// <summary>
+ /// When Complete Action
+ /// </summary>
+ public const string WhenCompleteAction = "WhenCompleteAction";
+
+ /// <summary>
+ /// Growl Encodes
+ /// </summary>
+ public const string GrowlEncode = "GrowlEncode";
+
+ /// <summary>
+ /// Growl Queues
+ /// </summary>
+ public const string GrowlQueue = "GrowlQueue";
+
+ /// <summary>
+ /// Process Priority
+ /// </summary>
+ public const string ProcessPriority = "ProcessPriority";
+
+ /// <summary>
+ /// Prevent Sleep
+ /// </summary>
+ public const string PreventSleep = "PreventSleep";
+
+ /// <summary>
+ /// Show the CLI window
+ /// </summary>
+ public const string ShowCLI = "ShowCLI";
+
+ /// <summary>
+ /// Save Log Directory
+ /// </summary>
+ public const string SaveLogToCopyDirectory = "SaveLogToCopyDirectory";
+
+ /// <summary>
+ /// Save log with video
+ /// </summary>
+ public const string SaveLogWithVideo = "SaveLogWithVideo";
+
+ /// <summary>
+ /// Save copy of the log to a directory
+ /// </summary>
+ public const string SaveLogCopyDirectory = "SaveLogCopyDirectory";
+
+ /// <summary>
+ /// HandBrakes version
+ /// </summary>
+ public const string HandBrakeVersion = "HandBrakeVersion";
+
+ /// <summary>
+ /// HandBrakes build
+ /// </summary>
+ public const string HandBrakeBuild = "HandBrakeBuild";
+
+ /// <summary>
+ /// HandBrakes build
+ /// </summary>
+ public const string HandBrakePlatform = "HandBrakePlatform";
+
+
+ /// <summary>
+ /// HandBrakes CLI Exe SHA1 Hash
+ /// </summary>
+ public const string HandBrakeExeHash = "HandBrakeExeHash";
+
+ /// <summary>
+ /// The Instance Id
+ /// </summary>
+ public const string InstanceId = "InstanceId";
+
+ /// <summary>
+ /// Disable Libdvdnav
+ /// </summary>
+ public const string DisableLibDvdNav = "DisableLibDvdNav";
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
index 3f56213e8..e267e45f4 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
@@ -109,7 +109,7 @@ namespace HandBrake.ApplicationServices.Utilities
{
StringBuilder logHeader = new StringBuilder();
- logHeader.AppendLine(String.Format("{0}", Init.HandBrakeGuiVersionString));
+ logHeader.AppendLine(String.Format("HandBrake {0} {1}", Properties.Settings.Default.HandBrakeVersion, Properties.Settings.Default.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));
@@ -140,5 +140,27 @@ namespace HandBrake.ApplicationServices.Utilities
return string.Format("[{0}] {1}", DateTime.Now.TimeOfDay, message);
}
+ /// <summary>
+ /// Gets a value indicating whether HandBrake is running in multi instance mode
+ /// </summary>
+ /// <returns>True if the UI has another instance running</returns>
+ public static bool IsMultiInstance
+ {
+ get
+ {
+ return Process.GetProcessesByName("HandBrake").Length > 0 ? true : false;
+ }
+ }
+
+ /// <summary>
+ /// Gets the number of HandBrake instances running.
+ /// </summary>
+ public static string GetInstanceCount
+ {
+ get
+ {
+ return Process.GetProcessesByName("HandBrake").Length == 0 ? string.Empty : Process.GetProcessesByName("HandBrake").Length.ToString();
+ }
+ }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
index 4aed1799f..0a8aa72ec 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs
@@ -516,7 +516,7 @@ namespace HandBrake.ApplicationServices.Utilities
AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString());
// Preset Information
- AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", Init.Build.ToString());
+ AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", Properties.Settings.Default.HandBrakeBuild.ToString());
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 e092c6c7c..d47fd40c8 100644
--- a/win/CS/HandBrake.ApplicationServices/app.config
+++ b/win/CS/HandBrake.ApplicationServices/app.config
@@ -1,8 +1,68 @@
<?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></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>
+ </HandBrake.ApplicationServices.Properties.Settings>
+ </userSettings>
+</configuration>