summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/Functions')
-rw-r--r--win/C#/Functions/Common.cs81
-rw-r--r--win/C#/Functions/Encode.cs (renamed from win/C#/Functions/CLI.cs)28
-rw-r--r--win/C#/Functions/QueryParser.cs2
3 files changed, 84 insertions, 27 deletions
diff --git a/win/C#/Functions/Common.cs b/win/C#/Functions/Common.cs
index fc2b3c23a..87256dc55 100644
--- a/win/C#/Functions/Common.cs
+++ b/win/C#/Functions/Common.cs
@@ -5,18 +5,19 @@
It may be used under the terms of the GNU General Public License. */
using System;
-using System.Collections.Generic;
+using System.Collections;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
using System.Drawing;
+using System.Diagnostics;
+using System.Text.RegularExpressions;
namespace Handbrake.Functions
{
class Common
{
-
/// <summary>
/// Checks for updates and returns true if an update is available.
/// </summary>
@@ -50,6 +51,64 @@ namespace Handbrake.Functions
}
/// <summary>
+ /// Get's HandBrakes version data from the CLI.
+ /// </summary>
+ /// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>
+ public ArrayList getCliVersionData()
+ {
+ ArrayList cliVersionData = new ArrayList();
+ // 0 = SVN Build / Version
+ // 1 = Build Date
+
+ Process cliProcess = new Process();
+ ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u");
+ handBrakeCLI.UseShellExecute = false;
+ handBrakeCLI.RedirectStandardError = true;
+ handBrakeCLI.RedirectStandardOutput = true;
+ handBrakeCLI.CreateNoWindow = true;
+ cliProcess.StartInfo = handBrakeCLI;
+ cliProcess.Start();
+
+ // Retrieve standard output and report back to parent thread until the process is complete
+ String line;
+ TextReader stdOutput = cliProcess.StandardError;
+
+ while (!cliProcess.HasExited)
+ {
+ line = stdOutput.ReadLine();
+ Match m = Regex.Match(line, @"HandBrake svn[0-9]*[M]* \([0-9]*\)");
+ if (m.Success != false)
+ {
+ string data = line.Replace("(", "").Replace(")","").Replace("HandBrake ","");
+ string[] arr = data.Split(' ');
+ cliVersionData.Add(arr[0]);
+ cliVersionData.Add(arr[1]);
+ return cliVersionData;
+ }
+ }
+ return null;
+ }
+
+ /// <summary>
+ /// Update the presets.dat file with the latest version of HandBrak's presets from the CLI
+ /// </summary>
+ public void grabCLIPresets()
+ {
+ string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
+ string presetsPath = Path.Combine(Application.StartupPath, "presets.dat");
+
+ string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
+
+ ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);
+ hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;
+
+ Process hbproc = Process.Start(hbGetPresets);
+ hbproc.WaitForExit();
+ hbproc.Dispose();
+ hbproc.Close();
+ }
+
+ /// <summary>
/// Function which generates the filename and path automatically based on
/// the Source Name, DVD title and DVD Chapters
/// </summary>
@@ -166,6 +225,20 @@ namespace Handbrake.Functions
mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
+ if (presetQuery.Format != null)
+ {
+ if (presetQuery.Format == "mp4")
+ mainWindow.drop_format.SelectedIndex = 0;
+ else if (presetQuery.Format == "m4v")
+ mainWindow.drop_format.SelectedIndex = 1;
+ else if (presetQuery.Format == "mkv")
+ mainWindow.drop_format.SelectedIndex = 2;
+ else if (presetQuery.Format == "avi")
+ mainWindow.drop_format.SelectedIndex = 3;
+ else if (presetQuery.Format == "ogm")
+ mainWindow.drop_format.SelectedIndex = 4;
+ }
+
if (presetQuery.IpodAtom == true)
mainWindow.check_iPodAtom.CheckState = CheckState.Checked;
else
@@ -178,6 +251,8 @@ namespace Handbrake.Functions
#endregion
+
+
// Picture Settings Tab
#region Picture
mainWindow.drp_crop.SelectedIndex = 1;
@@ -718,7 +793,7 @@ namespace Handbrake.Functions
// Now set the longest title in the gui.
mainWindow.drp_dvdtitle.SelectedItem = title2Select;
- }
+ }
}
// Generates part of the CLI query, for the tabbed components only.
diff --git a/win/C#/Functions/CLI.cs b/win/C#/Functions/Encode.cs
index 259397af3..eb1263585 100644
--- a/win/C#/Functions/CLI.cs
+++ b/win/C#/Functions/Encode.cs
@@ -15,7 +15,7 @@ using System.Runtime.InteropServices;
namespace Handbrake.Functions
{
- public class CLI
+ public class Encode
{
/// <summary>
/// CLI output is based on en-US locale,
@@ -42,7 +42,8 @@ namespace Handbrake.Functions
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
string logPath = Path.Combine(Path.GetTempPath(), "hb_encode_log.dat");
- string strCmdLine = String.Format(@"cmd /c """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);
+ string strCmdLine = String.Format(@" cmd /c """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);
+ //string arguments = String.Format(@"{0} 2>""{1}""", query, logPath);
ProcessStartInfo cliStart = new ProcessStartInfo("CMD.exe", strCmdLine);
@@ -71,9 +72,9 @@ namespace Handbrake.Functions
break;
}
}
- catch
+ catch (Exception exc)
{
- MessageBox.Show("Internal Software Error. Please Restart the Program");
+ MessageBox.Show("Internal Software Error. Please Restart the Program. Error Information: \n\n" + exc.ToString());
}
return hbProc;
}
@@ -110,24 +111,5 @@ namespace Handbrake.Functions
break;
}
}
-
- /// <summary>
- /// Update the presets.dat file with the latest version of HandBrak's presets from the CLI
- /// </summary>
- public void grabCLIPresets()
- {
- string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
- string presetsPath = Path.Combine(Application.StartupPath, "presets.dat");
-
- string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
-
- ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);
- hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;
-
- Process hbproc = Process.Start(hbGetPresets);
- hbproc.WaitForExit();
- hbproc.Dispose();
- hbproc.Close();
- }
}
}
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs
index c7998c5be..8970a562f 100644
--- a/win/C#/Functions/QueryParser.cs
+++ b/win/C#/Functions/QueryParser.cs
@@ -1010,7 +1010,7 @@ namespace Handbrake.Functions
double qConvert = 0;
if (videoQuality.Success != false)
{
- qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.CLI.Culture) * 100;
+ qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;
qConvert = System.Math.Ceiling(qConvert);
thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
}