using System.Threading;\r
using Handbrake.EncodeQueue;\r
using Handbrake.Functions;\r
+using Handbrake.Model;\r
using Handbrake.Presets;\r
using Handbrake.Parsing;\r
\r
public partial class frmMain : Form\r
{\r
// Objects which may be used by one or more other objects *************\r
- EncodeAndQueueHandler encodeQueue = new EncodeAndQueueHandler();\r
+ Queue encodeQueue = new Queue();\r
PresetsHandler presetHandler = new PresetsHandler();\r
- QueryGenerator queryGen = new QueryGenerator();\r
\r
// Globals: Mainly used for tracking. *********************************\r
public Title selectedTitle;\r
private SourceType selectedSourceType;\r
private string dvdDrivePath;\r
private string dvdDriveLabel;\r
+ private Preset CurrentlySelectedPreset;\r
+ private DVD currentSource;\r
\r
// Delegates **********************************************************\r
private delegate void UpdateWindowHandler();\r
// Update the users config file with the CLI version data.\r
lblStatus.Text = "Setting Version Data ...";\r
Application.DoEvents();\r
- Main.setCliVersionData();\r
+ Main.SetCliVersionData();\r
\r
// Show the form, but leave disabled until preloading is complete then show the main form\r
this.Enabled = false;\r
}\r
}\r
\r
+ // Clear the log files in the background\r
+ if (Properties.Settings.Default.clearOldLogs)\r
+ {\r
+ lblStatus.Text = "Clearing Old Log Files ...";\r
+ Application.DoEvents();\r
+ Thread clearLog = new Thread(Main.ClearOldLogs);\r
+ clearLog.Start();\r
+ }\r
+\r
// Setup the GUI components\r
lblStatus.Text = "Setting up the GUI ...";\r
Application.DoEvents();\r
- loadPresetPanel(); // Load the Preset Panel\r
+ LoadPresetPanel(); // Load the Preset Panel\r
treeView_presets.ExpandAll();\r
lbl_encode.Text = "";\r
drop_mode.SelectedIndex = 0;\r
- queueWindow = new frmQueue(encodeQueue); // Prepare the Queue\r
+ queueWindow = new frmQueue(encodeQueue, this); // Prepare the Queue\r
if (!Properties.Settings.Default.QueryEditorTab)\r
tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled.\r
\r
\r
if (query != null)\r
{\r
- //Ok, Reset all the H264 widgets before changing the preset\r
- x264Panel.reset2Defaults();\r
+ x264Panel.Reset2Defaults();\r
\r
- // Send the query from the file to the Query Parser class, then load the preset\r
QueryParser presetQuery = QueryParser.Parse(query);\r
- PresetLoader.presetLoader(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);\r
+ PresetLoader.LoadPreset(this, presetQuery, Properties.Settings.Default.defaultPreset, loadPictureSettings);\r
\r
- // The x264 widgets will need updated, so do this now:\r
x264Panel.X264_StandardizeOptString();\r
x264Panel.X264_SetCurrentSettingsInPanel();\r
}\r
// Startup Functions \r
private void queueRecovery()\r
{\r
- if (Main.checkQueueRecovery())\r
+ if (Main.CheckQueueRecovery())\r
{\r
DialogResult result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
\r
this.Resize += new EventHandler(frmMain_Resize);\r
\r
// Handle Encode Start / Finish / Pause\r
- encodeQueue.CurrentJobCompleted += new EventHandler(encodeEnded);\r
+\r
encodeQueue.QueuePauseRequested += new EventHandler(encodePaused);\r
- encodeQueue.NewJobStarted += new EventHandler(encodeStarted);\r
+ encodeQueue.EncodeStarted += new EventHandler(encodeStarted);\r
+ encodeQueue.EncodeEnded += new EventHandler(encodeEnded);\r
\r
// Handle a file being draged onto the GUI.\r
this.DragEnter += new DragEventHandler(frmMain_DragEnter);\r
private void changePresetLabel(object sender, EventArgs e)\r
{\r
labelPreset.Text = "Output Settings (Preset: Custom)";\r
+ CurrentlySelectedPreset = null;\r
}\r
\r
private static void frmMain_DragEnter(object sender, DragEventArgs e)\r
private void encodeStarted(object sender, EventArgs e)\r
{\r
lastAction = "encode";\r
- setEncodeStarted();\r
+ SetEncodeStarted();\r
\r
// Experimental HBProc Process Monitoring.\r
if (Properties.Settings.Default.enocdeStatusInGui)\r
{\r
- Thread encodeMon = new Thread(encodeMonitorThread);\r
+ Thread encodeMon = new Thread(EncodeMonitorThread);\r
encodeMon.Start();\r
}\r
}\r
private void encodeEnded(object sender, EventArgs e)\r
{\r
- setEncodeFinished();\r
+ SetEncodeFinished();\r
}\r
private void encodePaused(object sender, EventArgs e)\r
{\r
- setEncodeFinished();\r
+ SetEncodeFinished();\r
}\r
#endregion\r
\r
private void mnu_presetReset_Click(object sender, EventArgs e)\r
{\r
presetHandler.UpdateBuiltInPresets();\r
- loadPresetPanel();\r
+ LoadPresetPanel();\r
if (treeView_presets.Nodes.Count == 0)\r
MessageBox.Show("Unable to load the presets.xml file. Please select \"Update Built-in Presets\" from the Presets Menu. \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
else\r
private void mnu_delete_preset_Click(object sender, EventArgs e)\r
{\r
presetHandler.RemoveBuiltInPresets();\r
- loadPresetPanel(); // Reload the preset panel\r
+ LoadPresetPanel(); // Reload the preset panel\r
}\r
private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
{\r
}\r
private void btn_new_preset_Click(object sender, EventArgs e)\r
{\r
- Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler);\r
+ Form preset = new frmAddPreset(this, QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler);\r
preset.ShowDialog();\r
}\r
#endregion\r
nodeStatus.Add(node.IsExpanded);\r
\r
// Now reload the preset panel\r
- loadPresetPanel();\r
+ LoadPresetPanel();\r
\r
// And finally, re-expand any of the nodes if required\r
int i = 0;\r
{\r
// Ok, so, we've selected a preset. Now we want to load it.\r
string presetName = treeView_presets.SelectedNode.Text;\r
- if (presetHandler.GetPreset(presetName) != null)\r
+ Preset preset = presetHandler.GetPreset(presetName);\r
+ if (preset != null)\r
{\r
string query = presetHandler.GetPreset(presetName).Query;\r
Boolean loadPictureSettings = presetHandler.GetPreset(presetName).PictureSettings;\r
if (query != null)\r
{\r
//Ok, Reset all the H264 widgets before changing the preset\r
- x264Panel.reset2Defaults();\r
+ x264Panel.Reset2Defaults();\r
\r
// Send the query from the file to the Query Parser class\r
QueryParser presetQuery = QueryParser.Parse(query);\r
\r
// Now load the preset\r
- PresetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings);\r
+ PresetLoader.LoadPreset(this, presetQuery, presetName, loadPictureSettings);\r
\r
// The x264 widgets will need updated, so do this now:\r
x264Panel.X264_StandardizeOptString();\r
x264Panel.X264_SetCurrentSettingsInPanel();\r
+\r
+ // Finally, let this window have a copy of the preset settings.\r
+ CurrentlySelectedPreset = preset;\r
+ PictureSettings.SetPresetCropWarningLabel(preset);\r
}\r
}\r
}\r
}\r
private void importPreset()\r
{\r
- Import imp = new Import();\r
if (openPreset.ShowDialog() == DialogResult.OK)\r
{\r
- QueryParser parsed = imp.importMacPreset(openPreset.FileName);\r
+ QueryParser parsed = PlistPresetHandler.Import(openPreset.FileName);\r
if (presetHandler.CheckIfUserPresetExists(parsed.PresetName + " (Imported)"))\r
{\r
DialogResult result = MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?", "Overwrite preset?",\r
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
if (result == DialogResult.Yes)\r
{\r
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null),\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+ presetHandler.Update(parsed.PresetName + " (Imported)", QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),\r
parsed.UsesPictureSettings);\r
}\r
}\r
else\r
{\r
- PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
- presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings);\r
+ PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);\r
+ presetHandler.Add(parsed.PresetName, QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings);\r
\r
- if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings))\r
+ if (presetHandler.Add(parsed.PresetName + " (Imported)", QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings))\r
{\r
TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black };\r
treeView_presets.Nodes.Add(preset_treeview);\r
private void btn_source_Click(object sender, EventArgs e)\r
{\r
mnu_dvd_drive.Visible = true;\r
- Thread driveInfoThread = new Thread(getDriveInfoThread);\r
+ Thread driveInfoThread = new Thread(SetDriveSelectionMenuItem);\r
driveInfoThread.Start();\r
}\r
private void btn_start_Click(object sender, EventArgs e)\r
{\r
if (btn_start.Text == "Stop")\r
{\r
- DialogResult result = MessageBox.Show("Are you sure you wish to cancel the encode?", "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+ DialogResult result;\r
+ if (Properties.Settings.Default.enocdeStatusInGui && !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
\r
if (result == DialogResult.Yes)\r
{\r
// Pause The Queue\r
- encodeQueue.RequestPause();\r
+ encodeQueue.Pause();\r
\r
- // Allow the CLI to exit cleanly\r
- Win32.SetForegroundWindow((int)encodeQueue.processHandle);\r
- SendKeys.Send("^C");\r
+ if (Properties.Settings.Default.enocdeStatusInGui && !Properties.Settings.Default.showCliForInGuiEncodeStatus)\r
+ {\r
+ encodeQueue.Stop();\r
+ if (encodeQueue.HbProcess != null)\r
+ encodeQueue.HbProcess.WaitForExit();\r
+ }\r
+ else\r
+ {\r
+ encodeQueue.SafelyClose();\r
+ }\r
\r
// Update the GUI\r
- setEncodeFinished();\r
+ SetEncodeFinished();\r
}\r
}\r
else\r
{\r
if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text)))\r
{\r
- string generatedQuery = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
- string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ string generatedQuery = QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
string query = string.Empty;\r
\r
// Check to make sure the generated query matches the GUI settings\r
if (overwrite == DialogResult.Yes)\r
{\r
if (encodeQueue.Count == 0)\r
- encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+ encodeQueue.Add(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
\r
- queueWindow.setQueue();\r
+ queueWindow.SetQueue();\r
if (encodeQueue.Count > 1)\r
queueWindow.Show(false);\r
\r
- setEncodeStarted(); // Encode is running, so setup the GUI appropriately\r
- encodeQueue.StartEncodeQueue(); // Start The Queue Encoding Process\r
+ SetEncodeStarted(); // Encode is running, so setup the GUI appropriately\r
+ encodeQueue.Start(); // Start The Queue Encoding Process\r
lastAction = "encode"; // Set the last action to encode - Used for activity window.\r
}\r
if (ActivityWindow != null)\r
MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
else\r
{\r
- String query = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ String query = QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
if (rtf_query.Text != "")\r
query = rtf_query.Text;\r
\r
DialogResult result = MessageBox.Show("There is already a queue item for this destination path. \n\n If you continue, the encode will be overwritten. Do you wish to continue?",\r
"Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
if (result == DialogResult.Yes)\r
- encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+ encodeQueue.Add(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
\r
}\r
else\r
- encodeQueue.AddJob(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
+ encodeQueue.Add(query, sourcePath, text_destination.Text, (rtf_query.Text != ""));\r
\r
lbl_encode.Text = encodeQueue.Count + " encode(s) pending in the queue";\r
\r
}\r
\r
sourcePath = Path.GetFileName(file);\r
- StartScan(file,0);\r
+ StartScan(file, 0);\r
}\r
private void drp_dvdtitle_Click(object sender, EventArgs e)\r
{\r
private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
{\r
UnRegisterPresetEventHandler();\r
+ drop_mode.SelectedIndex = 0;\r
\r
PictureSettings.lbl_Aspect.Text = "Select a Title"; // Reset some values on the form\r
drop_chapterStart.Items.Clear();\r
{\r
selectedTitle = drp_dvdtitle.SelectedItem as Title;\r
lbl_duration.Text = selectedTitle.Duration.ToString();\r
+ PictureSettings.CurrentlySelectedPreset = CurrentlySelectedPreset;\r
PictureSettings.Source = selectedTitle; // Setup Picture Settings Tab Control\r
\r
// Populate the Angles dropdown\r
if (!string.IsNullOrEmpty(selectedTitle.SourceName))\r
labelSource.Text = labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
\r
- // Run the autoName & chapterNaming functions\r
+ // Run the AutoName & ChapterNaming functions\r
if (Properties.Settings.Default.autoNaming)\r
{\r
- string autoPath = Main.autoName(this);\r
+ string autoPath = Main.AutoName(this);\r
if (autoPath != null)\r
text_destination.Text = autoPath;\r
else\r
data_chpt.Rows.Clear();\r
if (selectedTitle.Chapters.Count != 1)\r
{\r
- DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text);\r
+ DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text);\r
if (chapterGridView != null)\r
data_chpt = chapterGridView;\r
}\r
}\r
\r
// Update the Duration\r
- lbl_duration.Text = Main.calculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString();\r
+ lbl_duration.Text = Main.CalculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString();\r
\r
// Run the Autonaming function\r
if (Properties.Settings.Default.autoNaming)\r
- text_destination.Text = Main.autoName(this);\r
+ text_destination.Text = Main.AutoName(this);\r
\r
// Disable chapter markers if only 1 chapter is selected.\r
if (chapterStart == chapterEnd)\r
}\r
}\r
}\r
- private void drop_mode_SelectedIndexChanged(object sender, EventArgs e)\r
+ private void SecondsOrFramesChanged(object sender, EventArgs e)\r
{\r
- if (drop_mode.SelectedIndex == 0) return;\r
+ int start, end;\r
+ int.TryParse(drop_chapterStart.Text, out start);\r
+ int.TryParse(drop_chapterFinish.Text, out end);\r
+ double duration = end - start;\r
\r
- if (drop_mode.SelectedIndex != 0)\r
- drop_mode.SelectedIndex = 0;\r
+ switch (drop_mode.SelectedIndex)\r
+ {\r
+ case 1:\r
+ lbl_duration.Text = TimeSpan.FromSeconds(duration).ToString();\r
+ return;\r
+ case 2:\r
+ if (selectedTitle != null)\r
+ {\r
+ duration = duration / selectedTitle.Fps;\r
+ lbl_duration.Text = TimeSpan.FromSeconds(duration).ToString();\r
+ }\r
+ else\r
+ lbl_duration.Text = "--:--:--";\r
\r
- MessageBox.Show("This feature is not implemented yet! Switching Back to Chapters Mode.", "",\r
- MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+ }\r
+ private void drop_mode_SelectedIndexChanged(object sender, EventArgs e)\r
+ {\r
+ // Reset\r
+ this.drop_chapterFinish.TextChanged -= new System.EventHandler(this.SecondsOrFramesChanged);\r
+ this.drop_chapterStart.TextChanged -= new System.EventHandler(this.SecondsOrFramesChanged);\r
+\r
+ // Do Work\r
+ switch (drop_mode.SelectedIndex)\r
+ {\r
+ case 0:\r
+ drop_chapterStart.DropDownStyle = ComboBoxStyle.DropDownList;\r
+ drop_chapterFinish.DropDownStyle = ComboBoxStyle.DropDownList;\r
+ if (drop_chapterStart.Items.Count != 0)\r
+ {\r
+ drop_chapterStart.SelectedIndex = 0;\r
+ drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1;\r
+ }\r
+ else\r
+ lbl_duration.Text = "--:--:--";\r
+ return;\r
+ case 1:\r
+ this.drop_chapterStart.TextChanged += new System.EventHandler(this.SecondsOrFramesChanged);\r
+ this.drop_chapterFinish.TextChanged += new System.EventHandler(this.SecondsOrFramesChanged);\r
+ drop_chapterStart.DropDownStyle = ComboBoxStyle.Simple;\r
+ drop_chapterFinish.DropDownStyle = ComboBoxStyle.Simple;\r
+ if (selectedTitle != null)\r
+ {\r
+ drop_chapterStart.Text = "0";\r
+ drop_chapterFinish.Text = selectedTitle.Duration.TotalSeconds.ToString();\r
+ }\r
+ return;\r
+ case 2:\r
+ this.drop_chapterStart.TextChanged += new System.EventHandler(this.SecondsOrFramesChanged);\r
+ this.drop_chapterFinish.TextChanged += new System.EventHandler(this.SecondsOrFramesChanged);\r
+ drop_chapterStart.DropDownStyle = ComboBoxStyle.Simple;\r
+ drop_chapterFinish.DropDownStyle = ComboBoxStyle.Simple;\r
+ if (selectedTitle != null)\r
+ {\r
+ drop_chapterStart.Text = "0";\r
+ drop_chapterFinish.Text = (selectedTitle.Fps * selectedTitle.Duration.TotalSeconds).ToString();\r
+ }\r
+ return;\r
+ }\r
}\r
\r
//Destination\r
check_turbo.CheckState = CheckState.Unchecked;\r
check_turbo.Enabled = false;\r
tab_advanced.Enabled = false;\r
- x264Panel.x264Query = "";\r
+ x264Panel.X264Query = "";\r
check_iPodAtom.Enabled = false;\r
check_iPodAtom.Checked = false;\r
}\r
switch (drp_videoEncoder.Text)\r
{\r
case "MPEG-4 (FFmpeg)":\r
- double rfValue = 31 - (slider_videoQuality.Value - 1);\r
- double max = slider_videoQuality.Maximum;\r
- double min = slider_videoQuality.Minimum;\r
- double val = ((max - min) - (rfValue - min)) / (max - min);\r
lbl_SliderValue.Text = "QP:" + (32 - slider_videoQuality.Value);\r
- lbl_qualityValue.Text = Math.Round((val * 100), 2).ToString(new CultureInfo("en-US")) + "%";\r
break;\r
case "H.264 (x264)":\r
- rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
- max = slider_videoQuality.Maximum * cqStep;\r
- min = slider_videoQuality.Minimum;\r
- val = ((max - min) - (rfValue - min)) / (max - min);\r
+ double rfValue = 51.0 - slider_videoQuality.Value * cqStep;\r
rfValue = Math.Round(rfValue, 2);\r
lbl_SliderValue.Text = "RF:" + rfValue.ToString(new CultureInfo("en-US"));\r
- lbl_qualityValue.Text = Math.Round((val * 100), 2).ToString(new CultureInfo("en-US")) + "%";\r
break;\r
case "VP3 (Theora)":\r
- rfValue = slider_videoQuality.Value;\r
- double value = rfValue / 63;\r
lbl_SliderValue.Text = "QP:" + slider_videoQuality.Value;\r
- lbl_qualityValue.Text = Math.Round((value * 100), 2).ToString(new CultureInfo("en-US")) + "%";\r
break;\r
}\r
}\r
if (File_ChapterImport.ShowDialog() == DialogResult.OK)\r
{\r
String filename = File_ChapterImport.FileName;\r
- DataGridView imported = Main.importChapterNames(data_chpt, filename);\r
+ DataGridView imported = Main.ImportChapterNames(data_chpt, filename);\r
if (imported != null)\r
data_chpt = imported;\r
}\r
private void mnu_resetChapters_Click(object sender, EventArgs e)\r
{\r
data_chpt.Rows.Clear();\r
- DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text);\r
+ DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text);\r
if (chapterGridView != null)\r
{\r
data_chpt = chapterGridView;\r
// Query Editor Tab\r
private void btn_generate_Query_Click(object sender, EventArgs e)\r
{\r
- rtf_query.Text = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null);\r
+ rtf_query.Text = QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null);\r
}\r
private void btn_clear_Click(object sender, EventArgs e)\r
{\r
\r
try\r
{\r
- DVD thisDVD = SourceScan.SouceData();\r
+ currentSource = SourceScan.SouceData();\r
\r
// Setup some GUI components\r
drp_dvdtitle.Items.Clear();\r
- if (thisDVD.Titles.Count != 0)\r
- drp_dvdtitle.Items.AddRange(thisDVD.Titles.ToArray());\r
+ if (currentSource.Titles.Count != 0)\r
+ drp_dvdtitle.Items.AddRange(currentSource.Titles.ToArray());\r
\r
// Now select the longest title\r
- if (thisDVD.Titles.Count != 0)\r
- drp_dvdtitle.SelectedItem = Main.selectLongestTitle(thisDVD);\r
+ if (currentSource.Titles.Count != 0)\r
+ drp_dvdtitle.SelectedItem = Main.SelectLongestTitle(currentSource);\r
\r
// Enable the creation of chapter markers if the file is an image of a dvd.\r
- if (sourcePath.ToLower().Contains(".iso") || sourcePath.Contains("VIDEO_TS"))\r
+ if (sourcePath.ToLower().Contains(".iso") || sourcePath.Contains("VIDEO_TS") || Directory.Exists(Path.Combine(sourcePath, "VIDEO_TS")))\r
Check_ChapterMarkers.Enabled = true;\r
else\r
{\r
if (!string.IsNullOrEmpty(selectedTitle.SourceName)) // If it's one of multiple source files, make sure we don't use the folder name\r
labelSource.Text = Path.GetFileName(selectedTitle.SourceName);\r
}\r
+\r
+ public void RecievingJob(Job job)\r
+ {\r
+ string query = job.Query;\r
+ StartScan(job.Source, 0);\r
+\r
+\r
+ if (query != null)\r
+ {\r
+ //Ok, Reset all the H264 widgets before changing the preset\r
+ x264Panel.Reset2Defaults();\r
+\r
+ // Send the query from the file to the Query Parser class\r
+ QueryParser presetQuery = QueryParser.Parse(query);\r
+\r
+ // Now load the preset\r
+ PresetLoader.LoadPreset(this, presetQuery, "Load Back From Queue", true);\r
+\r
+ // The x264 widgets will need updated, so do this now:\r
+ x264Panel.X264_StandardizeOptString();\r
+ x264Panel.X264_SetCurrentSettingsInPanel();\r
+\r
+ // Finally, let this window have a copy of the preset settings.\r
+ CurrentlySelectedPreset = null;\r
+ PictureSettings.SetPresetCropWarningLabel(null);\r
+ }\r
+\r
+ }\r
#endregion\r
\r
- #region GUI\r
+ #region GUI Functions and Actions\r
/// <summary>\r
/// Set the GUI to it's finished encoding state.\r
/// </summary>\r
- private void setEncodeFinished()\r
+ private void SetEncodeFinished()\r
{\r
try\r
{\r
if (InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(setEncodeFinished));\r
+ BeginInvoke(new UpdateWindowHandler(SetEncodeFinished));\r
return;\r
}\r
\r
/// <summary>\r
/// Set the GUI to it's started encoding state.\r
/// </summary>\r
- private void setEncodeStarted()\r
+ private void SetEncodeStarted()\r
{\r
try\r
{\r
if (InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(setEncodeStarted));\r
+ BeginInvoke(new UpdateWindowHandler(SetEncodeStarted));\r
return;\r
}\r
\r
MessageBox.Show(exc.ToString());\r
}\r
}\r
- #endregion\r
\r
- #region DVD Drive Detection\r
- private void getDriveInfoThread()\r
+ /// <summary>\r
+ /// Set the DVD Drive selection in the "Source" Menu\r
+ /// </summary>\r
+ private void SetDriveSelectionMenuItem()\r
{\r
try\r
{\r
if (InvokeRequired)\r
{\r
- BeginInvoke(new UpdateWindowHandler(getDriveInfoThread));\r
+ BeginInvoke(new UpdateWindowHandler(SetDriveSelectionMenuItem));\r
return;\r
}\r
\r
- Boolean foundDrive = false;\r
- DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();\r
- foreach (DriveInfo curDrive in theCollectionOfDrives)\r
+ List<DriveInformation> drives = Main.GetDrives();\r
+\r
+ if (drives.Count == 0)\r
{\r
- if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady)\r
- {\r
- if (File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))\r
- {\r
- this.dvdDrivePath = curDrive.RootDirectory + "VIDEO_TS";\r
- this.dvdDriveLabel = curDrive.VolumeLabel;\r
- mnu_dvd_drive.Text = this.dvdDrivePath + " (" + this.dvdDriveLabel + ")";\r
- foundDrive = true;\r
- break;\r
- }\r
- }\r
+ mnu_dvd_drive.Text = "[No DVD Drive Ready]";\r
+ return;\r
}\r
\r
- if (foundDrive == false)\r
- mnu_dvd_drive.Text = "[No DVD Drive Ready]";\r
+ this.dvdDrivePath = drives[0].RootDirectory + "VIDEO_TS";\r
+ this.dvdDriveLabel = drives[0].VolumeLabel;\r
+ mnu_dvd_drive.Text = this.dvdDrivePath + " (" + this.dvdDriveLabel + ")";\r
}\r
catch (Exception)\r
{\r
mnu_dvd_drive.Text = "[No DVD Drive Ready / Found]";\r
}\r
}\r
- #endregion\r
\r
- #region Public Methods\r
/// <summary>\r
/// Access the preset Handler and setup the preset panel.\r
/// </summary>\r
- public void loadPresetPanel()\r
+ private void LoadPresetPanel()\r
{\r
if (presetHandler.CheckIfPresetsAreOutOfDate())\r
if (!Properties.Settings.Default.presetNotification)\r
#endregion\r
\r
#region Overrides\r
+\r
+ /// <summary>\r
+ /// Handle GUI shortcuts\r
+ /// </summary>\r
+ /// <param name="msg"></param>\r
+ /// <param name="keyData"></param>\r
+ /// <returns></returns>\r
+ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)\r
+ {\r
+ if (keyData == (Keys.Control | Keys.S))\r
+ {\r
+ btn_start_Click(this, new EventArgs());\r
+ return true;\r
+ }\r
+\r
+ if (keyData == (Keys.Control | Keys.A))\r
+ {\r
+ btn_add2Queue_Click(this, new EventArgs());\r
+ return true;\r
+ }\r
+ return base.ProcessCmdKey(ref msg, keyData);\r
+ }\r
+\r
/// <summary>\r
/// If the queue is being processed, prompt the user to confirm application close.\r
/// </summary>\r
protected override void OnFormClosing(FormClosingEventArgs e)\r
{\r
// If currently encoding, the queue isn't paused, and there are queue items to process, prompt to confirm close.\r
- if ((encodeQueue.isEncoding) && (!encodeQueue.PauseRequested) && (encodeQueue.Count > 0))\r
+ if ((encodeQueue.IsEncoding) && (!encodeQueue.PauseRequested) && (encodeQueue.Count > 0))\r
{\r
DialogResult result = MessageBox.Show("HandBrake has queue items to process. Closing HandBrake will not stop the current encoding, but will stop processing the queue.\n\nDo you want to close HandBrake?",\r
"Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
#endregion\r
\r
#region In-GUI Encode Status (Experimental)\r
- private void encodeMonitorThread()\r
+ /// <summary>\r
+ /// Starts a new thread to monitor and process the CLI encode status\r
+ /// </summary>\r
+ private void EncodeMonitorThread()\r
{\r
try\r
{\r
- Parser encode = new Parser(encodeQueue.hbProcess.StandardOutput.BaseStream);\r
- encode.OnEncodeProgress += encodeOnEncodeProgress;\r
+ Parser encode = new Parser(encodeQueue.HbProcess.StandardOutput.BaseStream);\r
+ encode.OnEncodeProgress += EncodeOnEncodeProgress;\r
while (!encode.EndOfStream)\r
encode.readEncodeStatus();\r
}\r
MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
- private void encodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
+ \r
+ /// <summary>\r
+ /// Displays the Encode status in the GUI\r
+ /// </summary>\r
+ /// <param name="Sender"></param>\r
+ /// <param name="CurrentTask"></param>\r
+ /// <param name="TaskCount"></param>\r
+ /// <param name="PercentComplete"></param>\r
+ /// <param name="CurrentFps"></param>\r
+ /// <param name="AverageFps"></param>\r
+ /// <param name="TimeRemaining"></param>\r
+ private void EncodeOnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
{\r
if (this.InvokeRequired)\r
{\r
- this.BeginInvoke(new EncodeProgressEventHandler(encodeOnEncodeProgress),\r
+ this.BeginInvoke(new EncodeProgressEventHandler(EncodeOnEncodeProgress),\r
new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
return;\r
}\r
}\r
#endregion\r
\r
- #region enum\r
- private enum SourceType\r
- {\r
- None = 0,\r
- Folder,\r
- DvdDrive,\r
- VideoFile\r
- }\r
- #endregion\r
-\r
// This is the END of the road ****************************************\r
}\r
}
\ No newline at end of file