diff options
author | sr55 <[email protected]> | 2011-08-15 19:23:58 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-08-15 19:23:58 +0000 |
commit | 746186658150dcbca2721d6d6fea77b4d7c09467 (patch) | |
tree | ebf2f050abe5418dbf4acf6cb1602815eb786d49 /win/CS/HandBrake.ApplicationServices/Services | |
parent | 774af7004dd17c59fee9606273cd52a24867eb98 (diff) |
WinGui: Add a service manager to maintain single instances of services & update the user settings service to import defaults from an xml file.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4177 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
7 files changed, 58 insertions, 7 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 48505fc6f..6ab0e52a8 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -30,7 +30,7 @@ namespace HandBrake.ApplicationServices.Services.Base /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = new UserSettingService();
+ private IUserSettingService userSettingService = ServiceManager.UserSettingService;
/// <summary>
/// Windows 7 API Pack wrapper
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 04290eced..70f8f86ee 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -28,7 +28,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = new UserSettingService();
+ private IUserSettingService userSettingService = ServiceManager.UserSettingService;
/// <summary>
/// Gets The Process Handle
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index e677d4784..7ee9a9df3 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -35,7 +35,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = new UserSettingService();
+ private IUserSettingService userSettingService = ServiceManager.UserSettingService;
/// <summary>
/// The Start time of the current Encode;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index 9cad60e4e..b856577a9 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -42,7 +42,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = new UserSettingService();
+ private IUserSettingService userSettingService = ServiceManager.UserSettingService;
/// <summary>
/// The User Preset file
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index 30ba395f4..478fa3661 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -23,7 +23,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private static IUserSettingService userSettingService = new UserSettingService();
+ private static IUserSettingService userSettingService = ServiceManager.UserSettingService;
/// <summary>
/// Initializes a new instance of the <see cref="QueueProcessor"/> class.
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index 652115c06..a9c9e07ce 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -47,7 +47,7 @@ namespace HandBrake.ApplicationServices.Services /// <summary>
/// The User Setting Service
/// </summary>
- private IUserSettingService userSettingService = new UserSettingService();
+ private IUserSettingService userSettingService = ServiceManager.UserSettingService;
#endregion
diff --git a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs index 424d0a752..6a8584018 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs @@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Services using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
+ using System.Windows.Forms;
using System.Xml.Serialization;
using HandBrake.ApplicationServices.Collections;
@@ -139,7 +140,22 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
private void LoadDefaults()
{
- // TODO, maybe extract this out to a file.
+ string defaults = Path.Combine(Application.StartupPath, "defaultsettings.xml");
+ if (File.Exists(defaults))
+ {
+ using (StreamReader reader = new StreamReader(defaults))
+ {
+ SerializableDictionary<string, object> data = (SerializableDictionary<string, object>)serializer.Deserialize(reader);
+ this.userSettings = data;
+ }
+ }
+ }
+
+ /// <summary>
+ /// This is just a utility method for creating a defaults xml file. Don't use this!!!
+ /// </summary>
+ private void SetAllDefaults()
+ {
userSettings = new SerializableDictionary<string, object>();
userSettings[UserSettingConstants.X264Step] = 0.25;
userSettings[UserSettingConstants.Verbosity] = 1;
@@ -156,6 +172,41 @@ namespace HandBrake.ApplicationServices.Services userSettings[UserSettingConstants.MinScanDuration] = 10;
userSettings[UserSettingConstants.HandBrakeBuild] = 0;
userSettings[UserSettingConstants.HandBrakeVersion] = string.Empty;
+ userSettings["updateStatus"] = true;
+ userSettings["tooltipEnable"] = true;
+ userSettings["defaultPreset"] = string.Empty;
+ userSettings["skipversion"] = 0;
+ userSettings["autoNaming"] = true;
+ userSettings["autoNamePath"] = string.Empty;
+ userSettings["appcast"] = "http://handbrake.fr/appcast.xml";
+ userSettings["appcast_unstable"] = "http://handbrake.fr/appcast_unstable.xml";
+ userSettings["autoNameFormat"] = "{source}-{title}";
+ userSettings["VLC_Path"] = "C:\\Program Files\\VideoLAN\\vlc\\vlc.exe";
+ userSettings["MainWindowMinimize"] = true;
+ userSettings["QueryEditorTab"] = false;
+ userSettings["presetNotification"] = false;
+ userSettings["trayIconAlerts"] = true;
+ userSettings["lastUpdateCheckDate"] = DateTime.Today;
+ userSettings["daysBetweenUpdateCheck"] = 7;
+ userSettings["useM4v"] = 0;
+ userSettings["PromptOnUnmatchingQueries"] = true;
+ userSettings["NativeLanguage"] = "Any";
+ userSettings["DubMode"] = 255;
+ userSettings["CliExeHash"] = string.Empty;
+ userSettings["previewScanCount"] = 10;
+ userSettings["clearOldLogs"] = true;
+ userSettings["AutoNameTitleCase"] = true;
+ userSettings["AutoNameRemoveUnderscore"] = true;
+ userSettings["ActivityWindowLastMode"] = 0;
+ userSettings["useClosedCaption"] = false;
+ userSettings["batchMinDuration"] = 35;
+ userSettings["batchMaxDuration"] = 65;
+ userSettings["defaultPlayer"] = false;
+ userSettings["SelectedLanguages"] = new StringCollection();
+ userSettings["DubModeAudio"] = 0;
+ userSettings["DubModeSubtitle"] = 0;
+ userSettings["addOnlyOneAudioPerLanguage"] = true;
+ userSettings["MinTitleLength"] = 10;
}
}
}
|