summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Services
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-04-03 17:49:44 +0000
committersr55 <[email protected]>2011-04-03 17:49:44 +0000
commita6fbb52b6c9f4b639101e6e4d37e670ca2840c84 (patch)
tree5bf6b9a4d945365ba07dd07ba77fd05019d0e086 /win/CS/HandBrake.ApplicationServices/Services
parent80ebbf6f36a9084dd19e04e1cbfbd9ec93bfb6b6 (diff)
WinGui:
- Move all user settings for the Services library into the services library. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3899 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
-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
7 files changed, 192 insertions, 21 deletions
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;
+ }
+ }
+}