summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-08-03 15:26:14 +0000
committersr55 <[email protected]>2009-08-03 15:26:14 +0000
commitbd7f9d53243dde4bd44d50004e0022151b0a2af3 (patch)
tree29e660b4faaf20a350bf5c91d71ade0315122686 /win/C#/Functions
parent30e5a9e1a2a09f134db33d7779e21cea05203087 (diff)
WinGui:
- Mostly just code re-factoring. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2748 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions')
-rw-r--r--win/C#/Functions/QueryGenerator.cs74
1 files changed, 23 insertions, 51 deletions
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
index 248ee188e..42b962541 100644
--- a/win/C#/Functions/QueryGenerator.cs
+++ b/win/C#/Functions/QueryGenerator.cs
@@ -15,13 +15,14 @@ namespace Handbrake.Functions
class QueryGenerator
{
/// <summary>
- /// Generates a CLI query based on the GUI widgets.
+ /// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.
/// </summary>
/// <param name="mainWindow"></param>
- /// <returns>The CLI String</returns>
- public string generateTheQuery(frmMain mainWindow)
+ /// <param name="duration"></param>
+ /// <param name="preview"></param>
+ /// <returns></returns>
+ public string generateCLIQuery(frmMain mainWindow, int duration, string preview)
{
- // Source tab
string query = "";
if (!string.IsNullOrEmpty(mainWindow.sourcePath))
@@ -38,58 +39,30 @@ namespace Handbrake.Functions
if (mainWindow.drop_angle.Items.Count != 0)
query += " --angle " + mainWindow.drop_angle.SelectedItem;
- if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")
- query += " -c " + mainWindow.drop_chapterStart.Text;
- else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
- query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;
- else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")
- query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;
-
- // Destination tab
- if (mainWindow.text_destination.Text != "")
- query += " -o " + '"' + mainWindow.text_destination.Text + '"';
-
- query += generateTabbedComponentsQuery(mainWindow);
- return query;
- }
-
- /// <summary>
- /// Generates a CLI query for the preview function.
- /// This basically forces a shortened version of the encdode.
- /// </summary>
- /// <param name="mainWindow"></param>
- /// <param name="duration">Duration</param>
- /// <param name="preview">Start at preview</param>
- /// <returns>Returns a CLI query String.</returns>
- public string generatePreviewQuery(frmMain mainWindow, string duration, string preview)
- {
- int seconds;
- int.TryParse(duration, out seconds);
-
- // Source tab
- string query = "";
- if (!string.IsNullOrEmpty(mainWindow.sourcePath))
- if (mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")
- query = " -i " + '"' + mainWindow.sourcePath + '"';
+ if (duration != 0 && preview != null) // Preivew Query
+ {
+ query += " --start-at-preview " + preview;
+ query += " --stop-at duration:" + duration + " ";
- if (mainWindow.drp_dvdtitle.Text != "Automatic")
+ if (mainWindow.text_destination.Text != "")
+ query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"';
+ }
+ else // Non Preview Query
{
- string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');
- query += " -t " + titleInfo[0];
+ if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")
+ query += " -c " + mainWindow.drop_chapterStart.Text;
+ else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
+ query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;
+ else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "")
+ query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;
+
+ if (mainWindow.text_destination.Text != "")
+ query += " -o " + '"' + mainWindow.text_destination.Text + '"';
}
- if (mainWindow.drop_angle.SelectedIndex != 0)
- query += " --angle " + mainWindow.drop_angle.SelectedItem;
-
- query += " --start-at-preview " + preview;
- query += " --stop-at duration:" + duration + " ";
-
- // Destination tab
- if (mainWindow.text_destination.Text != "")
- query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"';
-
query += generateTabbedComponentsQuery(mainWindow);
+
return query;
}
@@ -606,7 +579,6 @@ namespace Handbrake.Functions
file.Close();
file.Dispose();
return true;
-
}
catch (Exception exc)
{