using System.Net;\r
using System.IO;\r
using System.Diagnostics;\r
+using System.Threading;\r
\r
namespace Handbrake\r
{\r
// TOOLS MENU --------------------------------------------------------------\r
private void mnu_encode_Click(object sender, EventArgs e)\r
{\r
- //Queue.ShowDialog();\r
+ showQueue();\r
}\r
\r
private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
QueryEditorText.Text = "";\r
}\r
\r
-\r
- \r
- \r
private frmQueue queueWindow = (frmQueue)new frmQueue();\r
private void btn_queue_Click(object sender, EventArgs e)\r
{\r
queueWindow.Show();\r
}\r
\r
+ private void showQueue()\r
+ {\r
+ queueWindow.Show();\r
+ }\r
+\r
private void btn_encode_Click(object sender, EventArgs e)\r
{\r
String query = "";\r
hbProc.StartInfo.Arguments = query;\r
hbProc.StartInfo.UseShellExecute = false;\r
hbProc.Start();\r
+\r
+ // Set the process Priority\r
+ string priority = Properties.Settings.Default.processPriority;\r
+ switch (priority)\r
+ {\r
+ case "Realtime":\r
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
+ break;\r
+ case "High":\r
+ hbProc.PriorityClass = ProcessPriorityClass.High;\r
+ break;\r
+ case "Above Normal":\r
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+ break;\r
+ case "Normal":\r
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
+ break;\r
+ case "Low":\r
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
+ break;\r
+ default:\r
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+ break;\r
+ }\r
\r
+ //hbProc.WaitForExit;\r
+ //hbProc.Close;\r
+ ThreadPool.QueueUserWorkItem(procMonitor);\r
+ \r
\r
- MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ \r
\r
// TODO: Need to write a bit of code here to do process monitoring.\r
// Note: hbProc.waitForExit will freeze the app, meaning one cannot add additional items to the queue during an encode.\r
}\r
\r
+ private void procMonitor(object state)\r
+ {\r
+ MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
+ }\r
+\r
+\r
+\r
+\r
// -------------------------------------------------------------- \r
// Items that require actions on frmMain\r
// --------------------------------------------------------------\r
int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
int chapterStart = int.Parse(drop_chapterStart.Text);\r
\r
- if (chapterFinish > chapterStart)\r
+ if (chapterFinish < chapterStart)\r
{\r
MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
}\r
}\r
}\r
\r
+ // There is a bug here *******************************************************************\r
if (!lbl_Aspect.Text.Equals("Select a Title")){\r
int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);\r
+ MessageBox.Show("test");\r
int mod16 = height % 16;\r
height = height - mod16;\r
text_height.Text = height.ToString();\r
}\r
\r
} catch(Exception){\r
- \r
+ // No need to alert the user if there is a problem here.\r
}\r
}\r
\r
// Reset some values on the form\r
lbl_Aspect.Text = "Select a Title";\r
lbl_RecomendedCrop.Text = "Select a Title";\r
+ drop_chapterStart.Items.Clear();\r
+ drop_chapterFinish.Items.Clear();\r
QueryEditorText.Text = "";\r
\r
// If the dropdown is set to automatic nothing else needs to be done.\r
{\r
lbl_Aspect.Text = thisDVD.Titles[counter].AspectRatio.ToString();\r
lbl_RecomendedCrop.Text = thisDVD.Titles[counter].AutoCropDimensions[0] + "/" + thisDVD.Titles[counter].AutoCropDimensions[1] + "/" + thisDVD.Titles[counter].AutoCropDimensions[2] + "/" + thisDVD.Titles[counter].AutoCropDimensions[3];\r
+\r
+ // Chapter Dropdown Menus\r
+ int chapterCount = thisDVD.Titles[counter].Chapters.Count;\r
+ int loopCouter = 1;\r
+ while (loopCouter <= chapterCount) \r
+ {\r
+ drop_chapterStart.Items.Add(loopCouter);\r
+ drop_chapterFinish.Items.Add(loopCouter);\r
+\r
+ drop_chapterStart.Text = "1";\r
+ drop_chapterFinish.Text = loopCouter.ToString();\r
+ loopCouter++;\r
+ }\r
+\r
+ // Audio Drop down Menu.\r
+ //thisDVD.Titles[counter].AudioTracks[0].ToString()\r
+\r
+ // Subtitle Dropdown Menu.\r
+\r
// Still need to set these up.\r
- MessageBox.Show(thisDVD.Titles[counter].AudioTracks[0].ToString());\r
- MessageBox.Show(thisDVD.Titles[counter].Chapters.ToString());\r
- MessageBox.Show(thisDVD.Titles[counter].Subtitles.ToString());\r
+ //thisDVD.Titles[counter].Subtitles.ToString()\r
+ \r
}\r
counter++;\r
}\r
hbProc.StartInfo.Arguments = query;\r
hbProc.StartInfo.UseShellExecute = false;\r
hbProc.Start();\r
+ // Set the process Priority\r
+ string priority = Properties.Settings.Default.processPriority;\r
+ switch (priority)\r
+ {\r
+ case "Realtime":\r
+ hbProc.PriorityClass = ProcessPriorityClass.RealTime;\r
+ break;\r
+ case "High":\r
+ hbProc.PriorityClass = ProcessPriorityClass.High;\r
+ break;\r
+ case "Above Normal":\r
+ hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;\r
+ break;\r
+ case "Normal":\r
+ hbProc.PriorityClass = ProcessPriorityClass.Normal;\r
+ break;\r
+ case "Low":\r
+ hbProc.PriorityClass = ProcessPriorityClass.Idle;\r
+ break;\r
+ default:\r
+ hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;\r
+ break;\r
+ }\r
+\r
hbProc.WaitForExit();\r
hbProc.Close();\r
counter++;\r
\r
private void updateUIElements(int progressSplit)\r
{\r
- // This needs to be written so there is no cross-thread problems\r
+ // This needs to be written so there is no cross-thread problems ********************\r
thisWindow.list_queue.Items.Remove(0);\r
progressBar.Value = progressBar.Value + progressSplit;\r
progressBar.Update();\r