diff options
author | sr55 <[email protected]> | 2012-08-25 14:05:56 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-08-25 14:05:56 +0000 |
commit | 5c878c4eab2f01acc386165fca26d2f3ef943b77 (patch) | |
tree | 5e7a7257147ad1f074297dcd28af691a554cae97 /win/CS/HandBrake.ApplicationServices/Utilities | |
parent | cbe5f09e69c95df3be3b38de06c2b7bd6b5bd949 (diff) |
WinGui: General Tidyup of the Services Library API.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4915 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
3 files changed, 69 insertions, 82 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs index 696eaedef..bebdc734d 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs @@ -106,35 +106,24 @@ namespace HandBrake.ApplicationServices.Utilities /// <summary>
/// Add the CLI Query to the Log File.
/// </summary>
+ /// <param name="version">
+ /// The version.
+ /// </param>
+ /// <param name="build">
+ /// The build.
+ /// </param>
/// <returns>
/// The create cli log header.
/// </returns>
- public static StringBuilder CreateCliLogHeader()
+ public static StringBuilder CreateCliLogHeader(string version, int build)
{
var logHeader = new StringBuilder();
- IUserSettingService userSettingService;
- try
- {
- userSettingService = IoC.Get<IUserSettingService>();
- }
- catch (Exception)
- {
- // TODO Sort this out. Should not be calling IoC.Get or creating a new instance here.
- userSettingService = new UserSettingService();
- }
-
- logHeader.AppendLine(
- String.Format(
- "HandBrake {0} {1}",
- userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion),
- userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)));
+ logHeader.AppendLine(String.Format("HandBrake {0} {1}", version, build));
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));
- logHeader.AppendLine(
- String.Format(
- "Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
+ logHeader.AppendLine(String.Format("Screen: {0}x{1}", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height));
logHeader.AppendLine(String.Format("Temp Dir: {0}", Path.GetTempPath()));
logHeader.AppendLine(String.Format("Install Dir: {0}", Application.StartupPath));
logHeader.AppendLine(String.Format("Data Dir: {0}\n", Application.UserAppDataPath));
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 871bc5adc..797c456f3 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -16,12 +16,9 @@ namespace HandBrake.ApplicationServices.Utilities using System.Windows.Forms;
using System.Xml;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Services;
- using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
/// <summary>
@@ -29,11 +26,6 @@ namespace HandBrake.ApplicationServices.Utilities /// </summary>
public class PlistUtility
{
- /// <summary>
- /// The User Setting Service
- /// </summary>
- private static IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
-
#region Import
/// <summary>
@@ -490,7 +482,10 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="preset">
/// The preset.
/// </param>
- public static void Export(string path, Preset preset)
+ /// <param name="build">
+ /// The build.
+ /// </param>
+ public static void Export(string path, Preset preset, string build)
{
if (string.IsNullOrEmpty(path))
{
@@ -509,7 +504,7 @@ namespace HandBrake.ApplicationServices.Utilities xmlWriter.WriteStartElement("array");
// Add New Preset Here. Can write multiple presets here if required in future.
- WritePreset(xmlWriter, parsed, preset);
+ WritePreset(xmlWriter, parsed, preset, build);
// Footer
xmlWriter.WriteEndElement();
@@ -534,11 +529,14 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="preset">
/// The preset.
/// </param>
- private static void WritePreset(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset)
+ /// <param name="build">
+ /// The build.
+ /// </param>
+ private static void WritePreset(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset, string build)
{
xmlWriter.WriteStartElement("dict");
AudioListArrayDict(xmlWriter, parsed);
- AddEncodeSettings(xmlWriter, parsed, preset);
+ AddEncodeSettings(xmlWriter, parsed, preset, build);
xmlWriter.WriteEndElement();
}
@@ -574,7 +572,10 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="preset">
/// The preset.
/// </param>
- private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset)
+ /// <param name="build">
+ /// The build.
+ /// </param>
+ private static void AddEncodeSettings(XmlTextWriter xmlWriter, EncodeTask parsed, Preset preset, string build)
{
AddEncodeElement(xmlWriter, "AudioAllowAACPass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowAACPass));
AddEncodeElement(xmlWriter, "AudioAllowAC3Pass", "integer", getNullBoolValue(parsed.AllowedPassthruOptions.AudioAllowAC3Pass));
@@ -701,7 +702,7 @@ namespace HandBrake.ApplicationServices.Utilities AddEncodeElement(xmlWriter, "PictureWidth", "integer", parsed.Width.ToString());
// Preset Information
- AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild).ToString());
+ AddEncodeElement(xmlWriter, "PresetBuildNumber", "string", build);
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/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index b28de2264..2bd04a93f 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -15,12 +15,8 @@ namespace HandBrake.ApplicationServices.Utilities using System.Globalization;
using System.IO;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
- using HandBrake.ApplicationServices.Services;
- using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
@@ -30,38 +26,29 @@ namespace HandBrake.ApplicationServices.Utilities public class QueryGeneratorUtility
{
/// <summary>
- /// Backing field for the user settings service.
- /// </summary>
- private static IUserSettingService UserSettingService;
-
- /// <summary>
/// Generate a CLI Query for an EncodeTask Model object
/// </summary>
/// <param name="task">
/// The task.
/// </param>
+ /// <param name="previewScanCount">
+ /// The preview Scan Count.
+ /// </param>
+ /// <param name="verbosity">
+ /// The verbosity.
+ /// </param>
+ /// <param name="disableLibDvdNav">
+ /// The disable Lib Dvd Nav.
+ /// </param>
/// <returns>
/// A Cli Query
/// </returns>
- public static string GenerateQuery(EncodeTask task)
+ public static string GenerateQuery(EncodeTask task, int previewScanCount, int verbosity, bool disableLibDvdNav)
{
- // TODO Remove this quick hack
- if (UserSettingService == null)
- {
- try
- {
- UserSettingService = IoC.Get<IUserSettingService>();
- }
- catch (Exception exc)
- {
- UserSettingService = new UserSettingService();
- }
- }
-
string query = string.Empty;
- query += SourceQuery(task, null, null);
+ query += SourceQuery(task, null, null, previewScanCount);
query += DestinationQuery(task);
- query += GenerateTabbedComponentsQuery(task, true);
+ query += GenerateTabbedComponentsQuery(task, true, verbosity, disableLibDvdNav);
return query;
}
@@ -78,28 +65,24 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="startAtPreview">
/// The start At Preview.
/// </param>
+ /// <param name="previewScanCount">
+ /// The preview Scan Count.
+ /// </param>
+ /// <param name="verbosity">
+ /// The verbosity.
+ /// </param>
+ /// <param name="disableLibDvdNav">
+ /// The disable Lib Dvd Nav.
+ /// </param>
/// <returns>
/// A Cli query suitable for generating a preview video.
/// </returns>
- public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview)
+ public static string GeneratePreviewQuery(EncodeTask task, int duration, string startAtPreview, int previewScanCount, int verbosity, bool disableLibDvdNav)
{
- // TODO Remove this quick hack
- if (UserSettingService == null)
- {
- try
- {
- UserSettingService = IoC.Get<IUserSettingService>();
- }
- catch (Exception exc)
- {
- UserSettingService = new UserSettingService();
- }
- }
-
string query = string.Empty;
- query += SourceQuery(task, duration, startAtPreview);
+ query += SourceQuery(task, duration, startAtPreview, previewScanCount);
query += DestinationQuery(task);
- query += GenerateTabbedComponentsQuery(task, true);
+ query += GenerateTabbedComponentsQuery(task, true, verbosity, disableLibDvdNav);
return query;
}
@@ -115,10 +98,16 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="enableFilters">
/// The enableFilters.
/// </param>
+ /// <param name="verbosity">
+ /// The verbosity.
+ /// </param>
+ /// <param name="disableLibDvdNav">
+ /// The disable Lib Dvd Nav.
+ /// </param>
/// <returns>
/// The CLI query for the Tabbed section of the main window UI
/// </returns>
- private static string GenerateTabbedComponentsQuery(EncodeTask task, bool enableFilters)
+ private static string GenerateTabbedComponentsQuery(EncodeTask task, bool enableFilters, int verbosity, bool disableLibDvdNav)
{
string query = string.Empty;
@@ -148,7 +137,7 @@ namespace HandBrake.ApplicationServices.Utilities query += AdvancedQuery(task);
// Extra Settings
- query += ExtraSettings();
+ query += ExtraSettings(verbosity, disableLibDvdNav);
return query;
}
@@ -165,10 +154,13 @@ namespace HandBrake.ApplicationServices.Utilities /// <param name="preview">
/// The preview.
/// </param>
+ /// <param name="previewScanCount">
+ /// The preview Scan Count.
+ /// </param>
/// <returns>
/// A Cli Query as a string
/// </returns>
- private static string SourceQuery(EncodeTask task, int? duration, string preview)
+ private static string SourceQuery(EncodeTask task, int? duration, string preview, int previewScanCount)
{
string query = string.Empty;
@@ -198,7 +190,7 @@ namespace HandBrake.ApplicationServices.Utilities query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", task.StartPoint, calculatedDuration);
break;
case PointToPointMode.Preview: // Preview
- query += " --previews " + UserSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount) + " ";
+ query += " --previews " + previewScanCount + " ";
query += " --start-at-preview " + preview;
query += " --stop-at duration:" + duration + " ";
break;
@@ -946,19 +938,24 @@ namespace HandBrake.ApplicationServices.Utilities /// <summary>
/// Generate the Command Line Arguments for any additional advanced options.
/// </summary>
+ /// <param name="verbosity">
+ /// The verbosity.
+ /// </param>
+ /// <param name="disableLibdvdNav">
+ /// The disable Libdvd Nav.
+ /// </param>
/// <returns>
/// A Cli Query as a string
/// </returns>
- private static string ExtraSettings()
+ private static string ExtraSettings(int verbosity, bool disableLibdvdNav)
{
string query = string.Empty;
// Verbosity Level
- int verbosity = UserSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity);
query += string.Format(" --verbose={0}", verbosity);
// LibDVDNav
- if (UserSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))
+ if (disableLibdvdNav)
query += " --no-dvdnav";
return query;
|