2 using System.Collections.Generic;
\r
3 using System.ComponentModel;
\r
5 using System.Drawing;
\r
7 using System.Windows.Forms;
\r
10 using System.Diagnostics;
\r
14 public partial class frmMain : Form
\r
18 InitializeComponent();
\r
21 // --------------------------------------------------------------
\r
22 // onLoad - setup the program ready for use.
\r
23 // --------------------------------------------------------------
\r
24 private void frmMain_Load(object sender, EventArgs e)
\r
26 // Set the Version number lable to the corect version.
\r
27 Version.Text = "Version " + Properties.Settings.Default.GuiVersion;
\r
29 // Run the update checker.
\r
32 // Now load the users default if required.
\r
37 public void loadUserDefaults()
\r
41 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
44 text_source.Text = Properties.Settings.Default.DVDSource;
\r
45 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
46 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
47 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
49 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
50 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
51 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
52 text_width.Text = Properties.Settings.Default.Width;
\r
53 text_height.Text = Properties.Settings.Default.Height;
\r
54 //Picture Settings Tab
\r
55 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
56 text_top.Text = Properties.Settings.Default.CropTop;
\r
57 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
58 text_left.Text = Properties.Settings.Default.CropLeft;
\r
59 text_right.Text = Properties.Settings.Default.CropRight;
\r
60 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
61 //Video Settings Tab
\r
62 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
63 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
64 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
65 if (Properties.Settings.Default.TwoPass == "Checked")
\r
67 check_2PassEncode.CheckState = CheckState.Checked;
\r
69 if (Properties.Settings.Default.DeInterlace == "Checked")
\r
71 check_DeInterlace.CheckState = CheckState.Checked;
\r
73 if (Properties.Settings.Default.Grayscale == "Checked")
\r
75 check_grayscale.CheckState = CheckState.Checked;
\r
78 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
80 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
82 CheckPixelRatio.CheckState = CheckState.Checked;
\r
84 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
86 check_turbo.CheckState = CheckState.Checked;
\r
88 if (Properties.Settings.Default.largeFile == "Checked")
\r
90 check_largeFile.CheckState = CheckState.Checked;
\r
92 //Audio Settings Tab
\r
93 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
94 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
95 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
97 if (Properties.Settings.Default.CRF == "Checked")
\r
99 CheckCRF.CheckState = CheckState.Checked;
\r
101 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
106 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
110 public void updateCheck()
\r
112 if (Properties.Settings.Default.updateStatus == "Checked")
\r
117 String updateFile = Properties.Settings.Default.updateFile;
\r
118 WebClient client = new WebClient();
\r
119 String data = client.DownloadString(updateFile);
\r
120 String[] versionData = data.Split('\n');
\r
122 if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))
\r
124 lbl_update.Visible = true;
\r
127 //else fail displaying an error message.
\r
130 //Silently ignore the error
\r
136 // --------------------------------------------------------------
\r
138 // --------------------------------------------------------------
\r
140 // FILE MENU --------------------------------------------------------------
\r
141 private void mnu_open_Click(object sender, EventArgs e)
\r
144 File_Open.ShowDialog();
\r
145 filename = File_Open.FileName;
\r
146 if (filename != "")
\r
150 // Create StreamReader & open file
\r
151 StreamReader line = new StreamReader(filename);
\r
152 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
154 // Read in the data and set the correct GUI component with the setting.
\r
155 text_source.Text = line.ReadLine();
\r
156 drp_dvdtitle.Text = line.ReadLine();
\r
157 drop_chapterStart.Text = line.ReadLine();
\r
158 drop_chapterFinish.Text = line.ReadLine();
\r
159 text_destination.Text = line.ReadLine();
\r
160 drp_videoEncoder.Text = line.ReadLine();
\r
161 drp_audioCodec.Text = line.ReadLine();
\r
162 text_width.Text = line.ReadLine();
\r
163 text_height.Text = line.ReadLine();
\r
164 text_top.Text = line.ReadLine();
\r
165 text_bottom.Text = line.ReadLine();
\r
166 text_left.Text = line.ReadLine();
\r
167 text_right.Text = line.ReadLine();
\r
168 drp_subtitle.Text = line.ReadLine();
\r
169 text_bitrate.Text = line.ReadLine();
\r
170 text_filesize.Text = line.ReadLine();
\r
171 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
173 temporyLine = line.ReadLine();
\r
174 if (temporyLine == "Checked")
\r
176 check_2PassEncode.CheckState = CheckState.Checked;
\r
179 temporyLine = line.ReadLine();
\r
180 if (temporyLine == "Checked")
\r
182 check_DeInterlace.CheckState = CheckState.Checked;
\r
185 temporyLine = line.ReadLine();
\r
186 if (temporyLine == "Checked")
\r
188 check_grayscale.CheckState = CheckState.Checked;
\r
191 drp_videoFramerate.Text = line.ReadLine();
\r
193 temporyLine = line.ReadLine();
\r
194 if (temporyLine == "Checked")
\r
196 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
199 temporyLine = line.ReadLine();
\r
200 if (temporyLine == "Checked")
\r
202 CheckPixelRatio.CheckState = CheckState.Checked;
\r
205 temporyLine = line.ReadLine();
\r
206 if (temporyLine == "Checked")
\r
208 check_turbo.CheckState = CheckState.Checked;
\r
211 temporyLine = line.ReadLine();
\r
212 if (temporyLine == "Checked")
\r
214 check_largeFile.CheckState = CheckState.Checked;
\r
217 drp_audioBitrate.Text = line.ReadLine();
\r
218 drp_audioSampleRate.Text = line.ReadLine();
\r
219 drp_audioChannels.Text = line.ReadLine();
\r
220 drp_audioMixDown.Text = line.ReadLine();
\r
222 // Advanced H264 Options
\r
223 temporyLine = line.ReadLine();
\r
224 if (temporyLine == "Checked")
\r
226 CheckCRF.CheckState = CheckState.Checked;
\r
228 rtf_h264advanced.Text = line.ReadLine();
\r
230 // Close the stream
\r
234 // Fix for SliderValue not appearing when Opening saved file
\r
235 SliderValue.Text = slider_videoQuality.Value + "%";
\r
237 } catch (Exception){
\r
238 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
243 private void mnu_save_Click(object sender, EventArgs e)
\r
247 File_Save.ShowDialog();
\r
248 filename = File_Save.FileName;
\r
249 if (filename != "")
\r
253 // Create a StreamWriter and open the file
\r
254 StreamWriter line = new StreamWriter(filename);
\r
257 line.WriteLine(text_source.Text);
\r
258 line.WriteLine(drp_dvdtitle.Text);
\r
259 line.WriteLine(drop_chapterStart.Text);
\r
260 line.WriteLine(drop_chapterFinish.Text);
\r
262 line.WriteLine(text_destination.Text);
\r
263 line.WriteLine(drp_videoEncoder.Text);
\r
264 line.WriteLine(drp_audioCodec.Text);
\r
265 line.WriteLine(text_width.Text);
\r
266 line.WriteLine(text_height.Text);
\r
267 //Picture Settings Tab
\r
268 line.WriteLine(text_top.Text);
\r
269 line.WriteLine(text_bottom.Text);
\r
270 line.WriteLine(text_left.Text);
\r
271 line.WriteLine(text_right.Text);
\r
272 line.WriteLine(drp_subtitle.Text);
\r
273 //Video Settings Tab
\r
274 line.WriteLine(text_bitrate.Text);
\r
275 line.WriteLine(text_filesize.Text);
\r
276 line.WriteLine(slider_videoQuality.Value.ToString());
\r
277 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
278 line.WriteLine(check_DeInterlace.CheckState.ToString());
\r
279 line.WriteLine(check_grayscale.CheckState.ToString());
\r
280 line.WriteLine(drp_videoFramerate.Text);
\r
281 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
282 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
283 line.WriteLine(check_turbo.CheckState.ToString());
\r
284 line.WriteLine(check_largeFile.CheckState.ToString());
\r
285 //Audio Settings Tab
\r
286 line.WriteLine(drp_audioBitrate.Text);
\r
287 line.WriteLine(drp_audioSampleRate.Text);
\r
288 line.WriteLine(drp_audioChannels.Text);
\r
289 line.WriteLine(drp_audioMixDown.Text);
\r
291 line.WriteLine(CheckCRF.CheckState.ToString());
\r
292 line.WriteLine(rtf_h264advanced.Text);
\r
293 // close the stream
\r
295 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
299 MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
305 private void mnu_update_Click(object sender, EventArgs e)
\r
307 Form Update = new frmUpdate();
\r
308 Update.ShowDialog();
\r
311 private void mnu_exit_Click(object sender, EventArgs e)
\r
316 // TOOLS MENU --------------------------------------------------------------
\r
317 private void mnu_encode_Click(object sender, EventArgs e)
\r
319 //Queue.ShowDialog();
\r
322 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
324 Form DVDData = new frmDvdInfo();
\r
328 private void mnu_options_Click(object sender, EventArgs e)
\r
330 Form Options = new frmOptions();
\r
331 Options.ShowDialog();
\r
334 // PRESETS MENU --------------------------------------------------------------
\r
335 private void mnu_preset_ipod133_Click(object sender, EventArgs e)
\r
337 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
338 text_width.Text = "640";
\r
339 text_height.Text = "480";
\r
340 drp_videoEncoder.Text = "H.264 (iPod)";
\r
341 text_bitrate.Text = "1000";
\r
342 text_filesize.Text = "";
\r
343 slider_videoQuality.Value = 0;
\r
344 SliderValue.Text = "0%";
\r
345 drp_audioBitrate.Text = "160";
\r
346 rtf_h264advanced.Text = "";
\r
347 drp_crop.Text = "No Crop";
\r
350 private void mnu_preset_ipod178_Click(object sender, EventArgs e)
\r
352 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
353 text_width.Text = "640";
\r
354 text_height.Text = "352";
\r
355 drp_videoEncoder.Text = "H.264 (iPod)";
\r
356 text_bitrate.Text = "1000";
\r
357 text_filesize.Text = "";
\r
358 slider_videoQuality.Value = 0;
\r
359 SliderValue.Text = "0%";
\r
360 drp_audioBitrate.Text = "160";
\r
361 rtf_h264advanced.Text = "";
\r
362 drp_crop.Text = "No Crop";
\r
365 private void mnu_preset_ipod235_Click(object sender, EventArgs e)
\r
367 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
368 text_width.Text = "640";
\r
369 text_height.Text = "272";
\r
370 drp_videoEncoder.Text = "H.264 (iPod)";
\r
371 text_bitrate.Text = "1000";
\r
372 text_filesize.Text = "";
\r
373 slider_videoQuality.Value = 0;
\r
374 SliderValue.Text = "0%";
\r
375 drp_audioBitrate.Text = "160";
\r
376 rtf_h264advanced.Text = "";
\r
377 drp_crop.Text = "No Crop";
\r
380 private void mnu_appleTv_Click(object sender, EventArgs e)
\r
382 text_width.Text = "";
\r
383 text_height.Text = "";
\r
384 drp_videoEncoder.Text = "H.264";
\r
385 text_bitrate.Text = "3000";
\r
386 text_filesize.Text = "";
\r
387 slider_videoQuality.Value = 0;
\r
388 SliderValue.Text = "0%";
\r
389 drp_audioBitrate.Text = "160";
\r
390 CheckPixelRatio.CheckState = CheckState.Checked;
\r
391 drp_audioSampleRate.Text = "48";
\r
392 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
\r
393 drp_crop.Text = "No Crop";
\r
397 private void mnu_presetPS3_Click(object sender, EventArgs e)
\r
399 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
400 text_width.Text = "";
\r
401 text_height.Text = "";
\r
402 drp_videoEncoder.Text = "H.264";
\r
403 text_bitrate.Text = "3000";
\r
404 text_filesize.Text = "";
\r
405 slider_videoQuality.Value = 0;
\r
406 SliderValue.Text = "0%";
\r
407 drp_audioBitrate.Text = "160";
\r
408 CheckPixelRatio.CheckState = CheckState.Checked;
\r
409 drp_audioSampleRate.Text = "48";
\r
410 rtf_h264advanced.Text = "level=41";
\r
411 drp_crop.Text = "No Crop";
\r
414 private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)
\r
417 Properties.Settings.Default.DVDSource = text_source.Text;
\r
418 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
419 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
420 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
422 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
423 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
424 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
425 Properties.Settings.Default.Width = text_width.Text;
\r
426 Properties.Settings.Default.Height = text_height.Text;
\r
427 //Picture Settings Tab
\r
428 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
429 Properties.Settings.Default.CropTop = text_top.Text;
\r
430 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
431 Properties.Settings.Default.CropLeft = text_left.Text;
\r
432 Properties.Settings.Default.CropRight = text_right.Text;
\r
433 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
434 //Video Settings Tab
\r
435 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
436 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
437 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
438 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
439 Properties.Settings.Default.DeInterlace = check_DeInterlace.CheckState.ToString();
\r
440 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
441 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
442 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
443 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
444 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
445 //Audio Settings Tab
\r
446 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
447 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
448 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
450 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
451 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
452 Properties.Settings.Default.Save();
\r
455 // Help Menu --------------------------------------------------------------
\r
456 private void mnu_wiki_Click(object sender, EventArgs e)
\r
458 Process.Start("http://handbrake.m0k.org/trac");
\r
461 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
463 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
466 private void mnu_faq_Click(object sender, EventArgs e)
\r
468 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
471 private void mnu_homepage_Click(object sender, EventArgs e)
\r
473 Process.Start("http://handbrake.m0k.org");
\r
476 private void mnu_forum_Click(object sender, EventArgs e)
\r
478 Process.Start("http://handbrake.m0k.org/forum");
\r
481 private void mnu_about_Click(object sender, EventArgs e)
\r
483 Form About = new frmAbout();
\r
484 About.ShowDialog();
\r
489 // --------------------------------------------------------------
\r
490 // Buttons on the main Window
\r
491 // --------------------------------------------------------------
\r
492 private void btn_Browse_Click(object sender, EventArgs e)
\r
494 String filename ="";
\r
495 text_source.Text = "";
\r
497 if (RadioDVD.Checked)
\r
499 DVD_Open.ShowDialog();
\r
500 filename = DVD_Open.SelectedPath;
\r
501 if (filename != "")
\r
503 text_source.Text = filename;
\r
504 Form frmReadDVD = new frmReadDVD(filename, this);
\r
505 frmReadDVD.ShowDialog();
\r
510 ISO_Open.ShowDialog();
\r
511 filename = ISO_Open.FileName;
\r
512 if (filename != "")
\r
514 text_source.Text = filename;
\r
515 Form frmReadDVD = new frmReadDVD(filename, this);
\r
516 frmReadDVD.ShowDialog();
\r
521 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
523 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
525 DVD_Save.ShowDialog();
\r
526 text_destination.Text = DVD_Save.FileName;
\r
528 if (Check_ChapterMarkers.Checked)
\r
530 string destination = text_destination.Text;
\r
531 destination = destination.Replace(".mp4", ".m4v");
\r
532 text_destination.Text = destination;
\r
536 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
538 rtf_h264advanced.Text = "";
\r
541 private void GenerateQuery_Click(object sender, EventArgs e)
\r
543 String query = GenerateTheQuery();
\r
544 QueryEditorText.Text = query;
\r
547 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
549 QueryEditorText.Text = "";
\r
555 private frmQueue queueWindow = (frmQueue)new frmQueue();
\r
556 private void btn_queue_Click(object sender, EventArgs e)
\r
558 String query = GenerateTheQuery();
\r
559 queueWindow.list_queue.Items.Add(query);
\r
560 queueWindow.Show();
\r
563 private void btn_encode_Click(object sender, EventArgs e)
\r
567 if (QueryEditorText.Text == "")
\r
569 query = GenerateTheQuery();
\r
573 query = QueryEditorText.Text;
\r
576 System.Diagnostics.Process hbProc = new System.Diagnostics.Process();
\r
577 hbProc.StartInfo.FileName = "hbcli.exe";
\r
578 hbProc.StartInfo.Arguments = query;
\r
579 hbProc.StartInfo.UseShellExecute = false;
\r
583 MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
585 // TODO: Need to write a bit of code here to do process monitoring.
\r
586 // Note: hbProc.waitForExit will freeze the app, meaning one cannot add additional items to the queue during an encode.
\r
589 // --------------------------------------------------------------
\r
590 // Items that require actions on frmMain
\r
591 // --------------------------------------------------------------
\r
594 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
596 QueryEditorText.Text = "";
\r
597 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
601 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
602 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
604 if (chapterFinish < chapterStart)
\r
606 MessageBox.Show("Invalid Chapter Range! - Final chapter can not be smaller than the starting chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
611 MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
618 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
620 QueryEditorText.Text = "";
\r
621 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
625 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
626 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
628 if (chapterFinish > chapterStart)
\r
630 MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
635 MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
640 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
642 text_filesize.Text = "";
\r
643 slider_videoQuality.Value = 0;
\r
644 SliderValue.Text = "0%";
\r
645 CheckCRF.CheckState = CheckState.Unchecked;
\r
648 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
650 text_bitrate.Text = "";
\r
651 slider_videoQuality.Value = 0;
\r
652 SliderValue.Text = "0%";
\r
653 CheckCRF.CheckState = CheckState.Unchecked;
\r
656 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
658 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
659 text_bitrate.Text = "";
\r
660 text_filesize.Text = "";
\r
663 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
665 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
668 private void text_width_TextChanged(object sender, EventArgs e)
\r
672 if (CheckPixelRatio.Checked) {
\r
673 text_width.Text = "";
\r
675 if ((int.Parse(text_width.Text) % 16) != 0){
\r
676 text_width.BackColor = Color.LightCoral;
\r
678 text_width.BackColor = Color.LightGreen;
\r
682 if (!lbl_Aspect.Text.Equals("Select a Title")){
\r
683 int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);
\r
684 int mod16 = height % 16;
\r
685 height = height - mod16;
\r
686 text_height.Text = height.ToString();
\r
689 } catch(Exception){
\r
694 private void text_height_TextChanged(object sender, EventArgs e)
\r
698 if (CheckPixelRatio.Checked)
\r
700 text_height.Text = "";
\r
704 if ((int.Parse(text_height.Text) % 16) != 0)
\r
706 text_height.BackColor = Color.LightCoral;
\r
710 text_height.BackColor = Color.LightGreen;
\r
713 } catch(Exception){
\r
714 // No need to alert the user.
\r
718 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
720 if ((string)drp_crop.SelectedItem == "Manual")
\r
722 text_left.Enabled = true;
\r
723 text_right.Enabled = true;
\r
724 text_top.Enabled = true;
\r
725 text_bottom.Enabled = true;
\r
728 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
730 text_left.Enabled = false;
\r
731 text_right.Enabled = false;
\r
732 text_top.Enabled = false;
\r
733 text_bottom.Enabled = false;
\r
734 text_left.Text = "";
\r
735 text_right.Text = "";
\r
736 text_top.Text = "";
\r
737 text_bottom.Text = "";
\r
739 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
741 string[] temp = new string[4];
\r
742 temp = lbl_RecomendedCrop.Text.Split('/');
\r
743 text_left.Text = temp[2];
\r
744 text_right.Text = temp[3];
\r
745 text_top.Text = temp[0];
\r
746 text_bottom.Text = temp[1];
\r
750 if ((string)drp_crop.SelectedItem == "No Crop")
\r
752 text_left.Enabled = false;
\r
753 text_right.Enabled = false;
\r
754 text_top.Enabled = false;
\r
755 text_bottom.Enabled = false;
\r
756 text_left.Text = "0";
\r
757 text_right.Text = "0";
\r
758 text_top.Text = "0";
\r
759 text_bottom.Text = "0";
\r
764 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
766 text_width.Text = "";
\r
767 text_height.Text = "";
\r
768 text_width.BackColor = Color.White;
\r
769 text_height.BackColor = Color.White;
\r
772 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
774 if (drp_dvdtitle.Items.Count == 1)
\r
776 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
780 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
783 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
785 drp_audioMixDown.Items.Clear();
\r
787 if (drp_audioCodec.Text == "AAC")
\r
789 drp_audioMixDown.Items.Clear();
\r
790 drp_audioMixDown.Items.Add("Mono");
\r
791 drp_audioMixDown.Items.Add("Stereo");
\r
792 drp_audioMixDown.Items.Add("Dolby Surround");
\r
793 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
794 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
796 drp_audioBitrate.Items.Clear();
\r
797 drp_audioBitrate.Items.Add("32");
\r
798 drp_audioBitrate.Items.Add("40");
\r
799 drp_audioBitrate.Items.Add("48");
\r
800 drp_audioBitrate.Items.Add("56");
\r
801 drp_audioBitrate.Items.Add("64");
\r
802 drp_audioBitrate.Items.Add("80");
\r
803 drp_audioBitrate.Items.Add("86");
\r
804 drp_audioBitrate.Items.Add("112");
\r
805 drp_audioBitrate.Items.Add("128");
\r
806 drp_audioBitrate.Items.Add("160");
\r
811 drp_audioMixDown.Items.Clear();
\r
812 drp_audioMixDown.Items.Add("Stereo");
\r
813 drp_audioMixDown.Items.Add("Dolby Surround");
\r
814 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
816 drp_audioBitrate.Items.Clear();
\r
817 drp_audioBitrate.Items.Add("32");
\r
818 drp_audioBitrate.Items.Add("40");
\r
819 drp_audioBitrate.Items.Add("48");
\r
820 drp_audioBitrate.Items.Add("56");
\r
821 drp_audioBitrate.Items.Add("64");
\r
822 drp_audioBitrate.Items.Add("80");
\r
823 drp_audioBitrate.Items.Add("86");
\r
824 drp_audioBitrate.Items.Add("112");
\r
825 drp_audioBitrate.Items.Add("128");
\r
826 drp_audioBitrate.Items.Add("160");
\r
827 drp_audioBitrate.Items.Add("192");
\r
828 drp_audioBitrate.Items.Add("224");
\r
829 drp_audioBitrate.Items.Add("256");
\r
830 drp_audioBitrate.Items.Add("320");
\r
831 drp_audioBitrate.Items.Add("384");
\r
835 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
837 if (drp_audioCodec.Text == "AAC")
\r
839 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
842 drp_audioBitrate.Items.Clear();
\r
843 drp_audioBitrate.Items.Add("32");
\r
844 drp_audioBitrate.Items.Add("40");
\r
845 drp_audioBitrate.Items.Add("48");
\r
846 drp_audioBitrate.Items.Add("56");
\r
847 drp_audioBitrate.Items.Add("64");
\r
848 drp_audioBitrate.Items.Add("80");
\r
849 drp_audioBitrate.Items.Add("86");
\r
850 drp_audioBitrate.Items.Add("112");
\r
851 drp_audioBitrate.Items.Add("128");
\r
852 drp_audioBitrate.Items.Add("160");
\r
853 drp_audioBitrate.Items.Add("192");
\r
854 drp_audioBitrate.Items.Add("224");
\r
855 drp_audioBitrate.Items.Add("256");
\r
856 drp_audioBitrate.Items.Add("320");
\r
857 drp_audioBitrate.Items.Add("384");
\r
862 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
864 if (Check_ChapterMarkers.Checked)
\r
866 string destination = text_destination.Text;
\r
867 destination = destination.Replace(".mp4", ".m4v");
\r
868 text_destination.Text = destination;
\r
872 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
874 if (!text_destination.Text.Contains(".mp4"))
\r
876 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
877 check_largeFile.CheckState = CheckState.Unchecked;
\r
881 private void check_turbo_CheckedChanged(object sender, EventArgs e)
\r
883 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
885 MessageBox.Show("This option is only compatible with the H.264 encoder's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
886 check_turbo.CheckState = CheckState.Unchecked;
\r
890 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
892 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
893 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
895 check_turbo.CheckState = CheckState.Unchecked;
\r
896 CheckCRF.CheckState = CheckState.Unchecked;
\r
900 private void CheckCRF_CheckedChanged(object sender, EventArgs e)
\r
902 if (slider_videoQuality.Value == 0)
\r
904 MessageBox.Show("This option is can only be used with the 'Video Quality' slider.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
905 CheckCRF.CheckState = CheckState.Unchecked;
\r
909 Parsing.DVD thisDVD;
\r
910 public void setStreamReader(Parsing.DVD dvd)
\r
912 this.thisDVD = dvd;
\r
915 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
917 // Reset some values on the form
\r
918 lbl_Aspect.Text = "Select a Title";
\r
919 lbl_RecomendedCrop.Text = "Select a Title";
\r
920 QueryEditorText.Text = "";
\r
922 // If the dropdown is set to automatic nothing else needs to be done.
\r
923 // Otheriwse if its not, title data has to be loased from parsing.
\r
924 if (drp_dvdtitle.Text != "Automatic")
\r
928 temp = drp_dvdtitle.Text.Split(' ');
\r
929 title = temp[0].Trim();
\r
931 int count = thisDVD.Titles.Count - 1;
\r
934 while (count >= counter)
\r
937 if (thisDVD.Titles[counter].TitleNumber.ToString() == title)
\r
939 lbl_Aspect.Text = thisDVD.Titles[counter].AspectRatio.ToString();
\r
940 lbl_RecomendedCrop.Text = thisDVD.Titles[counter].AutoCropDimensions[0] + "/" + thisDVD.Titles[counter].AutoCropDimensions[1] + "/" + thisDVD.Titles[counter].AutoCropDimensions[2] + "/" + thisDVD.Titles[counter].AutoCropDimensions[3];
\r
941 // Still need to set these up.
\r
942 MessageBox.Show(thisDVD.Titles[counter].AudioTracks[0].ToString());
\r
943 MessageBox.Show(thisDVD.Titles[counter].Chapters.ToString());
\r
944 MessageBox.Show(thisDVD.Titles[counter].Subtitles.ToString());
\r
955 // The Query Generation Function
\r
959 // This function was imported from old vb.net version of this application.
\r
960 // It could probably do with being cleaned up a good deal at some point
\r
961 public string GenerateTheQuery()
\r
963 string source = text_source.Text;
\r
964 string dvdTitle = drp_dvdtitle.Text;
\r
965 string chapterStart = drop_chapterStart.Text;
\r
966 string chapterFinish = drop_chapterFinish.Text;
\r
967 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
968 string dvdChapter = "";
\r
971 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
974 source = " -i " + '"' + source+ '"'; //'"'+
\r
977 if (dvdTitle == "Automatic")
\r
981 string[] titleInfo = dvdTitle.Split(' ');
\r
982 dvdTitle = " -t "+ titleInfo[0];
\r
985 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
987 else if (chapterFinish == chapterStart)
\r
988 dvdChapter = " -c " + chapterStart;
\r
990 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
992 string querySource = source+ dvdTitle+ dvdChapter;
\r
993 // ----------------------------------------------------------------------
\r
997 string destination = text_destination.Text;
\r
998 string videoEncoder = drp_videoEncoder.Text;
\r
999 string audioEncoder = drp_audioCodec.Text;
\r
1000 string width = text_width.Text;
\r
1001 string height = text_height.Text;
\r
1003 if (destination == "")
\r
1004 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1006 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1009 switch (videoEncoder)
\r
1012 videoEncoder = " -e ffmpeg";
\r
1015 videoEncoder = " -e xvid";
\r
1018 videoEncoder = " -e x264";
\r
1020 case "H.264 Baseline 1.3":
\r
1021 videoEncoder = " -e x264b13";
\r
1023 case "H.264 (iPod)":
\r
1024 videoEncoder = " -e x264b30";
\r
1027 videoEncoder = " -e x264";
\r
1031 switch (audioEncoder)
\r
1034 audioEncoder = " -E faac";
\r
1037 audioEncoder = " -E lame";
\r
1040 audioEncoder = " -E vorbis";
\r
1043 audioEncoder = " -E ac3";
\r
1046 audioEncoder = " -E faac";
\r
1051 width = " -w "+ width;
\r
1055 height = " -l "+ height;
\r
1058 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1059 // ----------------------------------------------------------------------
\r
1061 // Picture Settings Tab
\r
1063 string cropSetting = drp_crop.Text;
\r
1064 string cropTop = text_top.Text;
\r
1065 string cropBottom = text_bottom.Text;
\r
1066 string cropLeft = text_left.Text;
\r
1067 string cropRight = text_right.Text;
\r
1068 string subtitles = drp_subtitle.Text;
\r
1069 string cropOut = "";
\r
1070 // Returns Crop Query
\r
1072 if (cropSetting == "Auto Crop")
\r
1074 else if (cropSetting == "No Crop")
\r
1075 cropOut = " --crop 0:0:0:0 ";
\r
1077 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1079 if (subtitles == "None")
\r
1081 else if (subtitles == "")
\r
1086 tempSub = subtitles.Split(' ');
\r
1087 subtitles = " -s "+ tempSub[0];
\r
1090 string queryPictureSettings = cropOut+ subtitles;
\r
1091 // ----------------------------------------------------------------------
\r
1093 // Video Settings Tab
\r
1095 string videoBitrate = text_bitrate.Text;
\r
1096 string videoFilesize = text_filesize.Text;
\r
1097 int videoQuality = slider_videoQuality.Value;
\r
1098 string vidQSetting = "";
\r
1099 string twoPassEncoding = "";
\r
1100 string deinterlace = "";
\r
1101 string grayscale = "";
\r
1102 string videoFramerate = drp_videoFramerate.Text;
\r
1103 string pixelRatio = "";
\r
1104 string ChapterMarkers = "";
\r
1105 string turboH264 = "";
\r
1106 string largeFile = "";
\r
1108 if (videoBitrate != "")
\r
1109 videoBitrate = " -b "+ videoBitrate;
\r
1111 if (videoFilesize != "")
\r
1112 videoFilesize = " -S "+ videoFilesize;
\r
1114 // Video Quality Setting
\r
1116 if ((videoQuality == 0))
\r
1120 videoQuality = videoQuality/ 100;
\r
1121 if (videoQuality == 1)
\r
1123 vidQSetting = "1.0";
\r
1126 vidQSetting = " -q " + videoQuality.ToString();
\r
1129 if (check_2PassEncode.Checked)
\r
1130 twoPassEncoding = " -2 ";
\r
1132 if (check_DeInterlace.Checked)
\r
1133 deinterlace = " -d ";
\r
1135 if (check_grayscale.Checked)
\r
1136 grayscale = " -g ";
\r
1138 if (videoFramerate == "Automatic")
\r
1139 videoFramerate = "";
\r
1141 videoFramerate = " -r "+ videoFramerate;
\r
1143 if (CheckPixelRatio.Checked)
\r
1144 pixelRatio = " -p ";
\r
1146 if (Check_ChapterMarkers.Checked)
\r
1147 ChapterMarkers = " -m ";
\r
1149 if (check_turbo.Checked)
\r
1150 turboH264 = " -T ";
\r
1152 if (check_largeFile.Checked)
\r
1153 largeFile = " -4 ";
\r
1155 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile;
\r
1156 // ----------------------------------------------------------------------
\r
1158 // Audio Settings Tab
\r
1160 string audioBitrate = drp_audioBitrate.Text;
\r
1161 string audioSampleRate = drp_audioSampleRate.Text;
\r
1162 string audioChannels = drp_audioChannels.Text;
\r
1163 string Mixdown = drp_audioMixDown.Text;
\r
1164 string SixChannelAudio = "";
\r
1166 if (audioBitrate != "")
\r
1167 audioBitrate = " -B "+ audioBitrate;
\r
1169 if (audioSampleRate != "")
\r
1170 audioSampleRate = " -R "+ audioSampleRate;
\r
1172 if (audioChannels == "Automatic")
\r
1173 audioChannels = "";
\r
1174 else if (audioChannels == "")
\r
1175 audioChannels = "";
\r
1179 tempSub = audioChannels.Split(' ');
\r
1180 audioChannels = " -a "+ tempSub[0];
\r
1192 Mixdown = "stereo";
\r
1194 case "Dolby Surround":
\r
1197 case "Dolby Pro Logic II":
\r
1200 case "6 Channel Discrete":
\r
1204 Mixdown = "stero";
\r
1208 if (Mixdown != "")
\r
1209 SixChannelAudio = " -6 "+ Mixdown;
\r
1211 SixChannelAudio = "";
\r
1213 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1214 // ----------------------------------------------------------------------
\r
1218 string CRF = CheckCRF.CheckState.ToString();
\r
1219 string h264Advanced = rtf_h264advanced.Text;
\r
1225 if ((h264Advanced == ""))
\r
1226 h264Advanced = "";
\r
1228 h264Advanced = " -x "+ h264Advanced;
\r
1231 string h264Settings = CRF+ h264Advanced;
\r
1232 // ----------------------------------------------------------------------
\r
1234 // Processors (Program Settings)
\r
1236 string processors = Properties.Settings.Default.Processors;
\r
1237 // Number of Processors Handler
\r
1239 if (processors == "Automatic")
\r
1242 processors = " -C "+ processors+ " ";
\r
1245 string queryAdvancedSettings = processors;
\r
1246 // ----------------------------------------------------------------------
\r
1248 // Verbose option (Program Settings)
\r
1250 string verbose = "";
\r
1251 if (Properties.Settings.Default.verbose == "1")
\r
1254 // ----------------------------------------------------------------------
\r
1256 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1259 // This is the END of the road ------------------------------------------------------------------------------
\r