summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2008-09-14 16:54:19 +0000
committersr55 <[email protected]>2008-09-14 16:54:19 +0000
commitb4e47744bb7cbcfcb3b14cc9b2fbffd1919861d7 (patch)
tree66998e2619aac4d49b2be0cae881faa49f36fd9c
parente407a68f9e6c11f107760a36134aa8dff51a2fcb (diff)
WinGui:
- Delete key can now be used to delete presets & queue items. - Queued items now have job id's. this isn't used for anything yet, however will be useful for editing current queue items. - Moved batch script code to Queue.cs git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1696 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/C#/Functions/Queue.cs67
-rw-r--r--win/C#/frmMain.Designer.cs55
-rw-r--r--win/C#/frmMain.cs17
-rw-r--r--win/C#/frmMain.resx6
-rw-r--r--win/C#/frmQueue.Designer.cs1
-rw-r--r--win/C#/frmQueue.cs86
6 files changed, 144 insertions, 88 deletions
diff --git a/win/C#/Functions/Queue.cs b/win/C#/Functions/Queue.cs
index d6c7978de..28730e099 100644
--- a/win/C#/Functions/Queue.cs
+++ b/win/C#/Functions/Queue.cs
@@ -10,23 +10,24 @@ namespace Handbrake.Functions
public class Queue
{
ArrayList queue = new ArrayList();
- string lastQuery;
+ ArrayList lastQuery;
+ int id = 0; // Unique identifer number for each job
public ArrayList getQueue()
{
- return queue;
+ return queue;
}
/// <summary>
/// Get's the next CLI query for encoding
/// </summary>
/// <returns>String</returns>
- public string getNextItemForEncoding()
+ public String getNextItemForEncoding()
{
- string query = queue[0].ToString();
- lastQuery = query;
+ Object query = queue[0];
+ lastQuery = (ArrayList)query;
remove(0); // Remove the item which we are about to pass out.
- return query;
+ return lastQuery[1].ToString();
}
/// <summary>
@@ -35,7 +36,14 @@ namespace Handbrake.Functions
/// <param name="query">String</param>
public void add(string query)
{
- queue.Add(query);
+ // Creates a new job with a unique identifer and cli query
+ ArrayList newJob = new ArrayList();
+ newJob.Add(id);
+ newJob.Add(query);
+ id++;
+
+ // Adds the job to the queue
+ queue.Add(newJob);
}
/// <summary>
@@ -64,7 +72,7 @@ namespace Handbrake.Functions
/// <returns>String</returns>
public string getLastQuery()
{
- return lastQuery;
+ return lastQuery[1].ToString();
}
/// <summary>
@@ -112,9 +120,9 @@ namespace Handbrake.Functions
tempPath = file;
using (StreamWriter writer = new StreamWriter(tempPath))
{
- foreach (string item in queue)
+ foreach (ArrayList item in queue)
{
- writer.WriteLine(item);
+ writer.WriteLine(item[1].ToString());
}
writer.Close();
writer.Dispose();
@@ -127,6 +135,45 @@ namespace Handbrake.Functions
}
/// <summary>
+ /// Writes the current queue to disk to the location specified in file
+ /// </summary>
+ /// <param name="file"></param>
+ public void writeBatchScript(string file)
+ {
+ string queries = "";
+ foreach (ArrayList queue_item in queue)
+ {
+ string q_item = queue_item[1].ToString();
+ string fullQuery = '"' + Application.StartupPath.ToString() + "\\HandBrakeCLI.exe" + '"' + q_item;
+
+ if (queries == string.Empty)
+ queries = queries + fullQuery;
+ else
+ queries = queries + " && " + fullQuery;
+ }
+ string strCmdLine = queries;
+
+ if (file != "")
+ {
+ try
+ {
+ // Create a StreamWriter and open the file, Write the batch file query to the file and
+ // Close the stream
+ StreamWriter line = new StreamWriter(file);
+ line.WriteLine(strCmdLine);
+ line.Close();
+
+ MessageBox.Show("Your batch script has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
+ }
+ catch (Exception)
+ {
+ MessageBox.Show("Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
+ }
+
+ }
+ }
+
+ /// <summary>
/// Recover the queue from hb_queue_recovery.dat
/// </summary>
public void recoverQueue(string file)
diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs
index a70386b04..1fef2e7c2 100644
--- a/win/C#/frmMain.Designer.cs
+++ b/win/C#/frmMain.Designer.cs
@@ -38,7 +38,7 @@ namespace Handbrake
System.Windows.Forms.Label Label38;
System.Windows.Forms.ContextMenuStrip notifyIconMenu;
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
this.btn_restore = new System.Windows.Forms.ToolStripMenuItem();
this.DVD_Save = new System.Windows.Forms.SaveFileDialog();
this.File_Save = new System.Windows.Forms.SaveFileDialog();
@@ -82,11 +82,11 @@ namespace Handbrake
this.drp_audbit_4 = new System.Windows.Forms.ComboBox();
this.drp_audenc_4 = new System.Windows.Forms.ComboBox();
this.drp_audmix_4 = new System.Windows.Forms.ComboBox();
- this.label7 = new System.Windows.Forms.Label();
this.lbl_src_res = new System.Windows.Forms.Label();
this.lbl_duration = new System.Windows.Forms.Label();
this.label_duration = new System.Windows.Forms.Label();
this.drop_format = new System.Windows.Forms.ComboBox();
+ this.label7 = new System.Windows.Forms.Label();
this.DVD_Open = new System.Windows.Forms.FolderBrowserDialog();
this.File_Open = new System.Windows.Forms.OpenFileDialog();
this.ISO_Open = new System.Windows.Forms.OpenFileDialog();
@@ -165,9 +165,9 @@ namespace Handbrake
this.Label46 = new System.Windows.Forms.Label();
this.Label40 = new System.Windows.Forms.Label();
this.TabPage1 = new System.Windows.Forms.TabPage();
+ this.slider_deblock = new System.Windows.Forms.TrackBar();
this.label8 = new System.Windows.Forms.Label();
this.lbl_deblockVal = new System.Windows.Forms.Label();
- this.slider_deblock = new System.Windows.Forms.TrackBar();
this.check_customCrop = new System.Windows.Forms.RadioButton();
this.check_autoCrop = new System.Windows.Forms.RadioButton();
this.check_decomb = new System.Windows.Forms.CheckBox();
@@ -646,9 +646,9 @@ namespace Handbrake
//
// number
//
- dataGridViewCellStyle1.Format = "N0";
- dataGridViewCellStyle1.NullValue = null;
- this.number.DefaultCellStyle = dataGridViewCellStyle1;
+ dataGridViewCellStyle2.Format = "N0";
+ dataGridViewCellStyle2.NullValue = null;
+ this.number.DefaultCellStyle = dataGridViewCellStyle2;
this.number.HeaderText = "Chapter Number";
this.number.MaxInputLength = 3;
this.number.Name = "number";
@@ -945,16 +945,6 @@ namespace Handbrake
this.ToolTip.SetToolTip(this.drp_audmix_4, "Please note: Some options require a 5.1 audio channel to be selected");
this.drp_audmix_4.SelectedIndexChanged += new System.EventHandler(this.drp_audmix_4_SelectedIndexChanged);
//
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.BackColor = System.Drawing.Color.Transparent;
- this.label7.Location = new System.Drawing.Point(311, 34);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(52, 13);
- this.label7.TabIndex = 12;
- this.label7.Text = "Source:";
- //
// lbl_src_res
//
this.lbl_src_res.AutoSize = true;
@@ -1009,6 +999,16 @@ namespace Handbrake
this.ToolTip.SetToolTip(this.drop_format, "Select a video encoder");
this.drop_format.SelectedIndexChanged += new System.EventHandler(this.drop_format_SelectedIndexChanged);
//
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.BackColor = System.Drawing.Color.Transparent;
+ this.label7.Location = new System.Drawing.Point(311, 34);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(52, 13);
+ this.label7.TabIndex = 12;
+ this.label7.Text = "Source:";
+ //
// DVD_Open
//
this.DVD_Open.Description = "Select the \"VIDEO_TS\" folder from your DVD Drive.";
@@ -1893,6 +1893,15 @@ namespace Handbrake
this.TabPage1.TabIndex = 0;
this.TabPage1.Text = "Picture Settings";
//
+ // slider_deblock
+ //
+ this.slider_deblock.Location = new System.Drawing.Point(406, 201);
+ this.slider_deblock.Maximum = 15;
+ this.slider_deblock.Name = "slider_deblock";
+ this.slider_deblock.Size = new System.Drawing.Size(174, 42);
+ this.slider_deblock.TabIndex = 35;
+ this.slider_deblock.Scroll += new System.EventHandler(this.slider_deblock_Scroll);
+ //
// label8
//
this.label8.AutoSize = true;
@@ -1915,15 +1924,6 @@ namespace Handbrake
this.lbl_deblockVal.TabIndex = 36;
this.lbl_deblockVal.Text = "0";
//
- // slider_deblock
- //
- this.slider_deblock.Location = new System.Drawing.Point(406, 201);
- this.slider_deblock.Maximum = 15;
- this.slider_deblock.Name = "slider_deblock";
- this.slider_deblock.Size = new System.Drawing.Size(174, 42);
- this.slider_deblock.TabIndex = 35;
- this.slider_deblock.Scroll += new System.EventHandler(this.slider_deblock_Scroll);
- //
// check_customCrop
//
this.check_customCrop.AutoSize = true;
@@ -3004,16 +3004,17 @@ namespace Handbrake
//
// treeView_presets
//
- this.treeView_presets.ForeColor = System.Drawing.Color.Navy;
+ this.treeView_presets.ForeColor = System.Drawing.Color.DarkBlue;
this.treeView_presets.FullRowSelect = true;
this.treeView_presets.HideSelection = false;
- this.treeView_presets.ItemHeight = 17;
+ this.treeView_presets.ItemHeight = 21;
this.treeView_presets.Location = new System.Drawing.Point(10, 23);
this.treeView_presets.Name = "treeView_presets";
this.treeView_presets.ShowLines = false;
this.treeView_presets.Size = new System.Drawing.Size(177, 473);
this.treeView_presets.TabIndex = 0;
this.treeView_presets.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_presets_AfterSelect);
+ this.treeView_presets.KeyUp += new System.Windows.Forms.KeyEventHandler(this.treeView_presets_deleteKey);
//
// toolStrip1
//
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 5d8886746..3664b319e 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -173,8 +173,7 @@ namespace Handbrake
{
if (hb_common_func.check_queue_recovery() == true)
{
- DialogResult result;
- result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ DialogResult result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
encodeQueue.recoverQueue("hb_queue_recovery.dat"); // Start Recovery
@@ -1395,6 +1394,20 @@ namespace Handbrake
x264PanelFunctions.X264_StandardizeOptString(this);
x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);
}
+ private void treeView_presets_deleteKey(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Delete)
+ {
+ DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ if (result == DialogResult.Yes)
+ {
+ if (treeView_presets.SelectedNode != null)
+ presetHandler.remove(treeView_presets.SelectedNode.Text);
+ // Now reload the preset panel
+ loadPresetPanel();
+ }
+ }
+ }
#endregion
diff --git a/win/C#/frmMain.resx b/win/C#/frmMain.resx
index 1b5323eb3..d0c9f18a9 100644
--- a/win/C#/frmMain.resx
+++ b/win/C#/frmMain.resx
@@ -155,6 +155,12 @@ Make sure you have selected a "Title" from the "Source" box above otherwise
the list will not be populated with the correct amount of chapters.
Note: Do not change any of the chapter numbers!</value>
</data>
+ <metadata name="number.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
+ <metadata name="name.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>True</value>
+ </metadata>
<metadata name="DVD_Open.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>223, 15</value>
</metadata>
diff --git a/win/C#/frmQueue.Designer.cs b/win/C#/frmQueue.Designer.cs
index a02794142..750098e04 100644
--- a/win/C#/frmQueue.Designer.cs
+++ b/win/C#/frmQueue.Designer.cs
@@ -311,6 +311,7 @@ namespace Handbrake
this.list_queue.TabIndex = 72;
this.list_queue.UseCompatibleStateImageBehavior = false;
this.list_queue.View = System.Windows.Forms.View.Details;
+ this.list_queue.KeyUp += new System.Windows.Forms.KeyEventHandler(this.list_queue_deleteKey);
//
// Title
//
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs
index 670153c96..7c52305a8 100644
--- a/win/C#/frmQueue.cs
+++ b/win/C#/frmQueue.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
+using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
@@ -58,9 +59,10 @@ namespace Handbrake
private void redrawQueue()
{
list_queue.Items.Clear();
- foreach (string queue_item in queue.getQueue())
+ foreach (ArrayList queue_item in queue.getQueue())
{
- Functions.QueryParser parsed = Functions.QueryParser.Parse(queue_item);
+ string q_item = queue_item[1].ToString();
+ Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item);
// Get the DVD Title
string title = "";
@@ -306,59 +308,16 @@ namespace Handbrake
}
}
-
- // Hide's the window from the users view.
- private void btn_Close_Click(object sender, EventArgs e)
- {
- this.Hide();
- }
-
- // Hide's the window when the user tries to "x" out of the window instead of closing it.
- protected override void OnClosing(CancelEventArgs e)
- {
- e.Cancel = true;
- this.Hide();
- base.OnClosing(e);
- }
-
+ // Generate a Saveable batch script on the users request
private void mnu_batch_Click(object sender, EventArgs e)
{
- string queries = "";
- foreach (string query_item in queue.getQueue())
- {
- string fullQuery = '"' + Application.StartupPath.ToString() + "\\HandBrakeCLI.exe" + '"' + query_item;
-
- if (queries == string.Empty)
- queries = queries + fullQuery;
- else
- queries = queries + " && " + fullQuery;
- }
- string strCmdLine = queries;
-
SaveFile.Filter = "Batch|.bat";
SaveFile.ShowDialog();
- string filename = SaveFile.FileName;
-
- if (filename != "")
- {
- try
- {
- // Create a StreamWriter and open the file, Write the batch file query to the file and
- // Close the stream
- StreamWriter line = new StreamWriter(filename);
- line.WriteLine(strCmdLine);
- line.Close();
-
- MessageBox.Show("Your batch script has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception)
- {
- MessageBox.Show("Unable to write to the file. Please make sure that the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
- }
-
- }
+ if (SaveFile.FileName != String.Empty)
+ queue.writeBatchScript(SaveFile.FileName);
}
+ // Export the HandBrake Queue to a file.
private void mnu_export_Click(object sender, EventArgs e)
{
SaveFile.Filter = "HandBrake Queue|*.queue";
@@ -367,6 +326,7 @@ namespace Handbrake
queue.write2disk(SaveFile.FileName);
}
+ // Import an exported queue
private void mnu_import_Click(object sender, EventArgs e)
{
OpenFile.ShowDialog();
@@ -375,6 +335,34 @@ namespace Handbrake
redrawQueue();
}
+ // Delete a selected item on the queue, if the delete key is pressed.
+ private void list_queue_deleteKey(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Delete)
+ {
+ if (list_queue.SelectedIndices.Count != 0)
+ {
+ queue.remove(list_queue.SelectedIndices[0]);
+ queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file
+ redrawQueue();
+ }
+ }
+ }
+
+ // Hide's the window from the users view.
+ private void btn_Close_Click(object sender, EventArgs e)
+ {
+ this.Hide();
+ }
+
+ // Hide's the window when the user tries to "x" out of the window instead of closing it.
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ e.Cancel = true;
+ this.Hide();
+ base.OnClosing(e);
+ }
+
}
} \ No newline at end of file