diff options
Diffstat (limited to 'win/CS/Functions')
-rw-r--r-- | win/CS/Functions/Main.cs | 33 | ||||
-rw-r--r-- | win/CS/Functions/PresetLoader.cs | 7 | ||||
-rw-r--r-- | win/CS/Functions/QueryGenerator.cs | 15 |
3 files changed, 32 insertions, 23 deletions
diff --git a/win/CS/Functions/Main.cs b/win/CS/Functions/Main.cs index c436f4336..a4098cad6 100644 --- a/win/CS/Functions/Main.cs +++ b/win/CS/Functions/Main.cs @@ -17,10 +17,13 @@ namespace Handbrake.Functions using System.Windows.Forms;
using System.Xml.Serialization;
+ using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Extensions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
+ using HandBrake.ApplicationServices.Utilities;
using Handbrake.ToolWindows;
@@ -34,6 +37,8 @@ namespace Handbrake.Functions /// </summary>
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<QueueTask>));
+ private static readonly IUserSettingService UserSettingService = new UserSettingService();
+
/// <summary>
/// Set's up the DataGridView on the Chapters tab (frmMain)
/// </summary>
@@ -313,13 +318,13 @@ namespace Handbrake.Functions int buildValue;
int.TryParse(build, out buildValue);
- Properties.Settings.Default.hb_build = buildValue;
- Properties.Settings.Default.hb_version = version;
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakeBuild, buildValue);
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakeVersion, version);
}
if (platform.Success)
{
- Properties.Settings.Default.hb_platform = platform.Value.Replace("-", string.Empty).Trim();
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakePlatform, platform.Value.Replace("-", string.Empty).Trim());
}
if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
@@ -332,11 +337,15 @@ namespace Handbrake.Functions }
}
- Properties.Settings.Default.CliExeHash = base64Hash;
- Properties.Settings.Default.Save();
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakeExeHash, base64Hash);
}
catch (Exception e)
{
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakeBuild, string.Empty);
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakePlatform, string.Empty);
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakeVersion, string.Empty);
+ UserSettingService.SetUserSetting(UserSettingConstants.HandBrakeExeHash, string.Empty);
+
ShowExceptiowWindow("Unable to retrieve version information from the CLI.", e.ToString());
// Probably corrupted config. Delete config and let the user restart.
RecoverFromCorruptedLocalApplicationConfig();
@@ -421,7 +430,7 @@ namespace Handbrake.Functions }
else
{
- if (IsMultiInstance) return; // Don't tamper with the files if we are multi instance
+ if (GeneralUtilities.IsMultiInstance) return; // Don't tamper with the files if we are multi instance
foreach (string file in queueFiles)
{
@@ -432,18 +441,6 @@ namespace Handbrake.Functions }
/// <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>
/// Show the Exception Window
/// </summary>
/// <param name="shortError">
diff --git a/win/CS/Functions/PresetLoader.cs b/win/CS/Functions/PresetLoader.cs index 373d30ff8..7b36ab92f 100644 --- a/win/CS/Functions/PresetLoader.cs +++ b/win/CS/Functions/PresetLoader.cs @@ -8,14 +8,19 @@ namespace Handbrake.Functions using System.Drawing;
using System.Windows.Forms;
+ using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
/// <summary>
/// Load a preset into the main Window
/// </summary>
public class PresetLoader
{
+ private static readonly IUserSettingService UserSettingService = new UserSettingService();
+
/// <summary>
/// This function takes in a Query which has been parsed by QueryParser and
/// set's all the GUI widgets correctly.
@@ -300,7 +305,7 @@ namespace Handbrake.Functions sliderValue = 32 - (int)value;
break;
case VideoEncoder.X264:
- double cqStep = Properties.Settings.Default.x264cqstep;
+ double cqStep = UserSettingService.GetUserSettingDouble(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 ce9f6f00b..297b0ab44 100644 --- a/win/CS/Functions/QueryGenerator.cs +++ b/win/CS/Functions/QueryGenerator.cs @@ -11,6 +11,10 @@ namespace Handbrake.Functions using System.IO;
using System.Windows.Forms;
+ using HandBrake.ApplicationServices;
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
using Handbrake.Model;
/// <summary>
@@ -18,6 +22,9 @@ namespace Handbrake.Functions /// </summary>
public class QueryGenerator
{
+ private static readonly IUserSettingService UserSettingService = new UserSettingService();
+
+
public static string GenerateQueryForPreset(frmMain mainWindow, QueryPictureSettingsMode mode, bool filters, int width, int height)
{
string query = string.Empty;
@@ -112,7 +119,7 @@ namespace Handbrake.Functions query += " -t " + titleInfo[0];
}
- if (!Properties.Settings.Default.noDvdNav && mainWindow.drop_angle.Items.Count != 0)
+ if (!UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav) && mainWindow.drop_angle.Items.Count != 0)
query += " --angle " + mainWindow.drop_angle.SelectedItem;
// Decide what part of the video we want to encode.
@@ -310,7 +317,7 @@ namespace Handbrake.Functions // Video Quality Setting
if (mainWindow.radio_cq.Checked)
{
- double cqStep = Properties.Settings.Default.x264cqstep;
+ double cqStep = UserSettingService.GetUserSettingDouble(UserSettingConstants.X264Step);
double value;
switch (mainWindow.drp_videoEncoder.Text)
{
@@ -568,10 +575,10 @@ namespace Handbrake.Functions string query = string.Empty;
// Verbosity Level
- query += " --verbose=" + Properties.Settings.Default.verboseLevel;
+ query += " --verbose=" + UserSettingService.GetUserSettingInt(UserSettingConstants.Verbosity);
// LibDVDNav
- if (Properties.Settings.Default.noDvdNav)
+ if (UserSettingService.GetUserSettingBoolean(UserSettingConstants.DisableLibDvdNav))
query += " --no-dvdnav";
return query;
|