// Startup Functions \r
private void queueRecovery()\r
{\r
- if (Main.CheckQueueRecovery())\r
+ DialogResult result = DialogResult.None;\r
+ List<string> queueFiles = Main.CheckQueueRecovery();\r
+ if (queueFiles.Count == 1)\r
{\r
- DialogResult result =\r
- MessageBox.Show(\r
+ result = MessageBox.Show(\r
"HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",\r
"Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ }\r
+ else if (queueFiles.Count > 1)\r
+ {\r
+ result = MessageBox.Show(\r
+ "HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",\r
+ "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ }\r
\r
- if (result == DialogResult.Yes)\r
- encodeQueue.LoadQueueFromFile("hb_queue_recovery.xml"); // Start Recovery\r
- else\r
+ if (result == DialogResult.Yes)\r
+ {\r
+ foreach (string file in queueFiles)\r
+ {\r
+ encodeQueue.LoadQueueFromFile(file); // Start Recovery\r
+ }\r
+ }\r
+ else\r
+ {\r
+ if (Main.IsMultiInstance) return; // Don't tamper with the files if we are multi instance\r
+\r
+ string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+ foreach (string file in queueFiles)\r
{\r
- // Remove the Queue recovery file if the user doesn't want to recovery the last queue.\r
- string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
- if (File.Exists(queuePath))\r
- File.Delete(queuePath);\r
+ if (File.Exists(Path.Combine(tempPath, file)))\r
+ File.Delete(Path.Combine(tempPath, file));\r
}\r
}\r
}\r
\r
private void encodeStarted(object sender, EventArgs e)\r
{\r
- if (Properties.Settings.Default.preventSleep)\r
- {\r
- Win32.PreventSleep();\r
- } \r
SetEncodeStarted();\r
encodeQueue.EncodeStatusChanged += EncodeQueue_EncodeStatusChanged;\r
}\r
\r
private void encodeEnded(object sender, EventArgs e)\r
{\r
- if (Properties.Settings.Default.preventSleep)\r
- {\r
- Win32.AllowSleep();\r
- }\r
encodeQueue.EncodeStatusChanged -= EncodeQueue_EncodeStatusChanged;\r
SetEncodeFinished();\r
}\r
{\r
if (btn_start.Text == "Stop")\r
{\r
- DialogResult result;\r
- if (Properties.Settings.Default.enocdeStatusInGui &&\r
- !Properties.Settings.Default.showCliForInGuiEncodeStatus)\r
- {\r
- result = MessageBox.Show(\r
- "Are you sure you wish to cancel the encode?\n\nPlease note, when 'Enable in-GUI encode status' is enabled, stopping this encode will render the file unplayable. ",\r
- "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
- }\r
- else\r
- {\r
- result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?",\r
- MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
- }\r
+ DialogResult result = !Properties.Settings.Default.showCliForInGuiEncodeStatus\r
+ ? MessageBox.Show(\r
+ "Are you sure you wish to cancel the encode?\n\nPlease note: Stopping this encode will render the file unplayable. ",\r
+ "Cancel Encode?",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Question)\r
+ : MessageBox.Show(\r
+ "Are you sure you wish to cancel the encode?",\r
+ "Cancel Encode?",\r
+ MessageBoxButtons.YesNo,\r
+ MessageBoxIcon.Question);\r
\r
if (result == DialogResult.Yes)\r
{\r
// Pause The Queue\r
encodeQueue.Pause();\r
\r
- if (Settings.Default.enocdeStatusInGui && !Settings.Default.showCliForInGuiEncodeStatus)\r
- {\r
- encodeQueue.Stop();\r
- }\r
- else\r
- {\r
+ if (Settings.Default.showCliForInGuiEncodeStatus)\r
encodeQueue.SafelyClose();\r
- }\r
+ else\r
+ encodeQueue.Stop();\r
}\r
}\r
else\r
}\r
\r
// Try to safely close out if we can, or kill the cli if using in-gui status\r
- if (Settings.Default.enocdeStatusInGui)\r
+ if (!Settings.Default.showCliForInGuiEncodeStatus)\r
encodeQueue.Stop();\r
else\r
encodeQueue.SafelyClose();\r