From b023bb532c17e1284230172b660baa32b5750318 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 14 Jun 2009 13:31:24 +0000 Subject: [PATCH] WinGui: - Small tweaks to Encode.cs - write2disk queue recovery feature is now completely handled in QueueHandler - Auto naming is on by default. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2533 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/EncodeQueue/Encode.cs | 7 ++++--- win/C#/EncodeQueue/QueueHandler.cs | 24 +++++++++++++----------- win/C#/Properties/Settings.Designer.cs | 6 +++--- win/C#/Properties/Settings.settings | 4 ++-- win/C#/app.config | 4 ++-- win/C#/frmMain.cs | 26 ++++++++++---------------- win/C#/frmQueue.cs | 6 +----- 7 files changed, 35 insertions(+), 42 deletions(-) diff --git a/win/C#/EncodeQueue/Encode.cs b/win/C#/EncodeQueue/Encode.cs index c0e0b7c3e..80125fc30 100644 --- a/win/C#/EncodeQueue/Encode.cs +++ b/win/C#/EncodeQueue/Encode.cs @@ -33,7 +33,7 @@ namespace Handbrake.EncodeQueue { cliStart.RedirectStandardOutput = true; cliStart.UseShellExecute = false; - + } if (Properties.Settings.Default.cli_minimized == "Checked") cliStart.WindowStyle = ProcessWindowStyle.Minimized; @@ -43,7 +43,8 @@ namespace Handbrake.EncodeQueue currentEncode.processID = Main.getCliProcess(before); currentEncode.isEncoding = true; currentEncode.currentQuery = query; - currentEncode.processHandle = (int)currentEncode.hbProcProcess.MainWindowHandle; // Set the process Handle + if (currentEncode.hbProcProcess != null) + currentEncode.processHandle = (int)currentEncode.hbProcProcess.MainWindowHandle; // Set the process Handle // Set the process Priority Process hbCliProcess = null; @@ -75,7 +76,7 @@ namespace Handbrake.EncodeQueue } catch (Exception exc) { - MessageBox.Show("An error occured in runCli()\n Error Information: \n\n" + exc); + MessageBox.Show("It would appear that HandBrakeCLI has not started correctly. You should take a look at the Activity log as it may indicate the reason why.\n\n Detailed Error Information: error occured in runCli()\n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return currentEncode; diff --git a/win/C#/EncodeQueue/QueueHandler.cs b/win/C#/EncodeQueue/QueueHandler.cs index d16f10ffb..68cfe306a 100644 --- a/win/C#/EncodeQueue/QueueHandler.cs +++ b/win/C#/EncodeQueue/QueueHandler.cs @@ -36,6 +36,9 @@ namespace Handbrake.EncodeQueue String query = job.Query; lastQueueItem = job; remove(0); // Remove the item which we are about to pass out. + + updateQueueRecoveryFile("hb_queue_recovery.xml"); + return query; } @@ -57,6 +60,7 @@ namespace Handbrake.EncodeQueue id++; queue.Add(newJob); + updateQueueRecoveryFile("hb_queue_recovery.xml"); } /// @@ -82,6 +86,7 @@ namespace Handbrake.EncodeQueue public void remove(int index) { queue.RemoveAt(index); + updateQueueRecoveryFile("hb_queue_recovery.xml"); } /// @@ -106,6 +111,7 @@ namespace Handbrake.EncodeQueue queue.RemoveAt(index); queue.Insert((index - 1), item); } + updateQueueRecoveryFile("hb_queue_recovery.xml"); // Update the queue recovery file } /// @@ -121,13 +127,14 @@ namespace Handbrake.EncodeQueue queue.RemoveAt(index); queue.Insert((index + 1), item); } + updateQueueRecoveryFile("hb_queue_recovery.xml"); // Update the queue recovery file } /// /// Writes the current queue to disk. hb_queue_recovery.xml /// This function is called after getNextItemForEncoding() /// - public void write2disk(string file) + public void updateQueueRecoveryFile(string file) { string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file; @@ -191,11 +198,7 @@ namespace Handbrake.EncodeQueue /// public void recoverQueue(string file) { - string tempPath; - if (file == "hb_queue_recovery.xml") - tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml"); - else - tempPath = file; + string tempPath = file == "hb_queue_recovery.xml" ? Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml") : file; if (File.Exists(tempPath)) { @@ -210,7 +213,7 @@ namespace Handbrake.EncodeQueue queue.Add(item); if (file != "hb_queue_recovery.xml") - write2disk("hb_queue_recovery.xml"); + updateQueueRecoveryFile("hb_queue_recovery.xml"); } } } @@ -226,7 +229,6 @@ namespace Handbrake.EncodeQueue public void startEncode() { - Thread theQueue; if (this.count() != 0) { if (isPaused) @@ -236,7 +238,7 @@ namespace Handbrake.EncodeQueue isPaused = false; try { - theQueue = new Thread(startProc) { IsBackground = true }; + Thread theQueue = new Thread(startProcess) { IsBackground = true }; theQueue.Start(); } catch (Exception exc) @@ -256,7 +258,7 @@ namespace Handbrake.EncodeQueue encodeHandler.closeCLI(encodeProcess); } - private void startProc(object state) + private void startProcess(object state) { try { @@ -264,7 +266,7 @@ namespace Handbrake.EncodeQueue while (this.count() != 0) { string query = getNextItemForEncoding(); - write2disk("hb_queue_recovery.xml"); // Update the queue recovery file + updateQueueRecoveryFile("hb_queue_recovery.xml"); // Update the queue recovery file encodeProcess = encodeHandler.runCli(query); EncodeStarted(null); diff --git a/win/C#/Properties/Settings.Designer.cs b/win/C#/Properties/Settings.Designer.cs index f4cb2bd33..d03a34de7 100644 --- a/win/C#/Properties/Settings.Designer.cs +++ b/win/C#/Properties/Settings.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3053 +// Runtime Version:2.0.50727.3082 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -145,7 +145,7 @@ namespace Handbrake.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("")] + [global::System.Configuration.DefaultSettingValueAttribute("Checked")] public string autoNaming { get { return ((string)(this["autoNaming"])); @@ -229,7 +229,7 @@ namespace Handbrake.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("{source}-{title}-{chapters}")] + [global::System.Configuration.DefaultSettingValueAttribute("{source}-{title}")] public string autoNameFormat { get { return ((string)(this["autoNameFormat"])); diff --git a/win/C#/Properties/Settings.settings b/win/C#/Properties/Settings.settings index 6a94bff03..d8d2a1c6f 100644 --- a/win/C#/Properties/Settings.settings +++ b/win/C#/Properties/Settings.settings @@ -33,7 +33,7 @@ 0 - + Checked @@ -54,7 +54,7 @@ - {source}-{title}-{chapters} + {source}-{title} diff --git a/win/C#/app.config b/win/C#/app.config index d4c74e98a..344c8dd04 100644 --- a/win/C#/app.config +++ b/win/C#/app.config @@ -38,7 +38,7 @@ 0 - + Checked @@ -59,7 +59,7 @@ - {source}-{title}-{chapters} + {source}-{title} diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index b74499ef3..bad59d7b8 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -26,8 +26,8 @@ namespace Handbrake QueryGenerator queryGen = new QueryGenerator(); // Globals: Mainly used for tracking. ********************************* - Title selectedTitle; - DVD thisDVD; + private Title selectedTitle; + private DVD thisDVD; private frmQueue queueWindow; private frmPreview qtpreview; private Form splash; @@ -215,9 +215,8 @@ namespace Handbrake // Experimental HBProc Process Monitoring. if (Properties.Settings.Default.enocdeStatusInGui == "Checked") { - HBProcess = encodeQueue.encodeProcess.hbProcProcess; - Thread EncodeMon = new Thread(encodeMonitorThread); - EncodeMon.Start(); + Thread encodeMon = new Thread(encodeMonitorThread); + encodeMon.Start(); } } private void encodeEnded(object sender, EventArgs e) @@ -544,10 +543,8 @@ namespace Handbrake String query = rtf_query.Text != "" ? rtf_query.Text : queryGen.generateTheQuery(this); if (encodeQueue.count() == 0) - { encodeQueue.add(query, text_source.Text, text_destination.Text); - encodeQueue.write2disk("hb_queue_recovery.xml"); - } + queueWindow.setQueue(); if (encodeQueue.count() > 1) queueWindow.Show(false); @@ -582,7 +579,6 @@ namespace Handbrake else encodeQueue.add(query, text_source.Text, text_destination.Text); - encodeQueue.write2disk("hb_queue_recovery.xml"); // Writes the queue to the recovery file, just incase the GUI crashes. queueWindow.Show(); } } @@ -1560,14 +1556,13 @@ namespace Handbrake #endregion #region In-GUI Encode Status (Experimental) - private Process HBProcess { get; set; } - + private void encodeMonitorThread() { try { - Parser encode = new Parser(HBProcess.StandardOutput.BaseStream); - encode.OnEncodeProgress += encode_OnEncodeProgress; + Parser encode = new Parser(encodeQueue.encodeProcess.hbProcProcess.StandardOutput.BaseStream); + encode.OnEncodeProgress += encodeOnEncodeProgress; while (!encode.EndOfStream) { encode.readEncodeStatus(); @@ -1578,12 +1573,11 @@ namespace Handbrake MessageBox.Show(exc.ToString()); } } - - private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining) + private void encodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining) { if (this.InvokeRequired) { - this.BeginInvoke(new EncodeProgressEventHandler(encode_OnEncodeProgress), + this.BeginInvoke(new EncodeProgressEventHandler(encodeOnEncodeProgress), new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining }); return; } diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index 88da988ba..1672ae3f5 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -255,7 +255,6 @@ namespace Handbrake foreach (int selectedIndex in selectedIndices) queue.remove(selectedIndex); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file updateUIElements(); // Select the item where the first deleted item was previously @@ -310,7 +309,6 @@ namespace Handbrake foreach (int selectedIndex in selectedIndices) queue.moveUp(selectedIndex); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file updateUIElements(); // Keep the selected item(s) selected, now moved up one index @@ -339,7 +337,6 @@ namespace Handbrake foreach (int selectedIndex in selectedIndices) queue.moveDown(selectedIndex); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file updateUIElements(); // Keep the selected item(s) selected, now moved down one index @@ -366,7 +363,7 @@ namespace Handbrake SaveFile.Filter = "HandBrake Queue|*.queue"; SaveFile.ShowDialog(); if (SaveFile.FileName != String.Empty) - queue.write2disk(SaveFile.FileName); + queue.updateQueueRecoveryFile(SaveFile.FileName); } private void mnu_import_Click(object sender, EventArgs e) { @@ -381,7 +378,6 @@ namespace Handbrake if (queue.lastQueueItem != null) { queue.add(queue.lastQueueItem.Query, queue.lastQueueItem.Source, queue.lastQueueItem.Destination); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file updateUIElements(); } } -- 2.40.0