diff options
author | sr55 <[email protected]> | 2008-08-24 17:57:54 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-08-24 17:57:54 +0000 |
commit | 163bce7432c717a0d102568a0d582375f507e3f7 (patch) | |
tree | a62dc6dbd0d64b31a79e2630db4133b37885d668 /win/C#/Functions | |
parent | b4553cd70fde71ac12974aa83dec4508f8f690ab (diff) |
WinGui:
- Adds checkbox to enable decomb.
- Program Options updated with an option to customize decomb values.
- Queue Recovery feature. If you close the GUI without letting a queue complete, the user will be prompted if they'd like to recover the queue on next launch.
- Small bugfix with the queue HandBrakeCLI monitor thread not stopping when the GUI is closed.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1653 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions')
-rw-r--r-- | win/C#/Functions/Common.cs | 45 | ||||
-rw-r--r-- | win/C#/Functions/Queue.cs | 54 |
2 files changed, 97 insertions, 2 deletions
diff --git a/win/C#/Functions/Common.cs b/win/C#/Functions/Common.cs index f0cab1cde..7ff2ec806 100644 --- a/win/C#/Functions/Common.cs +++ b/win/C#/Functions/Common.cs @@ -562,7 +562,13 @@ namespace Handbrake.Functions }
if (mainWindow.check_decomb.Checked)
- query += " --decomb ";
+ {
+ string decombValue = Properties.Settings.Default.decomb;
+ if (decombValue != "" && decombValue != Properties.Settings.Default.default_decomb)
+ query += " --decomb=\"" + decombValue + "\"";
+ else
+ query += " --decomb ";
+ }
if (mainWindow.check_grayscale.Checked)
query += " -g ";
@@ -1226,5 +1232,42 @@ namespace Handbrake.Functions }
#endregion
+
+ #region Queue
+ /// <summary>
+ /// Check if the queue recovery file contains records.
+ /// If it does, it means the last queue did not complete before HandBrake closed.
+ /// So, return a boolean if true.
+ /// </summary>
+ public Boolean check_queue_recovery()
+ {
+ try
+ {
+ string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");
+ using (StreamReader reader = new StreamReader(tempPath))
+ {
+ string queue_item = reader.ReadLine();
+ if (queue_item == null)
+ {
+ reader.Close();
+ reader.Dispose();
+ return false;
+ }
+ else // There exists an item in the recovery queue file, so try and recovr it.
+ {
+ reader.Close();
+ reader.Dispose();
+ return true;
+ }
+ }
+ }
+ catch (Exception)
+ {
+ // Keep quiet about the error.
+ return false;
+ }
+ }
+ #endregion
+
}
}
\ No newline at end of file diff --git a/win/C#/Functions/Queue.cs b/win/C#/Functions/Queue.cs index e566c2e08..ad4ecaf44 100644 --- a/win/C#/Functions/Queue.cs +++ b/win/C#/Functions/Queue.cs @@ -2,6 +2,8 @@ using System.Collections.Generic;
using System.Text;
using System.Collections;
+using System.IO;
+using System.Windows.Forms;
namespace Handbrake.Functions
{
@@ -23,7 +25,7 @@ namespace Handbrake.Functions {
string query = queue[0].ToString();
lastQuery = query;
- remove(0);
+ remove(0); // Remove the item which we are about to pass out.
return query;
}
@@ -102,5 +104,55 @@ namespace Handbrake.Functions }
}
+ /// <summary>
+ /// Writes the current queue to disk. hb_queue_recovery.dat
+ /// This function is called after getNextItemForEncoding()
+ /// </summary>
+ public void write2disk()
+ {
+ try
+ {
+ string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");
+ using (StreamWriter writer = new StreamWriter(tempPath))
+ {
+ foreach (string item in queue)
+ {
+ writer.WriteLine(item);
+ }
+ writer.Close();
+ writer.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ // Any Errors will be out of diskspace/permissions problems. Don't report them as they'll annoy the user.
+ }
+ }
+
+ /// <summary>
+ /// Recover the queue from hb_queue_recovery.dat
+ /// </summary>
+ public void recoverQueue()
+ {
+ try
+ {
+ string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat");
+ using (StreamReader reader = new StreamReader(tempPath))
+ {
+ string queue_item = reader.ReadLine();
+
+ while (queue_item != null)
+ {
+ this.add(queue_item);
+ queue_item = reader.ReadLine();
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show("HandBrake was unable to recover the queue. \nError Information:" + exc.ToString(),"Queue Recovery Error",MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
}
}
|