private Process hbProc;\r
private Parsing.DVD thisDVD;\r
private frmQueue queueWindow = new frmQueue();\r
+ private delegate void updateStatusChanger();\r
+ Functions.Common hb_common_func = new Functions.Common();\r
\r
- // The main window beings here...\r
public frmMain()\r
{\r
// Load the splash screen in this thread\r
\r
//Create a label that can be updated from the parent thread.\r
Label lblStatus = new Label();\r
-\r
- //Size the label\r
lblStatus.Size = new Size(250, 20);\r
-\r
- //Position the label\r
lblStatus.Location = new Point(10, 280);\r
-\r
- //Put the label on the splash form\r
splash.Controls.Add(lblStatus);\r
\r
//Fire a thread to wait for 2 seconds. The splash screen will exit when the time expires\r
\r
InitializeComponent();\r
\r
- // show the form, but leave disabled until preloading is complete\r
+ // show the form, but leave disabled until preloading is complete then show the main form\r
this.Enabled = false;\r
\r
- // Show the main form\r
this.Show();\r
\r
// Forces frmMain to draw\r
if (Properties.Settings.Default.updateStatus == "Checked")\r
{\r
lblStatus.Text = "Checking for updates ...";\r
- // redraw the splash screen\r
Application.DoEvents();\r
- // Run the update checker.\r
Thread updateCheckThread = new Thread(startupUpdateCheck);\r
updateCheckThread.Start();\r
Thread.Sleep(100);\r
Thread.Sleep(100);\r
}\r
else\r
- {\r
loadNormalPreset();\r
- }\r
\r
// Enable or disable tooltips\r
if (Properties.Settings.Default.tooltipEnable == "Checked")\r
// Turn the interface back to the user\r
this.Enabled = true;\r
}\r
-\r
- private delegate void updateStatusChanger();\r
+ \r
private void startupUpdateCheck()\r
{\r
try\r
this.BeginInvoke(new updateStatusChanger(startupUpdateCheck));\r
return;\r
}\r
-\r
- Boolean update = updateCheck();\r
+ \r
+ Boolean update = hb_common_func.updateCheck();\r
if (update == true)\r
{\r
lbl_update.Visible = true;\r
\r
private void showSplash(object sender)\r
{\r
- // Display splash screen for 1.5 Seconds\r
Form splash = new frmSplashScreen();\r
splash.Show();\r
- Thread.Sleep(1500);\r
- splash.Close(); // Then close.\r
}\r
\r
private void loadUserDefaults()\r
// Some things that need to be done to reset some gui components:\r
CheckPixelRatio.CheckState = CheckState.Unchecked;\r
\r
- // Send the query from the file to the Query Parser class\r
+ // Send the query from the file to the Query Parser class Then load the preset\r
Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);\r
-\r
- // Now load the preset\r
presetLoader(presetQuery, "User Defaults ");\r
}\r
catch (Exception exc)\r
{\r
try\r
{\r
- // Some things that need to be done to reset some gui components:\r
- CheckPixelRatio.CheckState = CheckState.Unchecked;\r
-\r
- //---------------------------\r
- // Get the Preset\r
- // ---------------------------\r
-\r
// Create StreamReader & open file\r
StreamReader line = new StreamReader(filename);\r
\r
- // Send the query from the file to the Query Parser class\r
+ // Send the query from the file to the Query Parser class then load the preset\r
Functions.QueryParser presetQuery = Functions.QueryParser.Parse(line.ReadLine());\r
-\r
- // Now load the preset\r
presetLoader(presetQuery, filename);\r
\r
// Close the stream\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
- MessageBox.Show(exc.ToString());\r
+ MessageBox.Show("Unable to load profile. \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
}\r
}\r
}\r
\r
private void mnu_showCommand_Click(object sender, EventArgs e)\r
{\r
-\r
Form query = new frmQuery(GenerateTheQuery());\r
query.ShowDialog();\r
}\r
#endregion\r
\r
#region Presets Menu\r
- Boolean presetStatus;\r
\r
private void mnu_presetReset_Click(object sender, EventArgs e)\r
{\r
\r
private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
{\r
- Boolean update = updateCheck();\r
+ Boolean update = hb_common_func.updateCheck();\r
if (update == true)\r
{\r
lbl_update.Visible = true;\r
updateWindow.Show();\r
}\r
else\r
- {\r
MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
- }\r
}\r
\r
private void mnu_about_Click(object sender, EventArgs e)\r
\r
// If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
if (drp_dvdtitle.Items.Count == 0)\r
- {\r
MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source. Please refer to the FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
- }\r
}\r
\r
private void btn_destBrowse_Click(object sender, EventArgs e)\r
{\r
// This removes the file extension from the filename box on the save file dialog.\r
// It's daft but some users don't realise that typing an extension overrides the dropdown extension selected.\r
- // Should be a nicer way to do this.\r
DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "").Replace(".ogm", "").Replace(".avi", "");\r
\r
// Show the dialog and set the main form file path\r
\r
// Quicktime requires .m4v file for chapter markers to work. If checked, change the extension to .m4v (mp4 and m4v are the same thing)\r
if (Check_ChapterMarkers.Checked)\r
- {\r
- string destination = text_destination.Text;\r
- destination = destination.Replace(".mp4", ".m4v");\r
- text_destination.Text = destination;\r
- }\r
+ text_destination.Text = text_destination.Text.Replace(".mp4", ".m4v");\r
}\r
\r
private void btn_h264Clear_Click(object sender, EventArgs e)\r
drop_chapterStart.Items.Clear();\r
drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());\r
if (drop_chapterStart.Items.Count > 0)\r
- {\r
drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();\r
- }\r
\r
// Populate the Final Chapter Dropdown\r
drop_chapterFinish.Items.Clear();\r
drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());\r
if (drop_chapterFinish.Items.Count > 0)\r
- {\r
drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();\r
- }\r
\r
// Populate the Audio Channels Dropdown\r
drp_track1Audio.Items.Clear();\r
drp_track1Audio.Items.Add("None");\r
drp_track1Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
if (drp_track1Audio.Items.Count > 0)\r
- {\r
drp_track1Audio.Text = drp_track1Audio.Items[0].ToString();\r
- }\r
+\r
drp_track2Audio.Items.Clear();\r
drp_track2Audio.Items.Add("None");\r
drp_track2Audio.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
if (drp_track2Audio.Items.Count > 0)\r
- {\r
drp_track2Audio.Text = drp_track2Audio.Items[0].ToString();\r
- }\r
-\r
\r
// Populate the Subtitles dropdown\r
drp_subtitle.Items.Clear();\r
drp_subtitle.Items.Add("Autoselect");\r
drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
if (drp_subtitle.Items.Count > 0)\r
- {\r
drp_subtitle.Text = drp_subtitle.Items[0].ToString();\r
- }\r
+\r
}\r
\r
- // Run the Autonaming function\r
+ // Run the autoName & chapterNaming functions\r
autoName();\r
chapterNaming();\r
}\r
int chapterStart = int.Parse(drop_chapterStart.Text);\r
\r
if (chapterFinish < chapterStart)\r
- {\r
drop_chapterStart.BackColor = Color.LightCoral;\r
- }\r
}\r
catch (Exception)\r
{\r
int chapterStart = int.Parse(drop_chapterStart.Text);\r
\r
if (chapterFinish < chapterStart)\r
- {\r
drop_chapterFinish.BackColor = Color.LightCoral;\r
- }\r
}\r
catch (Exception)\r
{\r
else\r
{\r
if ((int.Parse(text_width.Text) % 16) != 0)\r
- {\r
text_width.BackColor = Color.LightCoral;\r
- }\r
else\r
- {\r
text_width.BackColor = Color.LightGreen;\r
- }\r
}\r
\r
if (lbl_Aspect.Text != "Select a Title")\r
text_width.BackColor = Color.White;\r
}\r
else\r
- {\r
text_height.Text = height.ToString();\r
- }\r
}\r
}\r
catch (Exception)\r
{\r
// No need to throw an error here.\r
- // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.\r
}\r
-\r
-\r
}\r
\r
private void text_height_TextChanged(object sender, EventArgs e)\r
else\r
{\r
if ((int.Parse(text_height.Text) % 16) != 0)\r
- {\r
text_height.BackColor = Color.LightCoral;\r
- }\r
else\r
- {\r
text_height.BackColor = Color.LightGreen;\r
- }\r
}\r
\r
}\r
text_top.Enabled = false;\r
text_bottom.Enabled = false;\r
\r
-\r
if (lbl_RecomendedCrop.Text != "Select a Title")\r
{\r
string[] temp = new string[4];\r
if (check_2PassEncode.CheckState.ToString() == "Checked")\r
{\r
if (drp_videoEncoder.Text.Contains("H.264"))\r
- {\r
check_turbo.Enabled = true;\r
- }\r
}\r
else\r
{\r
check_iPodAtom.CheckState = CheckState.Unchecked;\r
}\r
else\r
- {\r
lbl_ipodAtom.Visible = false;\r
- }\r
}\r
\r
private void check_optimiseMP4_CheckedChanged(object sender, EventArgs e)\r
check_optimiseMP4.CheckState = CheckState.Unchecked;\r
}\r
else\r
- {\r
check_optimiseMP4.BackColor = Color.Transparent;\r
- }\r
}\r
\r
private void drp_dvdtitle_Click(object sender, EventArgs e)\r
{\r
if (drp_dvdtitle.Items.Count == 0)\r
- {\r
MessageBox.Show("There are no titles to select. Please scan the DVD by clicking the 'browse' button above before trying to select a title.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
- }\r
}\r
\r
private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)\r
else\r
{\r
if (check_2PassEncode.CheckState == CheckState.Checked)\r
- {\r
check_turbo.Enabled = true;\r
- }\r
+\r
h264Tab.Enabled = true;\r
check_iPodAtom.Enabled = true;\r
lbl_ipodAtom.Visible = false;\r
// Function to select the default preset.\r
private void loadNormalPreset()\r
{\r
-\r
int normal = 0;\r
foreach (TreeNode treenode in treeView_presets.Nodes)\r
{\r
TreeNode np = treeView_presets.Nodes[normal];\r
\r
treeView_presets.SelectedNode = np;\r
-\r
-\r
-\r
}\r
\r
// Buttons\r
\r
}\r
else\r
- {\r
presetInput.ReadLine();\r
- }\r
}\r
}\r
catch (Exception exc)\r
MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
+\r
#endregion\r
\r
//---------------------------------------------------\r
{\r
// Make sure we are not already encoding and if we are then display an error.\r
if (hbProc != null)\r
- {\r
MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
- }\r
else\r
{\r
hbProc = process.runCli(this, (string)state, false, false, false, false);\r
\r
#endregion\r
\r
-\r
//---------------------------------------------------\r
// Some Functions\r
// - Query Generation\r
\r
drp_videoEncoder.Text = presetQuery.VideoEncoder;\r
drp_audioCodec.Text = presetQuery.AudioEncoder;\r
- if (presetQuery.Width != 0)\r
- text_width.Text = presetQuery.Width.ToString();\r
- else\r
- {\r
- text_width.Text = "";\r
- text_width.BackColor = Color.White;\r
- }\r
\r
- if (presetQuery.Height != 0)\r
- text_height.Text = presetQuery.Height.ToString();\r
- else\r
- {\r
- text_height.Text = "";\r
- text_height.BackColor = Color.White;\r
- }\r
#endregion\r
\r
// Picture Settings Tab\r
else\r
check_lAnamorphic.CheckState = CheckState.Unchecked;\r
\r
+ if (presetQuery.Width != 0)\r
+ text_width.Text = presetQuery.Width.ToString();\r
+ else\r
+ {\r
+ text_width.Text = "";\r
+ text_width.BackColor = Color.White;\r
+ }\r
+\r
+ if (presetQuery.Height != 0)\r
+ text_height.Text = presetQuery.Height.ToString();\r
+ else\r
+ {\r
+ text_height.Text = "";\r
+ text_height.BackColor = Color.White;\r
+ }\r
+\r
if (presetQuery.VFR == true)\r
check_vfr.CheckState = CheckState.Checked;\r
else\r
#endregion\r
}\r
\r
- private Boolean updateCheck()\r
- {\r
- try\r
- {\r
- Functions.RssReader rssRead = new Functions.RssReader();\r
- string build = rssRead.build();\r
-\r
- int latest = int.Parse(build);\r
- int current = Properties.Settings.Default.build;\r
- int skip = Properties.Settings.Default.skipversion;\r
-\r
- if (latest == skip)\r
- {\r
- return false;\r
- }\r
- else\r
- {\r
- Boolean update = (latest > current);\r
- return update;\r
- }\r
- }\r
- catch (Exception exc)\r
- {\r
- MessageBox.Show(exc.ToString());\r
- return false;\r
- }\r
- }\r
-\r
public void setStreamReader(Parsing.DVD dvd)\r
{\r
this.thisDVD = dvd;\r
csv.Append(",");\r
csv.Append(row.Cells[1].Value.ToString());\r
csv.Append(Environment.NewLine);\r
-\r
}\r
StreamWriter file = new StreamWriter(path);\r
file.Write(csv.ToString());\r