OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmMain.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Collections.Specialized;\r
4 using System.ComponentModel;\r
5 using System.Data;\r
6 using System.Drawing;\r
7 using System.Text;\r
8 using System.Windows.Forms;\r
9 using System.Net;\r
10 using System.IO;\r
11 using System.Diagnostics;\r
12 using System.Threading;\r
13 using System.Runtime.InteropServices;\r
14 using System.Globalization;\r
15 using System.Text.RegularExpressions;\r
16 \r
17 \r
18 namespace Handbrake\r
19 {\r
20     public partial class frmMain : Form\r
21     {\r
22         // -------------------------------------------------------------- \r
23         // Applicaiton Startup Stuff\r
24         // --------------------------------------------------------------\r
25 \r
26         #region Application Startup\r
27 \r
28         // Some stuff that needs to be Initialized. \r
29         private Process hbProc;\r
30         private Parsing.DVD thisDVD;\r
31         private frmQueue queueWindow = new frmQueue();\r
32 \r
33         // The main window beings here...\r
34         public frmMain()\r
35         {\r
36             // Load the splash screen in this thread\r
37             Form splash = new frmSplashScreen();\r
38             splash.Show();\r
39 \r
40             //Create a label that can be updated from the parent thread.\r
41             Label lblStatus = new Label();\r
42 \r
43             //Size the label\r
44             lblStatus.Size = new Size(250, 20);\r
45 \r
46             //Position the label\r
47             lblStatus.Location = new Point(10, 280);\r
48 \r
49             //Put the label on the splash form\r
50             splash.Controls.Add(lblStatus);\r
51 \r
52             //Fire a thread to wait for 2 seconds.  The splash screen will exit when the time expires\r
53             Thread timer = new Thread(splashTimer);\r
54             timer.Start();\r
55 \r
56             InitializeComponent();\r
57 \r
58             // show the form, but leave disabled until preloading is complete\r
59             this.Enabled = false;\r
60 \r
61             // Show the main form\r
62             this.Show();\r
63 \r
64             // Forces frmMain to draw\r
65             Application.DoEvents();\r
66 \r
67             // Set the Version number lable to the corect version.\r
68             Version.Text = "Version " + Properties.Settings.Default.CliVersion;\r
69 \r
70             // update the status\r
71             lblStatus.Text = "Checking for updates ...";\r
72             // redraw the splash screen\r
73             Application.DoEvents();\r
74             // Run the update checker.\r
75             updateCheck();\r
76             Thread.Sleep(200);\r
77 \r
78             // Update the presets\r
79             lblStatus.Text = "Updaing Presets ...";\r
80             Application.DoEvents();\r
81             updatePresets();\r
82             Thread.Sleep(200);\r
83 \r
84             // Now load the users default if required. (Will overide the above setting)\r
85             lblStatus.Text = "Loading User Default Settings...";\r
86             Application.DoEvents();\r
87             loadNormalPreset();\r
88             loadUserDefaults();\r
89             Thread.Sleep(100);\r
90 \r
91             // Enable or disable tooltips\r
92             lblStatus.Text = "Loading Tooltips ...";\r
93             Application.DoEvents();\r
94             tooltip();\r
95             Thread.Sleep(100);\r
96 \r
97             // Hide the preset bar if required.\r
98             hidePresetBar();\r
99 \r
100             //Finished Loading\r
101             lblStatus.Text = "Loading Complete!";\r
102             Application.DoEvents();\r
103             Thread.Sleep(200);\r
104 \r
105             // Wait until splash screen is done\r
106             while (timer.IsAlive)\r
107             { Thread.Sleep(100); }\r
108 \r
109             //Close the splash screen\r
110             splash.Close();\r
111             splash.Dispose();\r
112 \r
113             // Turn the interface back to the user\r
114             this.Enabled = true;\r
115         }\r
116 \r
117         private void splashTimer(object sender)\r
118         {\r
119             Thread.Sleep(2000);  //sit for 2 seconds then exit\r
120         }\r
121 \r
122         private void showSplash(object sender)\r
123         {\r
124             // Display splash screen for 1.5 Seconds\r
125             Form splash = new frmSplashScreen();\r
126             splash.Show();\r
127             Thread.Sleep(1500);\r
128             splash.Close(); // Then close.\r
129         }\r
130 \r
131         private void loadNormalPreset()\r
132         {\r
133             ListViewItem item = listview_presets.FindItemWithText("Normal");\r
134 \r
135             if (item != null)\r
136             {\r
137                 listview_presets.SelectedItems.Clear();\r
138                 item.Selected = true;\r
139             }\r
140         }\r
141 \r
142         private void loadUserDefaults()\r
143         {\r
144             try\r
145             {\r
146                 // Load the users default settings or if the user has not got this option enabled, load the normal preset.\r
147                 if (Properties.Settings.Default.defaultSettings == "Checked")\r
148                 {\r
149                     // Source\r
150                     text_source.Text = Properties.Settings.Default.DVDSource;\r
151                     drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;\r
152                     drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;\r
153                     drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;\r
154 \r
155                     // Destination\r
156                     text_destination.Text = Properties.Settings.Default.VideoDest;\r
157                     drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;\r
158                     drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;\r
159                     text_width.Text = Properties.Settings.Default.Width;\r
160                     text_height.Text = Properties.Settings.Default.Height;\r
161 \r
162                     // Picture Settings Tab\r
163                     drp_crop.Text = Properties.Settings.Default.CroppingOption;\r
164                     text_top.Text = Properties.Settings.Default.CropTop;\r
165                     text_bottom.Text = Properties.Settings.Default.CropBottom;\r
166                     text_left.Text = Properties.Settings.Default.CropLeft;\r
167                     text_right.Text = Properties.Settings.Default.CropRight;\r
168                     drp_subtitle.Text = Properties.Settings.Default.Subtitles;\r
169 \r
170                     // Video Settings Tab\r
171                     text_bitrate.Text = Properties.Settings.Default.VideoBitrate;\r
172                     text_filesize.Text = Properties.Settings.Default.VideoFilesize;\r
173                     slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;\r
174 \r
175                     if (Properties.Settings.Default.TwoPass == "Checked")\r
176                     {\r
177                         check_2PassEncode.CheckState = CheckState.Checked;\r
178                     }\r
179 \r
180                     drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;\r
181                     drp_deNoise.Text = Properties.Settings.Default.denoise;\r
182 \r
183                     if (Properties.Settings.Default.detelecine == "Checked")\r
184                     {\r
185                         check_detelecine.CheckState = CheckState.Checked;\r
186                     }\r
187 \r
188                     if (Properties.Settings.Default.detelecine == "Checked")\r
189                     {\r
190                         check_deblock.CheckState = CheckState.Checked;\r
191                     }\r
192 \r
193 \r
194                     if (Properties.Settings.Default.Grayscale == "Checked")\r
195                     {\r
196                         check_grayscale.CheckState = CheckState.Checked;\r
197                     }\r
198 \r
199                     drp_videoFramerate.Text = Properties.Settings.Default.Framerate;\r
200 \r
201                     if (Properties.Settings.Default.PixelRatio == "Checked")\r
202                     {\r
203                         CheckPixelRatio.CheckState = CheckState.Checked;\r
204                     }\r
205                     if (Properties.Settings.Default.turboFirstPass == "Checked")\r
206                     {\r
207                         check_turbo.CheckState = CheckState.Checked;\r
208                     }\r
209                     if (Properties.Settings.Default.largeFile == "Checked")\r
210                     {\r
211                         check_largeFile.CheckState = CheckState.Checked;\r
212                     }\r
213 \r
214                     if (Properties.Settings.Default.chapterMarker == "Checked")\r
215                     {\r
216                         Check_ChapterMarkers.CheckState = CheckState.Checked;\r
217                     }\r
218 \r
219                     // Audio Settings Tab\r
220                     drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;\r
221                     drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;\r
222                     drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;\r
223 \r
224                     // H264 Tab\r
225                     if (Properties.Settings.Default.CRF == "Checked")\r
226                     {\r
227                         CheckCRF.CheckState = CheckState.Checked;\r
228                     }\r
229                     rtf_h264advanced.Text = Properties.Settings.Default.H264;\r
230 \r
231                     groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.selectedPreset + ")";\r
232                 }\r
233             }\r
234             catch (Exception)\r
235             {\r
236                 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.\r
237             }\r
238         }\r
239 \r
240         private Boolean updateCheck()\r
241         {\r
242             try\r
243             {\r
244                 if (Properties.Settings.Default.updateStatus == "Checked")\r
245                 {\r
246                     String updateFile = Properties.Settings.Default.updateFile;\r
247                     WebClient client = new WebClient();\r
248                     String data = client.DownloadString(updateFile);\r
249                     String[] versionData = data.Split('\n');\r
250 \r
251                     int verdata = int.Parse(versionData[0].Replace(".", ""));\r
252                     int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));\r
253                     int verd1 = int.Parse(versionData[1].Replace(".", ""));\r
254                     int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));\r
255 \r
256                     Boolean update = ((verdata > vergui) || (verd1 > cliversion));\r
257 \r
258                     lbl_update.Visible = update;\r
259 \r
260                     return update;\r
261                 }\r
262                 else\r
263                 {\r
264                     return false;\r
265                 }\r
266             }\r
267             catch (Exception)\r
268             {\r
269                 // Silently ignore the error\r
270                 return false;\r
271             }\r
272         }\r
273 \r
274         private void tooltip()\r
275         {\r
276             if (Properties.Settings.Default.tooltipEnable == "Checked")\r
277             {\r
278                 ToolTip.Active = true;\r
279             }\r
280         }\r
281 \r
282         private void hidePresetBar()\r
283         {\r
284             if (Properties.Settings.Default.hidePresets == "Checked")\r
285             {\r
286                 btn_presets.Visible = true;\r
287                 this.Width = 591;\r
288             }\r
289 \r
290         }\r
291 \r
292         #endregion\r
293 \r
294         // -------------------------------------------------------------- \r
295         // The main Menu bar.\r
296         // -------------------------------------------------------------- \r
297 \r
298         #region File Menu\r
299         private void mnu_open_Click(object sender, EventArgs e)\r
300         {\r
301             string filename;\r
302             File_Open.ShowDialog();\r
303             filename = File_Open.FileName;\r
304 \r
305             if (filename != "")\r
306             {\r
307                 try\r
308                 {\r
309                     // Some things that need to be done to reset some gui components:\r
310                     CheckPixelRatio.CheckState = CheckState.Unchecked;\r
311 \r
312                     //---------------------------\r
313                     // Get the Preset\r
314                     // ---------------------------\r
315 \r
316                     // Create StreamReader & open file\r
317                     StreamReader line = new StreamReader(filename);\r
318 \r
319                     // Send the query from the file to the Query Parser class\r
320                     Functions.QueryParser presetQuery = Functions.QueryParser.Parse(line.ReadLine());\r
321 \r
322                     // Now load the preset\r
323                     presetLoader(presetQuery, filename);\r
324 \r
325                     // Close the stream\r
326                     line.Close();\r
327                 }\r
328                 catch (Exception exc)\r
329                 {\r
330                     MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
331                     MessageBox.Show(exc.ToString());\r
332                 }\r
333             }\r
334         }\r
335 \r
336         private void mnu_save_Click(object sender, EventArgs e)\r
337         {\r
338             string filename;\r
339             File_Save.ShowDialog();\r
340             filename = File_Save.FileName;\r
341             if (filename != "")\r
342             {\r
343                 try\r
344                 {\r
345                     // Create a StreamWriter and open the file\r
346                     StreamWriter line = new StreamWriter(filename);\r
347 \r
348                     // Generate and write the query string to the file\r
349                     String query = GenerateTheQuery();\r
350                     line.WriteLine(query);\r
351 \r
352                     // close the stream\r
353                     line.Close();\r
354                     MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
355                 }\r
356                 catch (Exception)\r
357                 {\r
358                     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
359                 }\r
360 \r
361             }\r
362         }\r
363 \r
364         private void mnu_exit_Click(object sender, EventArgs e)\r
365         {\r
366             Application.Exit();\r
367         }\r
368 \r
369         #endregion\r
370 \r
371         #region Tools Menu\r
372 \r
373         private void mnu_encode_Click(object sender, EventArgs e)\r
374         {\r
375             showQueue();\r
376         }\r
377 \r
378         private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
379         {\r
380             frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
381             dvdInfoWindow.Show();\r
382         }\r
383 \r
384         private void mnu_options_Click(object sender, EventArgs e)\r
385         {\r
386             Form Options = new frmOptions();\r
387             Options.ShowDialog();\r
388         }\r
389 \r
390         #endregion\r
391 \r
392         #region Presets Menu\r
393 \r
394         private void mnu_presetReset_Click(object sender, EventArgs e)\r
395         {\r
396             listview_presets.Items.Clear();\r
397             updatePresets();\r
398             MessageBox.Show("Presets have been updated", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
399         }\r
400 \r
401         private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
402         {\r
403             ListViewItem item = listview_presets.FindItemWithText("Normal");\r
404 \r
405             if (item != null)\r
406             {\r
407                 listview_presets.SelectedItems.Clear();\r
408                 item.Selected = true;\r
409             }\r
410 \r
411             if (presetStatus == false)\r
412             {\r
413                 this.Width = 881;\r
414                 presetStatus = true;\r
415                 btn_presets.Text = "Hide Presets";\r
416             }\r
417         }\r
418 \r
419         #endregion\r
420 \r
421         #region Help Menu\r
422 \r
423 \r
424         private void mnu_quickStart_Click(object sender, EventArgs e)\r
425         {\r
426             Form QuickStart = new frmQuickStart();\r
427             QuickStart.ShowDialog();\r
428         }\r
429 \r
430         private void mnu_wiki_Click(object sender, EventArgs e)\r
431         {\r
432             Process.Start("http://handbrake.m0k.org/trac");\r
433         }\r
434 \r
435         private void mnu_faq_Click(object sender, EventArgs e)\r
436         {\r
437             Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");\r
438         }\r
439 \r
440         private void mnu_onlineDocs_Click(object sender, EventArgs e)\r
441         {\r
442             Process.Start("http://handbrake.m0k.org/?page_id=11");\r
443         }\r
444 \r
445         private void mnu_homepage_Click(object sender, EventArgs e)\r
446         {\r
447             Process.Start("http://handbrake.m0k.org");\r
448         }\r
449 \r
450         private void mnu_forum_Click(object sender, EventArgs e)\r
451         {\r
452             Process.Start("http://handbrake.m0k.org/forum");\r
453         }\r
454 \r
455         private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
456         {\r
457             Boolean update = updateCheck();\r
458             if (update == true)\r
459             {\r
460                 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
461             }\r
462             else\r
463             {\r
464                 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
465             }\r
466         }\r
467 \r
468         private void mnu_about_Click(object sender, EventArgs e)\r
469         {\r
470             Form About = new frmAbout();\r
471             About.ShowDialog();\r
472         }\r
473 \r
474         #endregion\r
475 \r
476         // -------------------------------------------------------------- \r
477         // Buttons on the main Window\r
478         // --------------------------------------------------------------\r
479 \r
480         #region Buttons\r
481 \r
482         private void btn_Browse_Click(object sender, EventArgs e)\r
483         {\r
484             String filename = "";\r
485             text_source.Text = "";\r
486             frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
487 \r
488             if (RadioDVD.Checked)\r
489             {\r
490                 DVD_Open.ShowDialog();\r
491                 filename = DVD_Open.SelectedPath;\r
492                 if (filename != "")\r
493                 {\r
494                     Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);\r
495                     text_source.Text = filename;\r
496                     frmRD.ShowDialog();\r
497                 }\r
498             }\r
499             else\r
500             {\r
501                 ISO_Open.ShowDialog();\r
502                 filename = ISO_Open.FileName;\r
503                 if (filename != "")\r
504                 {\r
505                     Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);\r
506                     text_source.Text = filename;\r
507                     frmRD.ShowDialog();\r
508                 }\r
509             }\r
510 \r
511             // Check if there was titles in the dvd title dropdown \r
512             if (filename == "")\r
513             {\r
514                 text_source.Text = "Click 'Browse' to continue";\r
515             }\r
516 \r
517             // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.\r
518             if (drp_dvdtitle.Items.Count == 0)\r
519             {\r
520                 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
521             }\r
522         }\r
523 \r
524         private void btn_destBrowse_Click(object sender, EventArgs e)\r
525         {\r
526             // This removes the file extension from the filename box on the save file dialog.\r
527             // It's daft but some users don't realise that typing an extension overrides the dropdown extension selected.\r
528             // Should be a nicer way to do this.\r
529             DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "").Replace(".ogm", "").Replace(".avi", "");\r
530 \r
531             // Show the dialog and set the main form file path\r
532             DVD_Save.ShowDialog();\r
533             text_destination.Text = DVD_Save.FileName;\r
534 \r
535             // Quicktime requires .m4v file for chapter markers to work. If checked, change the extension to .m4v (mp4 and m4v are the same thing)\r
536             if (Check_ChapterMarkers.Checked)\r
537             {\r
538                 string destination = text_destination.Text;\r
539                 destination = destination.Replace(".mp4", ".m4v");\r
540                 text_destination.Text = destination;\r
541             }\r
542         }\r
543 \r
544         private void btn_h264Clear_Click(object sender, EventArgs e)\r
545         {\r
546             rtf_h264advanced.Text = "";\r
547         }\r
548 \r
549         private void GenerateQuery_Click(object sender, EventArgs e)\r
550         {\r
551             String query = GenerateTheQuery();\r
552             QueryEditorText.Text = query;\r
553         }\r
554 \r
555         private void btn_ClearQuery_Click(object sender, EventArgs e)\r
556         {\r
557             QueryEditorText.Text = "";\r
558         }\r
559 \r
560         private void btn_queue_Click(object sender, EventArgs e)\r
561         {\r
562 \r
563             if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")\r
564                 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
565             else\r
566             {\r
567                 string query;\r
568                 if (QueryEditorText.Text == "")\r
569                 {\r
570                     query = GenerateTheQuery();\r
571                 }\r
572                 else\r
573                 {\r
574                     query = QueryEditorText.Text;\r
575                 }\r
576                 queueWindow.list_queue.Items.Add(query);\r
577                 queueWindow.Show();\r
578             }\r
579         }\r
580 \r
581         private void btn_copy_Click(object sender, EventArgs e)\r
582         {\r
583             if (QueryEditorText.Text != "")\r
584                 Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);\r
585         }\r
586 \r
587         private void showQueue()\r
588         {\r
589             queueWindow.Show();\r
590         }\r
591 \r
592         #endregion\r
593 \r
594         // -------------------------------------------------------------- \r
595         // Main Window Preset System\r
596         // --------------------------------------------------------------\r
597 \r
598         #region Preset System\r
599 \r
600         // Import Current Presets\r
601         private void updatePresets()\r
602         {\r
603             string[] presets = new string[17];\r
604             presets[0] = "Animation";\r
605             presets[1] = "AppleTV";\r
606             presets[2] = "Bedlam";\r
607             presets[3] = "Blind";\r
608             presets[4] = "Broke";\r
609             presets[5] = "Classic";\r
610             presets[6] = "Constant Quality Rate";\r
611             presets[7] = "Deux Six Quatre";\r
612             presets[8] = "Film";\r
613             presets[9] = "iPhone / iPod Touch";\r
614             presets[10] = "iPod High-Rez";\r
615             presets[11] = "iPod Low-Rez";\r
616             presets[12] = "Normal";\r
617             presets[13] = "PS3";\r
618             presets[14] = "PSP";\r
619             presets[15] = "QuickTime";\r
620             presets[16] = "Television";\r
621 \r
622             ListViewItem preset_listview = new ListViewItem();\r
623             string[] presetList = new string[1];\r
624 \r
625             foreach (string preset in presets)\r
626             {\r
627                 presetList[0] = preset;\r
628                 preset_listview = new ListViewItem(presetList);\r
629 \r
630                 // Now Fill Out List View with Items\r
631                 listview_presets.Items.Add(preset_listview);\r
632             }\r
633 \r
634             string appPath = Application.StartupPath.ToString() + "\\";\r
635             string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " --preset-list >" + '"' + appPath + "presets.dat" + '"' + " 2>&1" + '"';\r
636             Process hbproc = Process.Start("CMD.exe", strCmdLine);\r
637             hbproc.WaitForExit();\r
638             hbproc.Dispose();\r
639             hbproc.Close();\r
640 \r
641         }\r
642 \r
643         // Varibles\r
644         private Boolean presetStatus = false;\r
645 \r
646         // Buttons\r
647         private void btn_presets_Click(object sender, EventArgs e)\r
648         {\r
649             if (presetStatus == false)\r
650             {\r
651                 this.Width = 881;\r
652                 presetStatus = true;\r
653                 btn_presets.Text = "Hide Presets";\r
654             }\r
655             else\r
656             {\r
657                 this.Width = 590;\r
658                 presetStatus = false;\r
659                 btn_presets.Text = "Show Presets";\r
660             }\r
661 \r
662         }\r
663 \r
664         private void btn_setDefault_Click(object sender, EventArgs e)\r
665         {\r
666             //Source\r
667             Properties.Settings.Default.DVDSource = text_source.Text;\r
668             Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;\r
669             Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;\r
670             Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;\r
671             //Destination\r
672             Properties.Settings.Default.VideoDest = text_destination.Text;\r
673             Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;\r
674             Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;\r
675             Properties.Settings.Default.Width = text_width.Text;\r
676             Properties.Settings.Default.Height = text_height.Text;\r
677             //Picture Settings Tab\r
678             Properties.Settings.Default.CroppingOption = drp_crop.Text;\r
679             Properties.Settings.Default.CropTop = text_top.Text;\r
680             Properties.Settings.Default.CropBottom = text_bottom.Text;\r
681             Properties.Settings.Default.CropLeft = text_left.Text;\r
682             Properties.Settings.Default.CropRight = text_right.Text;\r
683             Properties.Settings.Default.Subtitles = drp_subtitle.Text;\r
684             //Video Settings Tab\r
685             Properties.Settings.Default.VideoBitrate = text_bitrate.Text;\r
686             Properties.Settings.Default.VideoFilesize = text_filesize.Text;\r
687             Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;\r
688             Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();\r
689             Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;\r
690             Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();\r
691             Properties.Settings.Default.Framerate = drp_videoFramerate.Text;\r
692             Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();\r
693             Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();\r
694             Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();\r
695             Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();\r
696             Properties.Settings.Default.denoise = drp_deNoise.Text;\r
697             Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();\r
698             Properties.Settings.Default.chapterMarker = Check_ChapterMarkers.CheckState.ToString();\r
699             //Audio Settings Tab\r
700             Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;\r
701             Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;\r
702             Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;\r
703             //H264 Tab\r
704             Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();\r
705             Properties.Settings.Default.H264 = rtf_h264advanced.Text;\r
706             //Preset\r
707             Properties.Settings.Default.selectedPreset = groupBox_output.Text.Replace("Output Settings (Preset: ", "").Replace("\"", "").Replace(")", "");\r
708             // Save the new default Settings\r
709             Properties.Settings.Default.Save();\r
710             MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
711         }\r
712 \r
713         // Preset Selection\r
714         private void listview_presets_SelectedIndexChanged(object sender, EventArgs e)\r
715         {\r
716 \r
717             string selectedPreset = null;\r
718             ListView.SelectedListViewItemCollection name = null;\r
719             name = listview_presets.SelectedItems;\r
720 \r
721             if (listview_presets.SelectedItems.Count != 0)\r
722                 selectedPreset = name[0].SubItems[0].Text;\r
723 \r
724             try\r
725             {\r
726                 string appPath = Application.StartupPath.ToString() + "\\";\r
727                 StreamReader presetInput = new StreamReader(appPath + "presets.dat");\r
728 \r
729                 while (!presetInput.EndOfStream)\r
730                 {\r
731                     if ((char)presetInput.Peek() == '+')\r
732                     {\r
733                         string preset = presetInput.ReadLine().Replace("+ ", "");\r
734                         Regex r = new Regex("(:  )"); // Split on hyphens. \r
735                         string[] presetName = r.Split(preset);\r
736 \r
737                         if (selectedPreset == "iPhone / iPod Touch")\r
738                         {\r
739                             selectedPreset = "iPhone";\r
740                         }\r
741 \r
742                         if (selectedPreset == presetName[0])\r
743                         {\r
744                             // Need to disable anamorphic now, otherwise it may overide the width / height values later.\r
745                             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
746 \r
747                             // Send the query from the file to the Query Parser class\r
748                             Functions.QueryParser presetQuery = Functions.QueryParser.Parse(preset);\r
749 \r
750                             // Now load the preset\r
751                             presetLoader(presetQuery, selectedPreset);\r
752                         }\r
753                         \r
754                     }\r
755                     else\r
756                     {\r
757                         presetInput.ReadLine();\r
758                     }\r
759                 }\r
760             }\r
761             catch (Exception exc)\r
762             {\r
763                 MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
764             }\r
765 \r
766            \r
767         }\r
768         #endregion\r
769 \r
770         //---------------------------------------------------\r
771         // Encode / Cancel Buttons\r
772         // Encode Progress Text Handler\r
773         //---------------------------------------------------\r
774 \r
775         #region Encode/CLI\r
776 \r
777         Functions.CLI process = new Functions.CLI();\r
778 \r
779         private void btn_encode_Click(object sender, EventArgs e)\r
780         {\r
781             if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")\r
782                 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
783             else\r
784             {\r
785                 btn_eCancel.Enabled = true;\r
786                 String query = "";\r
787                 if (QueryEditorText.Text == "")\r
788                 {\r
789                     query = GenerateTheQuery();\r
790                 }\r
791                 else\r
792                 {\r
793                     query = QueryEditorText.Text;\r
794                 }\r
795 \r
796                 ThreadPool.QueueUserWorkItem(procMonitor, query);\r
797                 lbl_encode.Visible = true;\r
798                 lbl_encode.Text = "Encoding in Progress";\r
799             }\r
800         }\r
801 \r
802         private void btn_eCancel_Click(object sender, EventArgs e)\r
803         {\r
804             process.killCLI();\r
805             process.setNull();\r
806             lbl_encode.Text = "Encoding Canceled";\r
807         }\r
808 \r
809         [DllImport("user32.dll")]\r
810         public static extern void LockWorkStation();\r
811         [DllImport("user32.dll")]\r
812         public static extern int ExitWindowsEx(int uFlags, int dwReason);\r
813 \r
814         private void procMonitor(object state)\r
815         {\r
816             // Make sure we are not already encoding and if we are then display an error.\r
817             if (hbProc != null)\r
818             {\r
819                 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
820             }\r
821             else\r
822             {\r
823                 hbProc = process.runCli(this, (string)state, false, false, false, false);\r
824                 hbProc.WaitForExit();\r
825 \r
826                 try\r
827                 {\r
828                     /*\r
829                     //*****************************************************************************************\r
830                     // BUG!\r
831                     // When the below code is used and standard error is set to true, hbcli is outputing a\r
832                     // video stream which has mild corruption issues every few seconds.\r
833                     // Maybe an issue with the Parser cauing the CLI to hickup/pause?\r
834                     //*****************************************************************************************\r
835 \r
836                     \r
837                     Parsing.Parser encode = new Parsing.Parser(hbProc.StandardOutput.BaseStream);\r
838                     encode.OnEncodeProgress += encode_OnEncodeProgress;\r
839                     while (!encode.EndOfStream)\r
840                     {\r
841                         encode.ReadLine();\r
842                     }\r
843 \r
844                     hbProc.WaitForExit();\r
845                     process.closeCLI();\r
846                      */\r
847 \r
848                 }\r
849                 catch (Exception exc)\r
850                 {\r
851                     // Do nothing\r
852                     MessageBox.Show(exc.ToString());\r
853                 }\r
854 \r
855 \r
856                 setEncodeLabel();\r
857                 hbProc = null;\r
858 \r
859                 // Do something whent he encode ends.\r
860                 switch (Properties.Settings.Default.CompletionOption)\r
861                 {\r
862                     case "Shutdown":\r
863                         System.Diagnostics.Process.Start("Shutdown", "-s -t 60");\r
864                         break;\r
865                     case "Log Off":\r
866                         ExitWindowsEx(0, 0);\r
867                         break;\r
868                     case "Suspend":\r
869                         Application.SetSuspendState(PowerState.Suspend, true, true);\r
870                         break;\r
871                     case "Hibernate":\r
872                         Application.SetSuspendState(PowerState.Hibernate, true, true);\r
873                         break;\r
874                     case "Lock System":\r
875                         LockWorkStation();\r
876                         break;\r
877                     case "Quit HandBrake":\r
878                         Application.Exit();\r
879                         break;\r
880                     default:\r
881                         break;\r
882                 }\r
883             }\r
884         }\r
885 \r
886         private delegate void UpdateUIHandler();\r
887 \r
888         private void setEncodeLabel()\r
889         {\r
890             if (this.InvokeRequired)\r
891             {\r
892                 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));\r
893                 return;\r
894             }\r
895             lbl_encode.Text = "Encoding Finished";\r
896         }\r
897 \r
898         private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
899         {\r
900 \r
901             if (this.InvokeRequired)\r
902             {\r
903                 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),\r
904                     new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
905                 return;\r
906             }\r
907             lbl_encode.Text = string.Format("Encode Progress: {0}%,       FPS: {1},       Avg FPS: {2},       Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);\r
908         }\r
909 \r
910         #endregion\r
911 \r
912         //---------------------------------------------------\r
913         //  Items that require actions on frmMain\r
914         //---------------------------------------------------\r
915 \r
916         #region frmMain Actions\r
917 \r
918         private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
919         {\r
920             drop_chapterStart.BackColor = Color.White;\r
921             QueryEditorText.Text = "";\r
922             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
923             {\r
924                 try\r
925                 {\r
926                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
927                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
928 \r
929                     if (chapterFinish < chapterStart)\r
930                     {\r
931                         drop_chapterStart.BackColor = Color.LightCoral;\r
932                     }\r
933                 }\r
934                 catch (Exception)\r
935                 {\r
936                     drop_chapterStart.BackColor = Color.LightCoral;\r
937                 }\r
938             }\r
939 \r
940 \r
941         }\r
942 \r
943         private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
944         {\r
945             drop_chapterFinish.BackColor = Color.White;\r
946             QueryEditorText.Text = "";\r
947             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
948             {\r
949                 try\r
950                 {\r
951                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
952                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
953 \r
954                     if (chapterFinish < chapterStart)\r
955                     {\r
956                         drop_chapterFinish.BackColor = Color.LightCoral;\r
957                     }\r
958                 }\r
959                 catch (Exception)\r
960                 {\r
961                     drop_chapterFinish.BackColor = Color.LightCoral;\r
962                 }\r
963             }\r
964         }\r
965 \r
966         private void text_bitrate_TextChanged(object sender, EventArgs e)\r
967         {\r
968             text_filesize.Text = "";\r
969             slider_videoQuality.Value = 0;\r
970             SliderValue.Text = "0%";\r
971             CheckCRF.CheckState = CheckState.Unchecked;\r
972             CheckCRF.Enabled = false;\r
973         }\r
974 \r
975         private void text_filesize_TextChanged(object sender, EventArgs e)\r
976         {\r
977             text_bitrate.Text = "";\r
978             slider_videoQuality.Value = 0;\r
979             SliderValue.Text = "0%";\r
980             CheckCRF.CheckState = CheckState.Unchecked;\r
981             CheckCRF.Enabled = false;\r
982         }\r
983 \r
984         private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
985         {\r
986             SliderValue.Text = slider_videoQuality.Value.ToString() + "%";\r
987             text_bitrate.Text = "";\r
988             text_filesize.Text = "";\r
989             CheckCRF.Enabled = true;\r
990         }\r
991 \r
992         private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
993         {\r
994             Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");\r
995         }\r
996 \r
997         private void text_width_TextChanged(object sender, EventArgs e)\r
998         {\r
999             try\r
1000             {\r
1001                 if (CheckPixelRatio.Checked)\r
1002                 {\r
1003                     text_width.Text = "";\r
1004                     text_width.BackColor = Color.LightCoral;\r
1005                     CheckPixelRatio.BackColor = Color.LightCoral;\r
1006                 }\r
1007                 else\r
1008                 {\r
1009                     if ((int.Parse(text_width.Text) % 16) != 0)\r
1010                     {\r
1011                         text_width.BackColor = Color.LightCoral;\r
1012                     }\r
1013                     else\r
1014                     {\r
1015                         text_width.BackColor = Color.LightGreen;\r
1016                     }\r
1017                 }\r
1018 \r
1019                 if (lbl_Aspect.Text != "Select a Title")\r
1020                 {\r
1021                     double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);\r
1022                     double mod16 = height % 16;\r
1023                     height = height - mod16;\r
1024 \r
1025                     if (text_width.Text == "")\r
1026                     {\r
1027                         text_height.Text = "";\r
1028                         text_width.BackColor = Color.White;\r
1029                     }\r
1030                     else\r
1031                     {\r
1032                         text_height.Text = height.ToString();\r
1033                         text_width.BackColor = Color.LightGreen;\r
1034                     }\r
1035                 }\r
1036             }\r
1037             catch (Exception)\r
1038             {\r
1039                 // No need to throw an error here.\r
1040                 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.\r
1041             }\r
1042 \r
1043 \r
1044         }\r
1045 \r
1046         private void text_height_TextChanged(object sender, EventArgs e)\r
1047         {\r
1048             try\r
1049             {\r
1050                 if (CheckPixelRatio.Checked)\r
1051                 {\r
1052                     text_height.Text = "";\r
1053                     text_height.BackColor = Color.LightCoral;\r
1054                     CheckPixelRatio.BackColor = Color.LightCoral;\r
1055                 }\r
1056                 else\r
1057                 {\r
1058                     if ((int.Parse(text_height.Text) % 16) != 0)\r
1059                     {\r
1060                         text_height.BackColor = Color.LightCoral;\r
1061                     }\r
1062                     else\r
1063                     {\r
1064                         text_height.BackColor = Color.LightGreen;\r
1065                     }\r
1066                 }\r
1067 \r
1068             }\r
1069             catch (Exception)\r
1070             {\r
1071                 // No need to alert the user.\r
1072             }\r
1073         }\r
1074 \r
1075         private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)\r
1076         {\r
1077             if ((string)drp_crop.SelectedItem == "Manual")\r
1078             {\r
1079                 text_left.Enabled = true;\r
1080                 text_right.Enabled = true;\r
1081                 text_top.Enabled = true;\r
1082                 text_bottom.Enabled = true;\r
1083             }\r
1084 \r
1085             if ((string)drp_crop.SelectedItem == "Auto Crop")\r
1086             {\r
1087                 text_left.Enabled = false;\r
1088                 text_right.Enabled = false;\r
1089                 text_top.Enabled = false;\r
1090                 text_bottom.Enabled = false;\r
1091                 text_left.Text = "";\r
1092                 text_right.Text = "";\r
1093                 text_top.Text = "";\r
1094                 text_bottom.Text = "";\r
1095 \r
1096                 if (lbl_RecomendedCrop.Text != "Select a Title")\r
1097                 {\r
1098                     string[] temp = new string[4];\r
1099                     temp = lbl_RecomendedCrop.Text.Split('/');\r
1100                     text_left.Text = temp[2];\r
1101                     text_right.Text = temp[3];\r
1102                     text_top.Text = temp[0];\r
1103                     text_bottom.Text = temp[1];\r
1104                 }\r
1105             }\r
1106 \r
1107             if ((string)drp_crop.SelectedItem == "No Crop")\r
1108             {\r
1109                 text_left.Enabled = false;\r
1110                 text_right.Enabled = false;\r
1111                 text_top.Enabled = false;\r
1112                 text_bottom.Enabled = false;\r
1113                 text_left.Text = "0";\r
1114                 text_right.Text = "0";\r
1115                 text_top.Text = "0";\r
1116                 text_bottom.Text = "0";\r
1117 \r
1118             }\r
1119         }\r
1120 \r
1121         private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)\r
1122         {\r
1123             text_width.Text = "";\r
1124             text_height.Text = "";\r
1125             text_width.BackColor = Color.White;\r
1126             text_height.BackColor = Color.White;\r
1127             CheckPixelRatio.BackColor = TabPage1.BackColor;\r
1128         }\r
1129 \r
1130         private void check_2PassEncode_CheckedChanged(object sender, EventArgs e)\r
1131         {\r
1132             if (check_2PassEncode.CheckState.ToString() == "Checked")\r
1133             {\r
1134                 if (drp_videoEncoder.Text.Contains("H.264"))\r
1135                 {\r
1136                     check_turbo.Enabled = true;\r
1137                 }\r
1138             }\r
1139             else\r
1140             {\r
1141                 check_turbo.Enabled = false;\r
1142                 check_turbo.CheckState = CheckState.Unchecked;\r
1143             }\r
1144         }\r
1145 \r
1146         private void check_largeFile_CheckedChanged(object sender, EventArgs e)\r
1147         {\r
1148             if (!text_destination.Text.Contains(".mp4"))\r
1149             {\r
1150                 lbl_largeMp4Warning.Text = "Warning: Only mp4 files are supported";\r
1151                 lbl_largeMp4Warning.ForeColor = Color.Red;\r
1152                 check_largeFile.CheckState = CheckState.Unchecked;\r
1153             }\r
1154             else\r
1155             {\r
1156                 lbl_largeMp4Warning.Text = "Warning: Breaks iPod, @TV, PS3 compatibility.";\r
1157                 lbl_largeMp4Warning.ForeColor = Color.Black;\r
1158             }\r
1159         }\r
1160 \r
1161         private void drp_dvdtitle_Click(object sender, EventArgs e)\r
1162         {\r
1163             if (drp_dvdtitle.Items.Count == 0)\r
1164             {\r
1165                 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
1166             }\r
1167         }\r
1168 \r
1169         private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)\r
1170         {\r
1171 \r
1172             //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch\r
1173 \r
1174             drp_audioMixDown.Items.Clear();\r
1175 \r
1176             if (drp_audioCodec.Text == "AAC")\r
1177             {\r
1178                 drp_audioMixDown.Items.Clear();\r
1179                 drp_audioMixDown.Items.Add("Mono");\r
1180                 drp_audioMixDown.Items.Add("Stereo");\r
1181                 drp_audioMixDown.Items.Add("Dolby Surround");\r
1182                 drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
1183                 drp_audioMixDown.Items.Add("6 Channel Discrete");\r
1184 \r
1185                 drp_audioBitrate.Items.Clear();\r
1186                 drp_audioBitrate.Items.Add("32");\r
1187                 drp_audioBitrate.Items.Add("40");\r
1188                 drp_audioBitrate.Items.Add("48");\r
1189                 drp_audioBitrate.Items.Add("56");\r
1190                 drp_audioBitrate.Items.Add("64");\r
1191                 drp_audioBitrate.Items.Add("80");\r
1192                 drp_audioBitrate.Items.Add("86");\r
1193                 drp_audioBitrate.Items.Add("112");\r
1194                 drp_audioBitrate.Items.Add("128");\r
1195                 drp_audioBitrate.Items.Add("160");\r
1196 \r
1197             }\r
1198             else\r
1199             {\r
1200                 drp_audioMixDown.Items.Clear();\r
1201                 drp_audioMixDown.Items.Add("Stereo");\r
1202                 drp_audioMixDown.Items.Add("Dolby Surround");\r
1203                 drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
1204 \r
1205                 drp_audioBitrate.Items.Clear();\r
1206                 drp_audioBitrate.Items.Add("32");\r
1207                 drp_audioBitrate.Items.Add("40");\r
1208                 drp_audioBitrate.Items.Add("48");\r
1209                 drp_audioBitrate.Items.Add("56");\r
1210                 drp_audioBitrate.Items.Add("64");\r
1211                 drp_audioBitrate.Items.Add("80");\r
1212                 drp_audioBitrate.Items.Add("86");\r
1213                 drp_audioBitrate.Items.Add("112");\r
1214                 drp_audioBitrate.Items.Add("128");\r
1215                 drp_audioBitrate.Items.Add("160");\r
1216                 drp_audioBitrate.Items.Add("192");\r
1217                 drp_audioBitrate.Items.Add("224");\r
1218                 drp_audioBitrate.Items.Add("256");\r
1219                 drp_audioBitrate.Items.Add("320");\r
1220             }\r
1221         }\r
1222 \r
1223         private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)\r
1224         {\r
1225             if (drp_audioCodec.Text == "AAC")\r
1226             {\r
1227                 if (drp_audioMixDown.Text == "6 Channel Discrete")\r
1228                 {\r
1229 \r
1230                     drp_audioBitrate.Items.Clear();\r
1231                     drp_audioBitrate.Items.Add("32");\r
1232                     drp_audioBitrate.Items.Add("40");\r
1233                     drp_audioBitrate.Items.Add("48");\r
1234                     drp_audioBitrate.Items.Add("56");\r
1235                     drp_audioBitrate.Items.Add("64");\r
1236                     drp_audioBitrate.Items.Add("80");\r
1237                     drp_audioBitrate.Items.Add("86");\r
1238                     drp_audioBitrate.Items.Add("112");\r
1239                     drp_audioBitrate.Items.Add("128");\r
1240                     drp_audioBitrate.Items.Add("160");\r
1241                     drp_audioBitrate.Items.Add("192");\r
1242                     drp_audioBitrate.Items.Add("224");\r
1243                     drp_audioBitrate.Items.Add("256");\r
1244                     drp_audioBitrate.Items.Add("320");\r
1245                     drp_audioBitrate.Items.Add("384");\r
1246                 }\r
1247             }\r
1248         }\r
1249 \r
1250         private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
1251         {\r
1252             if (Check_ChapterMarkers.Checked)\r
1253             {\r
1254                 string destination = text_destination.Text;\r
1255                 destination = destination.Replace(".mp4", ".m4v");\r
1256                 text_destination.Text = destination;\r
1257             }\r
1258             else\r
1259             {\r
1260                 string destination = text_destination.Text;\r
1261                 destination = destination.Replace(".m4v", ".mp4");\r
1262                 text_destination.Text = destination;\r
1263             }\r
1264         }\r
1265 \r
1266         private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)\r
1267         {\r
1268             //Turn off some options which are H.264 only when the user selects a non h.264 encoder\r
1269             if (!drp_videoEncoder.Text.Contains("H.264"))\r
1270             {\r
1271                 check_turbo.CheckState = CheckState.Unchecked;\r
1272                 CheckCRF.CheckState = CheckState.Unchecked;\r
1273                 CheckCRF.Enabled = false;\r
1274                 check_turbo.Enabled = false;\r
1275                 h264Tab.Enabled = false;\r
1276                 rtf_h264advanced.Text = "";\r
1277             }\r
1278             else\r
1279             {\r
1280                 CheckCRF.Enabled = true;\r
1281                 if (check_2PassEncode.CheckState.ToString() == "Checked")\r
1282                 {\r
1283                     check_turbo.Enabled = true;\r
1284                 }\r
1285                 h264Tab.Enabled = true;\r
1286             }\r
1287 \r
1288         }\r
1289 \r
1290         public void setStreamReader(Parsing.DVD dvd)\r
1291         {\r
1292             this.thisDVD = dvd;\r
1293         }\r
1294 \r
1295         private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
1296         {\r
1297             // Reset some values on the form\r
1298             lbl_Aspect.Text = "Select a Title";\r
1299             lbl_RecomendedCrop.Text = "Select a Title";\r
1300             drop_chapterStart.Items.Clear();\r
1301             drop_chapterFinish.Items.Clear();\r
1302             QueryEditorText.Text = "";\r
1303 \r
1304             // If the dropdown is set to automatic nothing else needs to be done.\r
1305             // Otheriwse if its not, title data has to be loased from parsing.\r
1306             if (drp_dvdtitle.Text != "Automatic")\r
1307             {\r
1308                 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;\r
1309 \r
1310                 // Set the Aspect Ratio\r
1311                 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();\r
1312 \r
1313                 // Set the Recommended Cropping values\r
1314                 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);\r
1315 \r
1316                 // Populate the Start chapter Dropdown\r
1317                 drop_chapterStart.Items.Clear();\r
1318                 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());\r
1319                 if (drop_chapterStart.Items.Count > 0)\r
1320                 {\r
1321                     drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();\r
1322                 }\r
1323 \r
1324                 // Populate the Final Chapter Dropdown\r
1325                 drop_chapterFinish.Items.Clear();\r
1326                 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());\r
1327                 if (drop_chapterFinish.Items.Count > 0)\r
1328                 {\r
1329                     drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();\r
1330                 }\r
1331 \r
1332                 // Populate the Audio Channels Dropdown\r
1333                 drp_audioChannels.Items.Clear();\r
1334                 drp_audioChannels.Items.Add("Automatic");\r
1335                 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
1336                 if (drp_audioChannels.Items.Count > 0)\r
1337                 {\r
1338                     drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();\r
1339                 }\r
1340 \r
1341                 // Populate the Subtitles dropdown\r
1342                 drp_subtitle.Items.Clear();\r
1343                 drp_subtitle.Items.Add("None");\r
1344                 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
1345                 if (drp_subtitle.Items.Count > 0)\r
1346                 {\r
1347                     drp_subtitle.Text = drp_subtitle.Items[0].ToString();\r
1348                 }\r
1349             }\r
1350         }\r
1351 \r
1352         #endregion\r
1353 \r
1354         //---------------------------------------------------\r
1355         //  Some Functions\r
1356         //  - Query Generation\r
1357         //---------------------------------------------------\r
1358 \r
1359         #region Program Functions\r
1360 \r
1361         // Generate a CLI Query String\r
1362         public string GenerateTheQuery()\r
1363         {\r
1364             string source = text_source.Text;\r
1365             string dvdTitle = drp_dvdtitle.Text;\r
1366             string chapterStart = drop_chapterStart.Text;\r
1367             string chapterFinish = drop_chapterFinish.Text;\r
1368             int totalChapters = drop_chapterFinish.Items.Count - 1;\r
1369             string dvdChapter = "";\r
1370 \r
1371             source = " -i " + '"' + source + '"';\r
1372 \r
1373             if (dvdTitle == "Automatic")\r
1374                 dvdTitle = "";\r
1375             else\r
1376             {\r
1377                 string[] titleInfo = dvdTitle.Split(' ');\r
1378                 dvdTitle = " -t " + titleInfo[0];\r
1379             }\r
1380 \r
1381             if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))\r
1382                 dvdChapter = "";\r
1383             else if (chapterFinish == chapterStart)\r
1384                 dvdChapter = " -c " + chapterStart;\r
1385             else\r
1386                 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;\r
1387 \r
1388             string querySource = source + dvdTitle + dvdChapter;\r
1389             // ----------------------------------------------------------------------\r
1390 \r
1391             // Destination\r
1392 \r
1393             string destination = text_destination.Text;\r
1394             string videoEncoder = drp_videoEncoder.Text;\r
1395             string audioEncoder = drp_audioCodec.Text;\r
1396             string width = text_width.Text;\r
1397             string height = text_height.Text;\r
1398 \r
1399             if (destination == "")\r
1400                 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
1401             else\r
1402                 destination = " -o " + '"' + destination + '"'; //'"'+ \r
1403 \r
1404 \r
1405             switch (videoEncoder)\r
1406             {\r
1407                 case "Mpeg 4":\r
1408                     videoEncoder = " -e ffmpeg";\r
1409                     break;\r
1410                 case "Xvid":\r
1411                     videoEncoder = " -e xvid";\r
1412                     break;\r
1413                 case "H.264":\r
1414                     videoEncoder = " -e x264";\r
1415                     break;\r
1416                 case "H.264 Baseline 1.3":\r
1417                     videoEncoder = " -e x264b13";\r
1418                     break;\r
1419                 case "H.264 (iPod)":\r
1420                     videoEncoder = " -e x264b30";\r
1421                     break;\r
1422                 default:\r
1423                     videoEncoder = " -e x264";\r
1424                     break;\r
1425             }\r
1426 \r
1427             switch (audioEncoder)\r
1428             {\r
1429                 case "AAC":\r
1430                     audioEncoder = " -E faac";\r
1431                     break;\r
1432                 case "MP3":\r
1433                     audioEncoder = " -E lame";\r
1434                     break;\r
1435                 case "Vorbis":\r
1436                     audioEncoder = " -E vorbis";\r
1437                     break;\r
1438                 case "AC3":\r
1439                     audioEncoder = " -E ac3";\r
1440                     break;\r
1441                 default:\r
1442                     audioEncoder = " -E faac";\r
1443                     break;\r
1444             }\r
1445 \r
1446             if (width != "")\r
1447                 width = " -w " + width;\r
1448 \r
1449 \r
1450             if (height == "Auto")\r
1451             {\r
1452                 height = "";\r
1453             }\r
1454             else if (height != "")\r
1455             {\r
1456                 height = " -l " + height;\r
1457             }\r
1458 \r
1459 \r
1460             string queryDestination = destination + videoEncoder + audioEncoder + width + height;\r
1461             // ----------------------------------------------------------------------\r
1462 \r
1463             // Picture Settings Tab\r
1464 \r
1465             string cropSetting = drp_crop.Text;\r
1466             string cropTop = text_top.Text;\r
1467             string cropBottom = text_bottom.Text;\r
1468             string cropLeft = text_left.Text;\r
1469             string cropRight = text_right.Text;\r
1470             string subtitles = drp_subtitle.Text;\r
1471             string cropOut = "";\r
1472             string deInterlace_Option = drp_deInterlace_option.Text;\r
1473             string deinterlace = "";\r
1474             string grayscale = "";\r
1475             string pixelRatio = "";\r
1476             string ChapterMarkers = "";\r
1477             // Returns Crop Query\r
1478 \r
1479             if (cropSetting == "Auto Crop")\r
1480                 cropOut = "";\r
1481             else if (cropSetting == "No Crop")\r
1482                 cropOut = " --crop 0:0:0:0 ";\r
1483             else\r
1484             {\r
1485                 if (text_top.Text == "")\r
1486                     cropTop = "0";\r
1487                 if (text_bottom.Text == "")\r
1488                     cropBottom = "0";\r
1489                 if (text_left.Text == "")\r
1490                     cropLeft = "0";\r
1491                 if (text_right.Text == "")\r
1492                     cropRight = "0";\r
1493 \r
1494                 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
1495             }\r
1496 \r
1497             if (subtitles == "None")\r
1498                 subtitles = "";\r
1499             else if (subtitles == "")\r
1500                 subtitles = "";\r
1501             else\r
1502             {\r
1503                 string[] tempSub;\r
1504                 tempSub = subtitles.Split(' ');\r
1505                 subtitles = " -s " + tempSub[0];\r
1506             }\r
1507 \r
1508             switch (deInterlace_Option)\r
1509             {\r
1510                 case "None":\r
1511                     deinterlace = "";\r
1512                     break;\r
1513                 case "Original (Fast)":\r
1514                     deinterlace = " --deinterlace=fast";\r
1515                     break;\r
1516                 case "yadif (Slow)":\r
1517                     deinterlace = " --deinterlace=slow";\r
1518                     break;\r
1519                 case "yadif + mcdeint (Slower)":\r
1520                     deinterlace = " --deinterlace=slower";\r
1521                     break;\r
1522                 case "yadif + mcdeint (Slowest)":\r
1523                     deinterlace = " --deinterlace=slowest";\r
1524                     break;\r
1525                 default:\r
1526                     deinterlace = "";\r
1527                     break;\r
1528             }\r
1529 \r
1530             if (check_grayscale.Checked)\r
1531                 grayscale = " -g ";\r
1532 \r
1533             if (CheckPixelRatio.Checked)\r
1534                 pixelRatio = " -p ";\r
1535 \r
1536             if (Check_ChapterMarkers.Checked)\r
1537                 ChapterMarkers = " -m ";\r
1538 \r
1539             string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;\r
1540             // ----------------------------------------------------------------------\r
1541 \r
1542             // Video Settings Tab\r
1543 \r
1544             string videoBitrate = text_bitrate.Text;\r
1545             string videoFilesize = text_filesize.Text;\r
1546             double videoQuality = slider_videoQuality.Value;\r
1547             string vidQSetting = "";\r
1548             string twoPassEncoding = "";\r
1549             string videoFramerate = drp_videoFramerate.Text;\r
1550             string turboH264 = "";\r
1551             string largeFile = "";\r
1552             string deblock = "";\r
1553             string detelecine = "";\r
1554             string denoise = "";\r
1555             string CRF = CheckCRF.CheckState.ToString();\r
1556 \r
1557             if (CRF == "Checked")\r
1558                 CRF = " -Q ";\r
1559             else\r
1560                 CRF = "";\r
1561 \r
1562             if (videoBitrate != "")\r
1563                 videoBitrate = " -b " + videoBitrate;\r
1564 \r
1565             if (videoFilesize != "")\r
1566                 videoFilesize = " -S " + videoFilesize;\r
1567 \r
1568             // Video Quality Setting\r
1569 \r
1570             if ((videoQuality == 0))\r
1571                 vidQSetting = "";\r
1572             else\r
1573             {\r
1574                 videoQuality = videoQuality / 100;\r
1575                 if (videoQuality == 1)\r
1576                 {\r
1577                     vidQSetting = "1.0";\r
1578                 }\r
1579                 vidQSetting = " -q " + videoQuality.ToString(new CultureInfo("en-US")); \r
1580             }\r
1581 \r
1582             if (check_2PassEncode.Checked)\r
1583                 twoPassEncoding = " -2 ";\r
1584 \r
1585             if (videoFramerate == "Automatic")\r
1586                 videoFramerate = "";\r
1587             else\r
1588                 videoFramerate = " -r " + videoFramerate;\r
1589 \r
1590             if (check_turbo.Checked)\r
1591                 turboH264 = " -T ";\r
1592 \r
1593             if (check_largeFile.Checked)\r
1594                 largeFile = " -4 ";\r
1595 \r
1596             if (check_deblock.Checked)\r
1597                 deblock = " --deblock";\r
1598 \r
1599             if (check_detelecine.Checked)\r
1600                 detelecine = " --detelecine";\r
1601 \r
1602             switch (drp_deNoise.Text)\r
1603             {\r
1604                 case "None":\r
1605                     denoise = "";\r
1606                     break;\r
1607                 case "Weak":\r
1608                     denoise = " --denoise=weak";\r
1609                     break;\r
1610                 case "Medium":\r
1611                     denoise = " --denoise=medium";\r
1612                     break;\r
1613                 case "Strong":\r
1614                     denoise = " --denoise=strong";\r
1615                     break;\r
1616                 default:\r
1617                     denoise = "";\r
1618                     break;\r
1619             }\r
1620 \r
1621             string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + CRF + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;\r
1622             // ----------------------------------------------------------------------\r
1623 \r
1624             // Audio Settings Tab\r
1625 \r
1626             string audioBitrate = drp_audioBitrate.Text;\r
1627             string audioSampleRate = drp_audioSampleRate.Text;\r
1628             string audioChannels = drp_audioChannels.Text;\r
1629             string Mixdown = drp_audioMixDown.Text;\r
1630             string SixChannelAudio = "";\r
1631 \r
1632             if (audioBitrate != "")\r
1633                 audioBitrate = " -B " + audioBitrate;\r
1634 \r
1635             if (audioSampleRate != "")\r
1636                 audioSampleRate = " -R " + audioSampleRate;\r
1637 \r
1638             if (audioChannels == "Automatic")\r
1639                 audioChannels = "";\r
1640             else if (audioChannels == "")\r
1641                 audioChannels = "";\r
1642             else\r
1643             {\r
1644                 string[] tempSub;\r
1645                 tempSub = audioChannels.Split(' ');\r
1646                 audioChannels = " -a " + tempSub[0];\r
1647             }\r
1648 \r
1649             switch (Mixdown)\r
1650             {\r
1651                 case "Automatic":\r
1652                     Mixdown = "";\r
1653                     break;\r
1654                 case "Mono":\r
1655                     Mixdown = "mono";\r
1656                     break;\r
1657                 case "Stereo":\r
1658                     Mixdown = "stereo";\r
1659                     break;\r
1660                 case "Dolby Surround":\r
1661                     Mixdown = "dpl1";\r
1662                     break;\r
1663                 case "Dolby Pro Logic II":\r
1664                     Mixdown = "dpl2";\r
1665                     break;\r
1666                 case "6 Channel Discrete":\r
1667                     Mixdown = "6ch";\r
1668                     break;\r
1669                 default:\r
1670                     Mixdown = "";\r
1671                     break;\r
1672             }\r
1673 \r
1674             if (Mixdown != "")\r
1675                 SixChannelAudio = " -6 " + Mixdown;\r
1676             else\r
1677                 SixChannelAudio = "";\r
1678 \r
1679             string queryAudioSettings = audioBitrate + audioSampleRate + audioChannels + SixChannelAudio;\r
1680             // ----------------------------------------------------------------------\r
1681 \r
1682             //  H.264 Tab\r
1683 \r
1684 \r
1685             string h264Advanced = rtf_h264advanced.Text;\r
1686 \r
1687             if ((h264Advanced == ""))\r
1688                 h264Advanced = "";\r
1689             else\r
1690                 h264Advanced = " -x " + h264Advanced;\r
1691 \r
1692 \r
1693             string h264Settings = h264Advanced;\r
1694             // ----------------------------------------------------------------------\r
1695 \r
1696             // Processors (Program Settings)\r
1697 \r
1698             string processors = Properties.Settings.Default.Processors;\r
1699             //  Number of Processors Handler\r
1700 \r
1701             if (processors == "Automatic")\r
1702                 processors = "";\r
1703             else\r
1704                 processors = " -C " + processors + " ";\r
1705 \r
1706 \r
1707             string queryAdvancedSettings = processors;\r
1708             // ----------------------------------------------------------------------\r
1709 \r
1710             //  Verbose option (Program Settings)\r
1711 \r
1712             string verbose = "";\r
1713             if (Properties.Settings.Default.verbose == "Checked")\r
1714                 verbose = " -v ";\r
1715 \r
1716             // ----------------------------------------------------------------------\r
1717 \r
1718             return querySource + queryDestination + queryPictureSettings + queryVideoSettings + h264Settings + queryAudioSettings + queryAdvancedSettings + verbose;\r
1719         }\r
1720 \r
1721         // Load a Preset\r
1722         private void presetLoader(Functions.QueryParser presetQuery, string name)\r
1723         {\r
1724             // ---------------------------\r
1725             // Setup the GUI\r
1726             // ---------------------------\r
1727 \r
1728             // Source tab\r
1729             #region source\r
1730             if (presetQuery.Source != "")\r
1731                 text_source.Text = presetQuery.Source;\r
1732 \r
1733             if (presetQuery.DVDTitle != 0)\r
1734                 drp_dvdtitle.Text = presetQuery.DVDTitle.ToString();\r
1735 \r
1736             if (presetQuery.DVDChapterStart != 0)\r
1737                 drop_chapterStart.Text = presetQuery.DVDChapterStart.ToString();\r
1738 \r
1739             if (presetQuery.DVDChapterFinish != 0)\r
1740                 drop_chapterFinish.Text = presetQuery.DVDChapterFinish.ToString();\r
1741 \r
1742             if (presetQuery.Format != "")\r
1743             {\r
1744                 string destination = text_destination.Text;\r
1745                 destination = destination.Replace(".mp4", "." + presetQuery.Format);\r
1746                 destination = destination.Replace(".m4v", "." + presetQuery.Format);\r
1747                 destination = destination.Replace(".avi", "." + presetQuery.Format);\r
1748                 destination = destination.Replace(".mkv", "." + presetQuery.Format);\r
1749                 destination = destination.Replace(".ogm", "." + presetQuery.Format);\r
1750                 text_destination.Text = destination;\r
1751             }\r
1752 \r
1753             #endregion\r
1754 \r
1755             // Destination tab\r
1756             #region destination\r
1757 \r
1758             if (presetQuery.Destination != "")\r
1759                 text_destination.Text = presetQuery.Destination;\r
1760 \r
1761             drp_videoEncoder.Text = presetQuery.VideoEncoder;\r
1762             drp_audioCodec.Text = presetQuery.AudioEncoder;\r
1763             if (presetQuery.Width != 0)\r
1764             {\r
1765                 text_width.Text = presetQuery.Width.ToString();\r
1766            \r
1767             }\r
1768             else\r
1769             {\r
1770                 text_width.Text = "";\r
1771                 text_width.BackColor = Color.White;\r
1772             }\r
1773 \r
1774             if (presetQuery.Height != 0)\r
1775             {\r
1776                 text_height.Text = presetQuery.Height.ToString();\r
1777             }\r
1778             else\r
1779             {\r
1780                 text_height.Text = "";\r
1781                 text_height.BackColor = Color.White;\r
1782             }\r
1783             #endregion\r
1784 \r
1785             // Picture Settings Tab\r
1786             #region Picture\r
1787             drp_crop.Text = "Manual";\r
1788             text_top.Text = presetQuery.CropTop;\r
1789             text_bottom.Text = presetQuery.CropBottom;\r
1790             text_left.Text = presetQuery.CropLeft;\r
1791             text_right.Text = presetQuery.CropRight;\r
1792 \r
1793             drp_deInterlace_option.Text = presetQuery.DeInterlace;\r
1794             drp_deNoise.Text = presetQuery.DeNoise;\r
1795 \r
1796             if (presetQuery.DeTelecine == true)\r
1797             {\r
1798                 check_detelecine.CheckState = CheckState.Checked;\r
1799             }\r
1800             else\r
1801             {\r
1802                 check_detelecine.CheckState = CheckState.Unchecked;\r
1803             }\r
1804 \r
1805 \r
1806             if (presetQuery.DeBlock == true)\r
1807             {\r
1808                 check_deblock.CheckState = CheckState.Checked;\r
1809             }\r
1810             else\r
1811             {\r
1812                 check_deblock.CheckState = CheckState.Unchecked;\r
1813             }\r
1814 \r
1815             if (presetQuery.ChapterMarkers == true)\r
1816             {\r
1817                 Check_ChapterMarkers.CheckState = CheckState.Checked;\r
1818             }\r
1819             else\r
1820             {\r
1821                 Check_ChapterMarkers.CheckState = CheckState.Unchecked;\r
1822             }\r
1823 \r
1824             if (presetQuery.Anamorphic == true)\r
1825             {\r
1826                 CheckPixelRatio.CheckState = CheckState.Checked;\r
1827             }\r
1828             else\r
1829             {\r
1830                 CheckPixelRatio.CheckState = CheckState.Unchecked;\r
1831             }\r
1832             #endregion\r
1833 \r
1834             // Video Settings Tab\r
1835             #region video\r
1836             text_bitrate.Text = presetQuery.AverageVideoBitrate;\r
1837             text_filesize.Text = presetQuery.VideoTargetSize;\r
1838             slider_videoQuality.Value = presetQuery.VideoQuality;\r
1839             if (slider_videoQuality.Value != 0)\r
1840             {\r
1841                 CheckCRF.Enabled = true;\r
1842                 int ql = presetQuery.VideoQuality;\r
1843                 SliderValue.Text = ql.ToString() + "%";\r
1844             }\r
1845 \r
1846             if (presetQuery.TwoPass == true)\r
1847             {\r
1848                 check_2PassEncode.CheckState = CheckState.Checked;\r
1849             }\r
1850             else\r
1851             {\r
1852                 check_2PassEncode.CheckState = CheckState.Unchecked;\r
1853             }\r
1854 \r
1855             if (presetQuery.Grayscale == true)\r
1856             {\r
1857                 check_grayscale.CheckState = CheckState.Checked;\r
1858             }\r
1859             else\r
1860             {\r
1861                 check_grayscale.CheckState = CheckState.Unchecked;\r
1862             }\r
1863 \r
1864             drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
1865 \r
1866             if (presetQuery.TurboFirstPass == true)\r
1867             {\r
1868                 check_turbo.CheckState = CheckState.Checked;\r
1869             }\r
1870             else\r
1871             {\r
1872                 check_turbo.CheckState = CheckState.Unchecked;\r
1873             }\r
1874 \r
1875             if (presetQuery.LargeMP4 == true)\r
1876             {\r
1877                 check_largeFile.CheckState = CheckState.Checked;\r
1878             }\r
1879             else\r
1880             {\r
1881                 check_largeFile.CheckState = CheckState.Unchecked;\r
1882             }\r
1883             if (presetQuery.CRF == true)\r
1884             {\r
1885                 CheckCRF.CheckState = CheckState.Checked;\r
1886             }\r
1887             else\r
1888             {\r
1889                 CheckCRF.CheckState = CheckState.Unchecked;\r
1890             }\r
1891             #endregion\r
1892 \r
1893             // Audio Settings Tab\r
1894             #region audio\r
1895             drp_audioBitrate.Text = presetQuery.AudioBitrate;\r
1896             drp_audioSampleRate.Text = presetQuery.AudioSampleBitrate;\r
1897             drp_audioChannels.Text = presetQuery.AudioTrack1;\r
1898             drp_audioMixDown.Text = presetQuery.AudioTrackMix;\r
1899             drp_subtitle.Text = presetQuery.Subtitles;\r
1900             #endregion\r
1901 \r
1902             // H264 Tab & Preset Name\r
1903             #region other\r
1904             rtf_h264advanced.Text = presetQuery.H264Query;\r
1905 \r
1906             // Set the preset name\r
1907             groupBox_output.Text = "Output Settings (Preset: " + name + ")";\r
1908             #endregion\r
1909         }\r
1910 \r
1911         #endregion\r
1912 \r
1913         // This is the END of the road ------------------------------------------------------------------------------\r
1914     }\r
1915 }