diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
13 files changed, 112 insertions, 13 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs b/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs index b492bc2f0..ad6a56221 100644 --- a/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs +++ b/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs @@ -6,6 +6,7 @@ namespace HandBrake.ApplicationServices.Collections
{
using System.Collections.Generic;
+ using System.Collections.Specialized;
using System.Runtime.Serialization;
using System.Xml.Serialization;
@@ -60,7 +61,16 @@ namespace HandBrake.ApplicationServices.Collections reader.ReadEndElement();
reader.ReadStartElement("value");
- TValue value = (TValue)valueSerializer.Deserialize(reader);
+ TValue value;
+ if (reader.Name.Contains("ArrayOfString"))
+ {
+ XmlSerializer scSerializer = new XmlSerializer(typeof(StringCollection));
+ value = (TValue)scSerializer.Deserialize(reader);
+ }
+ else
+ {
+ value = (TValue)valueSerializer.Deserialize(reader);
+ }
reader.ReadEndElement();
this.Add(key, value);
@@ -92,8 +102,18 @@ namespace HandBrake.ApplicationServices.Collections writer.WriteStartElement("value");
TValue value = this[key];
- valueSerializer.Serialize(writer, value);
- writer.WriteEndElement();
+
+ if (value.GetType() == typeof(StringCollection))
+ {
+ XmlSerializer scSerializer = new XmlSerializer(typeof(StringCollection));
+ scSerializer.Serialize(writer, value);
+ writer.WriteEndElement();
+ }
+ else
+ {
+ valueSerializer.Serialize(writer, value);
+ writer.WriteEndElement();
+ }
writer.WriteEndElement();
}
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 78480847c..0c417c279 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -128,6 +128,7 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
+ <Compile Include="ServiceManager.cs" />
<Compile Include="Services\Base\EncodeBase.cs" />
<Compile Include="Services\Encode.cs" />
<Compile Include="Services\Interfaces\IEncode.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index 1ddb4730d..ac8bcf6d3 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -32,7 +32,7 @@ namespace HandBrake.ApplicationServices.Parsing /// <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="Title"/> class.
diff --git a/win/CS/HandBrake.ApplicationServices/ServiceManager.cs b/win/CS/HandBrake.ApplicationServices/ServiceManager.cs new file mode 100644 index 000000000..06b4422e2 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/ServiceManager.cs @@ -0,0 +1,27 @@ +namespace HandBrake.ApplicationServices
+{
+ using HandBrake.ApplicationServices.Services;
+ using HandBrake.ApplicationServices.Services.Interfaces;
+
+ /// <summary>
+ /// Tempory Class which manages services until Windosor is added back into the project to handle it for us.
+ /// </summary>
+ public class ServiceManager
+ {
+ /// <summary>
+ /// Backing Field for the User Setting Service.
+ /// </summary>
+ private static IUserSettingService userSettingService;
+
+ /// <summary>
+ /// Gets UserSettingService.
+ /// </summary>
+ public static IUserSettingService UserSettingService
+ {
+ get
+ {
+ return userSettingService ?? (userSettingService = new UserSettingService());
+ }
+ }
+ }
+}
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;
}
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index 746f36937..b2187ed4b 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -25,7 +25,7 @@ namespace HandBrake.ApplicationServices.Utilities /// <summary>
/// The User Setting Service
/// </summary>
- private static IUserSettingService userSettingService = new UserSettingService();
+ private static IUserSettingService userSettingService = ServiceManager.UserSettingService;
/// <summary>
/// The Default Log Directory
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index a75741277..392abc569 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -27,7 +27,7 @@ namespace HandBrake.ApplicationServices.Utilities /// <summary>
/// The User Setting Service
/// </summary>
- private static IUserSettingService userSettingService = new UserSettingService();
+ private static IUserSettingService userSettingService = ServiceManager.UserSettingService;
/**
* TODO:
|