diff options
author | brianmario <[email protected]> | 2007-07-18 08:32:09 +0000 |
---|---|---|
committer | brianmario <[email protected]> | 2007-07-18 08:32:09 +0000 |
commit | 2ffb589f0bd275962e526c673b01d7d08237245d (patch) | |
tree | 4ed35989279524a7121a42841f372d803a2995bb /win | |
parent | a0985795ca8a5f003272f713c57cd208b8097872 (diff) |
WinGui:
continued adding to CLI manager code
updated frmDvdInfo to display data parsed from STDOUT/STDERR
minor updates to form constructors
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@708 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r-- | win/C#/CLI/Jobs/Encode.cs | 15 | ||||
-rw-r--r-- | win/C#/CLI/Jobs/Job.cs | 28 | ||||
-rw-r--r-- | win/C#/CLI/Jobs/ParseDVD.cs | 15 | ||||
-rw-r--r-- | win/C#/CLI/Manager.cs | 83 | ||||
-rw-r--r-- | win/C#/HandBrakeCS.csproj | 3 | ||||
-rw-r--r-- | win/C#/frmAbout.Designer.cs | 1 | ||||
-rw-r--r-- | win/C#/frmAbout.cs | 7 | ||||
-rw-r--r-- | win/C#/frmDvdInfo.cs | 28 | ||||
-rw-r--r-- | win/C#/frmOptions.Designer.cs | 1 | ||||
-rw-r--r-- | win/C#/frmOptions.cs | 9 | ||||
-rw-r--r-- | win/C#/frmReadDVD.Designer.cs | 6 | ||||
-rw-r--r-- | win/C#/frmReadDVD.cs | 9 |
12 files changed, 176 insertions, 29 deletions
diff --git a/win/C#/CLI/Jobs/Encode.cs b/win/C#/CLI/Jobs/Encode.cs new file mode 100644 index 000000000..e09673856 --- /dev/null +++ b/win/C#/CLI/Jobs/Encode.cs @@ -0,0 +1,15 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Handbrake.CLI.Jobs
+{
+ public class Encode
+ {
+ public override string ToString()
+ {
+ // TODO: generate param string to be used with hbcli
+ return base.ToString();
+ }
+ }
+}
diff --git a/win/C#/CLI/Jobs/Job.cs b/win/C#/CLI/Jobs/Job.cs new file mode 100644 index 000000000..f1c02c352 --- /dev/null +++ b/win/C#/CLI/Jobs/Job.cs @@ -0,0 +1,28 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Diagnostics;
+
+namespace Handbrake.CLI.Jobs
+{
+ public class Job
+ {
+ private string m_exec;
+
+ private Process m_proc;
+ /// <summary>
+ /// The base process associated with this job
+ /// </summary>
+ public Process Process
+ {
+ get
+ {
+ return this.m_proc;
+ }
+ }
+
+ public Job()
+ {
+ }
+ }
+}
diff --git a/win/C#/CLI/Jobs/ParseDVD.cs b/win/C#/CLI/Jobs/ParseDVD.cs new file mode 100644 index 000000000..d902fc35c --- /dev/null +++ b/win/C#/CLI/Jobs/ParseDVD.cs @@ -0,0 +1,15 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Handbrake.CLI.Jobs
+{
+ public class ParseDVD
+ {
+ public override string ToString()
+ {
+ // TODO: generate param string to be used with hbcli
+ return base.ToString();
+ }
+ }
+}
diff --git a/win/C#/CLI/Manager.cs b/win/C#/CLI/Manager.cs index ac20609a3..d6627ba8a 100644 --- a/win/C#/CLI/Manager.cs +++ b/win/C#/CLI/Manager.cs @@ -6,15 +6,96 @@ using System.Diagnostics; namespace Handbrake.CLI
{
/// <summary>
+ /// Delegate to handle pointers to event subscriptions regarding CLI jobs
+ /// </summary>
+ /// <param name="Sender">The object which raised the event using this delegate</param>
+ /// <param name="Job">The job which caused this delegate to fire</param>
+ public delegate void JobStatusHandler(Jobs.Job Job);
+
+ /// <summary>
/// still workin on this
/// </summary>
class Manager
{
private static Queue<Process> m_processQueue = new Queue<Process>();
- public static void Enqueue(object s)
+ /// <summary>
+ /// Raised upon a job being completed
+ /// </summary>
+ public static event JobStatusHandler OnJobCompleted;
+
+ /// <summary>
+ /// Raised upon a new job starting
+ /// </summary>
+ public static event JobStatusHandler OnJobStarted;
+
+ /// <summary>
+ /// Raised upon any noteable progress during a job
+ /// </summary>
+ public static event JobStatusHandler OnJobProgress;
+
+ /// <summary>
+ /// Used for queueing up a job to be processed later
+ /// </summary>
+ /// <param name="job">The job to be processed later</param>
+ public static void EnqueueJob(Jobs.Job job)
{
//TODO: create new Process object from passed
+ m_processQueue.Enqueue(CreateProcess(job));
+ }
+
+ /// <summary>
+ /// Starts the job queue
+ /// </summary>
+ public static void StartJobs()
+ {
+ while (m_processQueue.Count > 0)
+ {
+ Process proc = m_processQueue.Dequeue();
+ proc.Start();
+ proc.Close();
+ }
+ }
+
+ /// <summary>
+ /// Creates a new Process object from a Job object
+ /// </summary>
+ /// <param name="job">The Job object to create a process from</param>
+ /// <returns>A Process object based on the requirements of the Job passed</returns>
+ private static Process CreateProcess(Jobs.Job job)
+ {
+ Process hbProc = new Process();
+ hbProc.StartInfo.FileName = "hbcli.exe";
+ hbProc.StartInfo.Arguments = job.ToString();
+ hbProc.StartInfo.RedirectStandardOutput = true;
+ hbProc.StartInfo.RedirectStandardError = true;
+ hbProc.StartInfo.UseShellExecute = false;
+ hbProc.StartInfo.CreateNoWindow = true;
+
+ // Set the process Priority
+ switch (Properties.Settings.Default.processPriority)
+ {
+ case "Realtime":
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;
+ break;
+ case "High":
+ hbProc.PriorityClass = ProcessPriorityClass.High;
+ break;
+ case "Above Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
+ break;
+ case "Normal":
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;
+ break;
+ case "Low":
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;
+ break;
+ default:
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
+ break;
+ }
+
+ return hbProc;
}
}
}
diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index ebc5bfe41..c9b1bac81 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -37,6 +37,9 @@ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="CLI\Jobs\Encode.cs" />
+ <Compile Include="CLI\Jobs\Job.cs" />
+ <Compile Include="CLI\Jobs\ParseDVD.cs" />
<Compile Include="CLI\Manager.cs" />
<Compile Include="frmAbout.cs">
<SubType>Form</SubType>
diff --git a/win/C#/frmAbout.Designer.cs b/win/C#/frmAbout.Designer.cs index 6bbf4e68f..e0123aeb4 100644 --- a/win/C#/frmAbout.Designer.cs +++ b/win/C#/frmAbout.Designer.cs @@ -132,7 +132,6 @@ namespace Handbrake this.Name = "frmAbout";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "About Handbrake";
- this.Load += new System.EventHandler(this.About_Load);
((System.ComponentModel.ISupportInitialize)(this.PictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
diff --git a/win/C#/frmAbout.cs b/win/C#/frmAbout.cs index d34ff6567..e27df2a3b 100644 --- a/win/C#/frmAbout.cs +++ b/win/C#/frmAbout.cs @@ -13,17 +13,12 @@ namespace Handbrake public frmAbout()
{
InitializeComponent();
+ Version.Text = Properties.Settings.Default.GuiVersion;
}
private void btn_close_Click(object sender, EventArgs e)
{
this.Close();
}
-
-
- private void About_Load(object sender, EventArgs e)
- {
- Version.Text = Properties.Settings.Default.GuiVersion;
- }
}
}
\ No newline at end of file diff --git a/win/C#/frmDvdInfo.cs b/win/C#/frmDvdInfo.cs index 130ffa2f3..7d58cb146 100644 --- a/win/C#/frmDvdInfo.cs +++ b/win/C#/frmDvdInfo.cs @@ -10,19 +10,37 @@ namespace Handbrake {
public partial class frmDvdInfo : Form
{
-
- /*
- * This window should be used to display the RAW output of the handbrake CLI which is produced during the scan.
- */
-
+ /// <summary>
+ /// This window should be used to display the RAW output of the handbrake CLI which is produced during the scan.
+ /// </summary>
public frmDvdInfo()
{
InitializeComponent();
+ Parsing.Parser.OnReadLine += HandleParsedData;
+ Parsing.Parser.OnReadToEnd += HandleParsedData;
+ this.rtf_dvdInfo.Text = string.Empty;
+ }
+
+ private void HandleParsedData(object Sender, string Data)
+ {
+ if (this.InvokeRequired)
+ {
+ this.BeginInvoke(new Parsing.DataReadEventHandler(HandleParsedData), new object[] { Sender, Data });
+ return;
+ }
+ this.rtf_dvdInfo.AppendText(Data + System.Environment.NewLine);
}
private void btn_close_Click(object sender, EventArgs e)
{
this.Close();
}
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ e.Cancel = true;
+ this.Hide();
+ base.OnClosing(e);
+ }
}
}
\ No newline at end of file diff --git a/win/C#/frmOptions.Designer.cs b/win/C#/frmOptions.Designer.cs index 32237e809..eb78a6591 100644 --- a/win/C#/frmOptions.Designer.cs +++ b/win/C#/frmOptions.Designer.cs @@ -258,7 +258,6 @@ namespace Handbrake this.Name = "frmOptions";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Options";
- this.Load += new System.EventHandler(this.frmOptions_Load);
this.GroupBox2.ResumeLayout(false);
this.GroupBox2.PerformLayout();
this.GroupBox3.ResumeLayout(false);
diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index 61fd90bde..fc3d55a0a 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -10,14 +10,12 @@ namespace Handbrake {
public partial class frmOptions : Form
{
+ /// <summary>
+ /// When the form loads, Initialise all the setting components with their correct values
+ /// </summary>
public frmOptions()
{
InitializeComponent();
- }
-
- // When the form loads, Initialise all the setting components with their correct values
- private void frmOptions_Load(object sender, EventArgs e)
- {
if (Properties.Settings.Default.updateStatus == "Checked")
{
check_updateCheck.CheckState = CheckState.Checked;
@@ -42,7 +40,6 @@ namespace Handbrake }
}
-
private void check_updateCheck_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.updateStatus = check_updateCheck.CheckState.ToString();
diff --git a/win/C#/frmReadDVD.Designer.cs b/win/C#/frmReadDVD.Designer.cs index 1cb811133..18bbd36a1 100644 --- a/win/C#/frmReadDVD.Designer.cs +++ b/win/C#/frmReadDVD.Designer.cs @@ -53,12 +53,12 @@ namespace Handbrake this.btn_ok.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_ok.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_ok.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
- this.btn_ok.Location = new System.Drawing.Point(405, 51);
+ this.btn_ok.Location = new System.Drawing.Point(400, 52);
this.btn_ok.Name = "btn_ok";
- this.btn_ok.Size = new System.Drawing.Size(56, 22);
+ this.btn_ok.Size = new System.Drawing.Size(61, 22);
this.btn_ok.TabIndex = 28;
this.btn_ok.TabStop = false;
- this.btn_ok.Text = "Ok";
+ this.btn_ok.Text = "OK";
this.btn_ok.UseVisualStyleBackColor = false;
this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
//
diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index 62a1563cc..2958bdf65 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -18,6 +18,7 @@ namespace Handbrake private frmMain mainWindow;
private frmDvdInfo dvdInfo;
private Parsing.DVD thisDvd;
+ private Process hbProc;
private delegate void UpdateUIHandler();
public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)
@@ -50,10 +51,6 @@ namespace Handbrake mainWindow.drp_dvdtitle.Items.Clear();
mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray());
- // Just a quick test to see if data can be pushed to frmDvdInfo.
- // What needs to happen here is the plaintext outout needs to be sent to the frmDvdInfo.
- dvdInfo.rtf_dvdInfo.Text = thisDvd.ToString();
-
this.Close();
}
@@ -62,10 +59,10 @@ namespace Handbrake string query = "-i " + '"' + inputFile + '"' + " -t0";
Functions.CLI process = new Functions.CLI();
- Process hbProc = process.runCli(this, query, true, true, false, true);
+ hbProc = process.runCli(this, query, true, true, false, true);
Parsing.Parser readData = new Parsing.Parser(hbProc.StandardError.BaseStream);
- hbProc.WaitForExit();
+ //hbProc.WaitForExit();
hbProc.Close();
// Setup the parser
|