summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions/Queue.cs
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 /win/C#/Functions/Queue.cs
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
Diffstat (limited to 'win/C#/Functions/Queue.cs')
-rw-r--r--win/C#/Functions/Queue.cs67
1 files changed, 57 insertions, 10 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)